﻿var currentModal;
        
        
function showModal(modalName)
{
    var modal = Sys.Application.findComponent(modalName);
    if (!modal)
        alert("Error: Please refresh the page, wait for it to load completely, and try again (cannot find modal dialog).");
    else
        modal.show();

    setTimeout("modalFocus()", 250);

    currentModal = modalName;
}


function hideModal(modalName)
{
    var modal = Sys.Application.findComponent(modalName);
    if (!modal)
        alert("Error: Please refresh the page, wait for it to load completely, and try again (cannot find modal dialog).");
    else
        modal.hide();

    currentModal = null;
}


function modalFocus()
{
    try
    {
        document.getElementById("ctl00_LLogin_UserName").focus();
    }
    catch (focusError) {
        try {
            document.getElementById("ctl00_TBCurrentPW").focus();
        }
        catch (focusError2) { }
    }
}


function closeOnEscape(e) {
    if (e.keyCode == 27 && currentModal != null && currentModal != 'resetPW') {
        hideModal(currentModal);
    }
}