var PopupWindow;

function OpenPopupWindow(URL, WindowName, WindowProps)
{
	PopupWindow = window.open(URL, WindowName, WindowProps);
	document.body.onunload = DoUnload;
}

function DoUnload()
{
//	alert(window.document.childNodes.Agent.KeepMe);
	if(PopupWindow != null)
	{
		try
		{
			if(PopupWindow.KeepMe != null)
			{
				if(!PopupWindow.KeepMe)
				{
					PopupWindow.close();
				}
				else
				{
					PopupWindow.KeepMe = false;
					PopupWindow.focus();
				}
			}
		}
		catch(e)
		{
			PopupWindow = null;
		}
	}
}

// function to display modal popup window
// works with Internet Explorer 

function popitupDailog(url) {

    var w = 600, h = 600;
    if (document.all) {
       /* the following is only available after onLoad */
       w = document.body.clientWidth;
       h = document.body.clientHeight;
    }
    else if (document.layers) {
       w = window.innerWidth;
       h = window.innerHeight;
    }
    var popW = 310, popH = 330;
    var leftPos = (w-popW)/2, topPos = (h-popH)/2;

		var WinSettings = "center:yes;resizable:no;status:no;dialogHeight:" + popH + "px;dialogWidth:" + popW + "px;dialogLeft:" + leftPos +";dialogTop" + topPos;
		
		//window.showModalDialog(url,'OfficeDetial',WinSettings); 
		
	if(-1 != navigator.userAgent.indexOf("MSIE"))
     {
      var return_value = window.showModalDialog(url,"OfficeDetail",WinSettings);
     }
     else if(-1 != navigator.userAgent.indexOf("Firefox"))
     {
     
        var return_value;
       return_value = window.open(url, "", "modal=yes,toolbar=false,location=false,directories=false,status=false,menubar=false,scrollbars=no,resizable=no,width="+popW+",height="+popH + ",top="+ topPos + ",left=" + leftPos);
       window.returnValue = false;
        
     
     }		

}
