﻿// JScript File

var winModalWindow;
 
function IgnoreEvents(e)
{
  return false;
}
 
function ShowWindow(href)
{
    var w = 480;
    var h = 340;
    
    var t = window.screenTop;
    var l = window.screenLeft;
    
    var maxleftpos = window.screen.width - 800;
    var maxtoppos = window.screen.height - 600;

    if(document.all)
    {
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    else
    {
        w = window.innerWidth;
        h = window.innerHeight;
    }
    
    var leftpos = l + ((w-800) / 2);
    if(leftpos > maxleftpos)
    {
        leftpos = maxleftpos;
    }
    
    var toppos = t + (h-600)/ 2;
    if(toppos > maxtoppos)
    {
        toppos = maxtoppos;
    }

//    if (window.showModalDialog)
//	{
//		window.showModalDialog(href, self, "dialogWidth:810px;dialogHeight:600px;dialogTop:" + toppos + ";dialogLeft:" + leftpos + ";status:off;resizable:no;scroll:no;help: no;");
//	}
//	else
//	{
//        window.top.captureEvents (Event.CLICK|Event.FOCUS);
//        window.top.onclick = IgnoreEvents;
//        window.top.onfocus = HandleFocus;
        winModalWindow = window.open (href, "NST_Center", "location=no,menubar=no,resizable=no,scrollbars=no,toolbar=no,dependent=yes,width=800,height=600,top=" + toppos + ",left=" + leftpos);
        winModalWindow.focus();
//    }
}

function ShowWindowSized(href, width, height)
{
    var w = 480;
    var h = 340;
    
    var t = window.screenTop;
    var l = window.screenLeft;
    
    var maxleftpos = window.screen.width - width;
    var maxtoppos = window.screen.height - height;

    if(document.all)
    {
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    else
    {
        w = window.innerWidth;
        h = window.innerHeight;
    }
    
    var leftpos = l + ((w-width) / 2);
    if(leftpos > maxleftpos)
    {
        leftpos = maxleftpos;
    }
    
    var toppos = t + ((h-height)/ 2);
    if(toppos > maxtoppos)
    {
        toppos = maxtoppos;
    }

//    if (window.showModalDialog)
//	{
//		window.showModalDialog(href, self, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;top:" + toppos + ";left:" + leftpos + ";status:off;resizable:no;scroll:no;help: no;");
//	}
//	else
//	{
//        window.top.captureEvents (Event.CLICK|Event.FOCUS);
//        window.top.onclick = IgnoreEvents;
//        window.top.onfocus = HandleFocus;
        winModalWindow = window.open (href, "NST_Center", "width=" + width + ",height=" + height + ",top=" + toppos + ",left=" + leftpos);
        winModalWindow.focus();
//    }
}

 
function HandleFocus()
{
    if (winModalWindow)
    {
        if (!winModalWindow.closed)
        {
            winModalWindow.focus();
        }
        else
        {
            window.top.releaseEvents (Event.CLICK|Event.FOCUS);
            window.top.onclick = "";
        }
    }
    
    return false;
}

function CloseWindow()
{
//    if (window.showModalDialog)
//	{
//	    window.dialogArguments.location = window.dialogArguments.location;
//	    //self.close();
//	}
//	else
//	{
	    window.opener.location.href = window.opener.location.href;
	//}
	
	window.close();
}

function refreshGrids()
{
    var btn = document.getElementById("ctl00_btnRefreshGrids");
    if(btn)
    {
        btn.click();
    }
    
    var btn2 = document.getElementById("ctl00_EditorContentPlaceHolder_btnRefreshGrids");
    if(btn2)
    {
        btn2.click();
    }
    
}

function refreshGrids2()
{
    var btn = document.getElementById("ctl00_EditorContentPlaceHolder_btnRefreshGrids");
    if(btn)
    {
        btn.click();
    }
}

function refreshGridsSpecial()
{
    document.getElementById("ctl00_EditorContentPlaceHolder_btnRefreshSpecial").click();
}

function refreshJobOrderSelect()
{
    document.getElementById("ctl00_MainContent_btnReloadPage").click();
}