//<script language="javascript" %>

function ChangePage( sPage, sFrameName, sQueryString )
{
	if ( typeof( sFrameName ) == "undefined" )
		sFrameName = "frameMain";				
			
	/*
	if( typeof( sQueryString ) != "undefined" )
	{
		if( sPage.indexOf("?") != -1 )
		{
			var aPage = sPage.split("?");
			sPage = aPage[0] + sQueryString + "&" + aPage[1];
		}
		else
		{		
			sPage += sQueryString;		
		}
	}
	*/
	
	if( sUserLoginId != 0 )
	{
		if( sPage.indexOf("?") == -1 )
			sPage += "?";
		else
			sPage += "&";	
			
		sPage += "reference=" + sUserLoginId;
	}

	if( typeof( sQueryString ) != "undefined" )
	{
		if( sPage.indexOf("?") != -1 )
			sPage += "&" + sQueryString;
		else
			sPage += "?" + sQueryString;		
	}

	if( typeof( eval( "window.parent." + sFrameName ) ) == "undefined" )
	{				
		document.forms.frmNavigation.action = sPage;
		document.forms.frmNavigation.submit();
	}
	else
	{		
		eval("window.parent." + sFrameName + ".document.location.href = \"" + sPage + "\"");
	}
	
}

//
// Handle page cancel functionality in webs pages
//
function PageCancel(ReturnUrl)
{
	if( ReturnUrl != "" )
	{
		document.location.href = ReturnUrl;
	}
	else
	{
		// Refresh the page
		document.location.href 	= document.location.href;
	}
}
	
function WinPopup(winUrl,winName,winWidth,winHeight, winFeatures) {
	
	var clientWidth = screen.width;
	var clientHeight = screen.height;
	var leftPos = (clientWidth - winWidth)/2;
	var topPos = (clientHeight - winHeight)/2;		
	if(leftPos < 0) {
		leftPos = 0;
	}
	if(topPos < 0) {
		topPos = 0;
	}
	if(winFeatures == null) {
		winFeatures = "left=" + leftPos + ",top=" + topPos + ",width=" + winWidth +",height=" + winHeight +",status=1,address=0,location=0,scrollbars=1,resizable=1";
	} else {
		winFeatures = "left=" + leftPos + ",top=" + topPos + ",width=" + winWidth +",height=" + winHeight +"," + winFeatures;
	}	
	
	window.open( winUrl, winName, winFeatures );
	
	
}

function WinPopupObj(winUrl,winName,winWidth,winHeight, winFeatures) {
	var clientWidth = screen.width;
	var clientHeight = screen.height;
	var leftPos = (clientWidth - winWidth)/2;
	var topPos = (clientHeight - winHeight)/2;		
	if(leftPos < 0) {
		leftPos = 0;
	}
	if(topPos < 0) {
		topPos = 0;
	}
	if(winFeatures == null) {
		winFeatures = "left=" + leftPos + ",top=" + topPos + ",width=" + winWidth +",height=" + winHeight +",status=yes,address=no,location=no,scrollbars=yes,resizable=yes";
	} else {
		winFeatures = "left=" + leftPos + ",top=" + topPos + ",width=" + winWidth +",height=" + winHeight +"," + winFeatures;
	}	
	
	return window.open(winUrl,winName,winFeatures);
	
}
//</script>