﻿var _modalpopup = null;

function showModalPopup(url, width, height)
{
    // if popup closed new popup will be opened
    if (isPopupClosed() == true)
    {   
        _modalpopup = window.open(url, '', 'height=' + height + ', width=' + width + ', toolbar=no, menubar=no, resizable=yes');
    }
}

// check's is modal popup closed or opend (if opened set's focus to popup)
function isPopupClosed()
{
    // if popup undefined or closed return true
    if (!_modalpopup || _modalpopup.closed == true)
    {
        return true;
    }
    
    // otherwise returns false
    return false;
}

// page validator disallows postbacks while modal popup is opened
function modalPopupValidator_Validate(sender ,e)
{
    // validator is valid if popup is closed
    e.IsValid = isPopupClosed();
}

// document body click event handler
function body_Click(sender, e)
{
    if (isPopupClosed() == false)
    {
        _modalpopup.focus();
    }
}

// changes exception handling system page
function switchSystemPage(url)
{
    // if popup is closed navigate to specified url
    if (isPopupClosed())
    {
        window.location.href = url;
    }
}

