﻿// javascript File

function confirmSubmit(elementId, displayDivId) {
    var lbl = document.getElementById(elementId);

    if (lbl != null && typeof (lbl) != "undefined") {
        //lbl.className += " link-button";
        lbl.style.cursor = "not-allowed";
        var timoutfunc = "var btn = document.getElementById('" + elementId + "'); btn.disabled = true; btn.style.cursor = 'not-allowed';";
        window.setTimeout(timoutfunc, 10);

        // Show the display div if required..
        showHideDisplay(displayDivId, "block")
    }    
}


function openPopupWindow(URL, windowName) {
    openWindow(URL, windowName, 900, 800, 1, 1);
}

function openPrintWindow(URL, windowName) {
    var width = 900;
    var height = 800;
    var scroller = 1;
    var resizable = 1;
    var menubar = 1;

    if (popupWindow1 && !popupWindow1.closed) {
        popupWindow1.close();
    }
    // To debug the source use the normal window options.
    // popupWindow1 = window.open(URL, windowName);
    popupWindow1 = window.open(URL, windowName, "toolbar=1, location=1, status=1, menubar=" + menubar + ", top=0, left=0, screenX=0, screenY=0,  scrollbars =" + scroller + " , width=" + width + ", height=" + height + ", resizable=" + resizable);
    //popupWindow1.moveTo(0,0);	

}

// Pop Up
var popupWindow1 = null;

function openWindow(URL, windowName, width, height, scroller, resizable) {
    if (popupWindow1 && !popupWindow1.closed) {
        popupWindow1.close();
    }
    // To debug the source use the normal window options.
    // popupWindow1 = window.open(URL, windowName);
    popupWindow1 = window.open(URL, windowName, "toolbar=1, location=0, status=0, menubar=0, top=0, left=0, screenX=0, screenY=0,  scrollbars =" + scroller + " , width=" + width + ", height=" + height + ", resizable=" + resizable);
    //popupWindow1.moveTo(0,0);	
}

// Used to close the window.
function closeWindow() {
    // Force the Parent window to refresh.
    //refreshParent();

    if (popupWindow1 && !popupWindow1.closed) {
        popupWindow1.close();
    }
    else {
        // Since most of the calls will come from a postback the popupWindow1 will be null.
        // Just default to close the current window.
        window.close();
    }
}

// Causes the Parent window to reload
function refreshParent() {
    if (window.opener != null && !window.opener.closed) {
        //alert(window.opener.location);
        // Foces a full page reload/rebind.
        window.opener.location = window.opener.location;
        // Doesn't cause the rebind
        //window.opener.document.forms[0].submit();
        // We could use a GetPostBackEventReference for one of the
        // buttons on the form but will do this in the future if time permits.
    }
    else {
        //alert("opener is null");
    }
}

