/*------------------------ 
© 2009 Systen, L.L.C. 
10500 Barkley 
Suite 200 
Overland Park, KS 66212 
-----------------------
Created by: Michael Merrell
Date Created: 3/5/2009
-----------------------
Purpose:
-----------------------
*/
function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable) {
	var childWin;
	var childLeft = (screen.width - childWidth)/2;
	var childTop = (screen.height - childHeight)/2;

	childWin = self.window.open(childURL, '', 'toolbar='+toolbars+',status=no,menubar=no,scrollbars='+ scrollBars +
		',resizable='+resizable+',width='+ childWidth +',height='+ childHeight +',top='+childTop+',left='+childLeft);
	childWin.opener = self;
	
	return null;
}//function openWin(childURL, childWidth, childHeight, scrollBars, toolbars, resizable)

function IsBrowserIE() {
    if (navigator.appName == 'Microsoft Internet Explorer') {
        return true;
    }
    else {
        return false;
    }
}

function showWin(childURL, childWidth, childHeight) {
    if (childURL.toString().indexOf('/', 0) == 0) {
        if (self.location.host.toString().indexOf('localhost', 0) != 0) {
            childURL = '/Secure' + childURL;
        }
    }
    if (document.documentElement.clientWidth <= childWidth || document.documentElement.clientHeight <= childHeight)
    {
        openWin(childURL, childWidth, childHeight, 'no', 'no', 'no');
    }
    else if (document.getElementById('dvWindowMain') && document.getElementById('iWindow') && document.getElementById('dvWindow'))
    {
        var dvWindowMain = document.getElementById('dvWindowMain');
        var dvWindow = document.getElementById('dvWindow');
        var iWindow = document.getElementById('iWindow');
                
        dvWindowMain.style.display = "block";
        
        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';
        
        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
    }
    else
    {
        var dvWindowMain = document.createElement('div');
        var dvBlackOut = document.createElement('div');
        var dvWindow = document.createElement('div');
        var iWindow = document.createElement('iframe');
        
        dvWindowMain.appendChild(dvBlackOut);
        dvWindowMain.appendChild(dvWindow);    
        dvWindow.appendChild(iWindow);
        
        dvWindowMain.id = "dvWindowMain";
        dvWindowMain.style.width = "100%";
        dvWindowMain.style.height = "100%";
        dvWindowMain.style.display = "block";
        dvWindowMain.style.position = "absolute";
        dvWindowMain.style.left = "0px";
        dvWindowMain.style.top = "0px";
        
        dvBlackOut.className = "dvBlackOut";
        
        dvWindow.id = "dvWindow";
        dvWindow.className = "dvWindow";
        dvWindow.style.width = childWidth + 'px';
        dvWindow.style.height = childHeight + 'px';
        dvWindow.style.left = ((document.documentElement.clientWidth - childWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - childHeight) / 2) + 'px';
        
        iWindow.id = "iWindow"
        iWindow.src = childURL;
        iWindow.height = childHeight + 'px';
        iWindow.width = childWidth + 'px';
        iWindow.frameborder = "0";
        
        document.forms[0].appendChild(dvWindowMain);
    }
}

function closeWin(bRefresh)
{
    if (parent.document.getElementById('dvWindowMain') && bRefresh)
    {
        parent.document.location = parent.document.location;
    }
    else if (parent.document.getElementById('dvWindowMain') && bRefresh == false)
    {
        parent.document.getElementById('dvWindowMain').style.display = "none";
        parent.document.getElementById('iWindow').src = "";
    }
    else if (document.getElementById('dvWindowMain') && bRefresh)
    {
        document.location = document.location;
    }
    else if (document.getElementById('dvWindowMain') && bRefresh == false)
    {
        document.getElementById('dvWindowMain').style.display = "none";
        document.getElementById('iWindow').src = "";
    }
    else if (self.opener && self.opener.document.getElementById('dvWindowMain') && bRefresh)
    {
        self.opener.document.location = self.opener.document.location;
        self.close();
    }
    else //if (self.opener && bRefresh == false)
    {
        self.close();
    }
}

function centerWin()
{
    var dvWindow = document.getElementById('dvWindow');
    if (dvWindow != null)
    {
        dvWindow.style.left = ((document.documentElement.clientWidth - dvWindow.clientWidth) / 2) + 'px';
        dvWindow.style.top = ((document.documentElement.clientHeight - dvWindow.clientHeight) / 2) + 'px';
    }
}

