﻿//get browser type
var msie = false
var mozilla = false
var userAgent = new String(window.navigator.userAgent)

if(userAgent.indexOf("MSIE") >= 0) 
	msie = true
else if(userAgent.indexOf("Mozilla") >= 0)
	mozilla = true
	
function GetModalDialogTop(dialogHeight)
{
	var screenTop = 0
	var clientHeight = 0
	var bodyClientHeight = 0
	
	if(msie)
	{
		screenTop = window.screenTop //top of the client area relative to the screen
		//clientHeight = document.documentElement.clientHeight //the height of the client area
		clientHeight = document.body.clientHeight
	}
	else if (mozilla)
	{
		screenTop = window.screenY //top of the window 
		clientHeight = window.innerHeight //the height of the client area
	}
	var top = screenTop + (clientHeight - dialogHeight)/2 
	//alert("msie="+msie)
	//alert("mozilla="+mozilla)
	//alert("screenTop="+screenTop)
	//alert("clientHeight="+clientHeight)
	//alert("top="+top)
	return top
}
	
function GetModalDialogLeft(dialogWidth)
{
	var screenLeft = 0
	var clientWidth =	0
	
	if(msie)
	{
		screenLeft = window.screenLeft //left coordinate of the client area relative to the screen
		clientWidth = document.body.clientWidth //the width of the client area
	}
	else if (mozilla)
	{
		screenLeft = window.screenX //left coordinate of the window
		clientWidth = window.innerWidth //the width of the client area
	}
	var left = screenLeft + (clientWidth - dialogWidth)/2 
	//alert("screenLeft="+screenLeft)
	//alert("clientWidth="+clientWidth)
	//alert("left="+left)
	return left
}


function OpenModalDialog(url, winName, top, left, height, width, toolbar, status, menubar, scrollbars, resizable) 
{
    if(status == 0)
        status="no";
    else
        status="yes";
                
	if (window.showModalDialog) 
	{
		var features = "dialogTop:"+top+"; dialogLeft:"+left+"; dialogHeight:"+height+"px; dialogWidth:"+width+"px; resizable:"+resizable+"; status:"+status+"; scroll:"+scrollbars;
		window.showModalDialog(url, "", features)
	} 
	else 
	{
		var features = "top="+top+", left="+left+", height="+height+", width="+width+", toolbar="+toolbar+", status="+status+", menubar="+menubar+", scrollbars="+scrollbars+", resizable="+resizable+", modal=yes";
		window.open(url,winName,features);
	}
} 

function CloseModalDialog()
{
	if(mozilla)
	{
		window.opener.location.reload()
		window.close()
	}
	else if (msie)
	{
		window.close()
	}
}

