﻿var defaultDialogWidth = 800;
var defaultDialogHeight = 600;

function showDialog(url, dialogWidth, dialogHeight, resizable) {
    if (!window.showModalDialog) {
        alert('Your browser does not support modal dialogs.');
        return null;
    }

    if (!dialogWidth) {
        dialogWidth = defaultDialogWidth;
    }
    if (!dialogHeight) {
        dialogHeight = defaultDialogHeight;
    }
    if (!resizable) {
        resizable = 'yes';
    }

    return window.showModalDialog(url, null, 'dialogWidth:' + dialogWidth + 'px;dialogHeight:' + dialogHeight + 'px;center:yes;resizable:' + resizable + ';scroll:yes;status:yes;');
}

function showConfirm(url, message) {
    if (window.showModalDialog) {
        var dialogResult = showDialog(url, 400, 150, 'no');
        return (dialogResult && dialogResult.length > 0);
    }
    else {
        return confirm(message);
    }
}
function showAlert(url, message) {
    if (window.showModalDialog) {
        return showDialog(url, 400, 150, 'no');
    }
    else {
        return alert(message);
    }
}


function setDialogResult(dialogResult) {
    window.returnValue = dialogResult;
    window.opener = top;
    window.close();
}


function openAdministrationWindow(url, w, h) {

    var width = (w ? w : 800);
    var height = (h ? h : 600);

    return window.open(url, '_blank', 'width=' + width + ',height='+height+',resizable=yes,scrollbars=1', false);
}
