function OpenWindow(strURL,winType,winName,winWidth,winHeight)
{
	var objWindow,blnlongcall=false,winHeightBrowserShell=0,scrollbars="no";
	var winLeft=0;
	var winTop=0;

	switch(winType)
	{
		case "customsize":
			blnlongcall=true;
			winHeightBrowserShell=50;
			break;
		case "customsizescroll":
			blnlongcall=true;
			winHeightBrowserShell=50;
			scrollbars = "yes";
			break;			
		case "spg":
			if( strURL.indexOf("gameplayer.aspx") > 0)
			{
			    if (screen.width<1024 || screen.height<768) 
                    scrollbars = "yes";
			    winWidth = 1024;winHeight=708;			    			    
			    winHeightBrowserShell=60;
			}
			else
			{
			    winWidth=800,winHeight=540;			    
			    winHeightBrowserShell=50;
			}			
			blnlongcall=true;
			
			break;
		case "iframe":
		    // window size for IFramePlayer
			if (screen.width<1024 || screen.height<768) 
                scrollbars = "yes";
			winWidth = 1024;winHeight=708;			    			    
			winHeightBrowserShell=60;
			blnlongcall=true;
			
			break;
		case "badges":
			winWidth=600,winHeight=470,blnlongcall=true;
			winHeightBrowserShell=50;
			break;
		case "learntoplay":
			winWidth=600,winHeight=470,blnlongcall=true;
			winLeft=100;
			winTop=50;
			winHeightBrowserShell=50;
			break;
		case "zpa":
			winWidth=830,winHeight=610,blnlongcall=true;
			winHeightBrowserShell=50;
			break;
		case "sweeps":
			winWidth=550,winHeight=500,blnlongcall=true;
			winHeightBrowserShell=50;
			break;
		default:
			objWindow=window.open(strURL);
			return;
	}

	//center window
	if (winWidth>0 && winHeight>0 && winLeft==0 && winTop==0)
	{
		winLeft=(screen.width - winWidth)/2;			
		winTop=(screen.height - winHeight - winHeightBrowserShell)/2;
	}

	if(blnlongcall==true)
		objWindow=window.open(strURL,winName,'width='+winWidth+',height='+winHeight+',left=' + winLeft + ',top=' + winTop + ',scrollbars=' + scrollbars + ',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no');
	else
		objWindow=window.open(strURL,winName,'scrollbars,resizable,width='+winWidth+',height='+winHeight+',left=' + winLeft + ',top=' + winTop);
	//This will focus on the window, if it is already opened.
	if(objWindow!=null) objWindow.focus();
}

function TestForOpener()
{

}

function ManageWindows(strURL, useWinParent, closeWinCurrent)
{
	if(useWinParent=="true" || useWinParent==true)
	{
		var navDone=false;
		if(typeof(window.opener)=="object")
		{
			try
			{
			  window.opener.TestForOpener();
			  window.opener.location.href=strURL;
			  window.opener.focus();
			  navDone=true;
			}
			catch(e)
			{
			  // .TestForOpener failed so must launch new window	
			}
		}
		if(!navDone)
		{
			OpenWindow(strURL, "", "", "", "");
		}
	}
	else
	{
		this.location.href=strURL;
	}


	if(closeWinCurrent=="true" || closeWinCurrent==true)
	{
		if(typeof(g_zpa_CMS_Editing) != "undefined" && g_zpa_CMS_Editing)
		{
			var message = "This page wants to close itself.  In production this will automatically close.  Allow the window to close?";
			if(confirm(message))
				window.close;
		}
		else
			window.close();
	}
}
