﻿function showwin(url,title) {
    
    var theurl = url;
    var thetitle = title;
    
    if (url.toString().indexOf("?") > -1)
        theurl = theurl //+ "&guid=" + generateGuid();
    else
        theurl = theurl //+ "?guid=" + generateGuid();

    $("#ddialog").dialog({
        modal: true,
        overlay: {
            opacity: 0.5,
            background: "white"
        },
        title: thetitle,
        width: 800,
        height: 575,
        resizable: false,
        autoResize: true,
        close: closed,
        resizableOptions: { autoResize: true, autoHide: true }
    }).show();
    $("#createPageiFrame").attr("src", theurl);
    $("#createPageiFrame").css("display", "block");
}
function showwinpostback(url, title, height, width) {

    var theurl = url;
    var thetitle = title;

    if (url.toString().indexOf("?") > -1)
        theurl = theurl //+ "&guid=" + generateGuid();
    else
        theurl = theurl //+ "?guid=" + generateGuid();

    $("#ddialog").dialog({
        modal: true,
        overlay: {
            opacity: 0.5,
            background: "white"
        },
        title: thetitle,
        width: width,
        height: height,
        resizable: false,
        autoResize: true,
        close: closed,
        resizableOptions: { autoResize: true, autoHide: true }
    }).show();
    $("#createPageiFrame").attr("src", theurl);
    $("#createPageiFrame").css("display", "block");
}

function showwinpopup(url, title,height,width) {

    var theurl = url;
    var thetitle = title;

    if (url.toString().indexOf("?") > -1)
        theurl = theurl //+ "&guid=" + generateGuid();
    else
        theurl = theurl //+ "?guid=" + generateGuid();

    $("#ddialog").dialog({
        modal: false,
        overlay: {
            opacity: 0.5,
            background: "white"
        },
        title: thetitle,
        width: width,
        height: height,
        resizable: true,
        autoResize: true,
        close: closedwithoutpostback,
        resizableOptions: { autoResize: true, autoHide: true }
    }).show();
    $("#createPageiFrame").attr("src", theurl);
    $("#createPageiFrame").css("display", "block");
}
function closedwithoutpostback() {
    var d = $("#ddialog").dialog('destroy');
    //$("#createPageiFrame").attr("src", '/blank.htm');
    
}
function closed()
{
    var d = $("#ddialog").dialog('destroy');
    //$("#createPageiFrame").attr("src", '/blank.htm');
    if (window.frames["iAdmin"]) {
        window.frames["iAdmin"].location.href = window.frames["iAdmin"].location.href.replace('review=true', '');
    }
    else
        window.location.href = window.location.href.replace('review=true','');
}


function maximize() {
    var d = $("#ddialog");
    if (isMaximized == false) {
        var w = screen.width - 40;
        var h = screen.height - 70;
        d.data("width.dialog", w);
        d.data("height.dialog", h);
        $('#createPageiFrame').height(h - 70);
        $('#createPageiFrame').width(w - 40);
        isMaximized = true;
        debugger;
    }
    else {
        var w = 800;
        var h = 575;
        d.data("width.dialog", w);
        d.data("height.dialog", h);
        $('#createPageiFrame').height(h - 70);
        $('#createPageiFrame').width(w - 40);
        isMaximized = false;
    }
}

function generateGuid() {
    var result, i, j;
    result = '';
    for (j = 0; j < 32; j++) {
        if (j == 8 || j == 12 || j == 16 || j == 20)
            result = result + '-';
        i = Math.floor(Math.random() * 16).toString(16).toUpperCase();
        result = result + i;
    }
    return result
} 