//-------------------------- Private utilities --------------------------

function GetUrl() 
{ 
	return "?" ;	
}

function NavToBookmark(bookmark) {
	if ((bookmark!=null) && (bookmark.length>0))
		document.location = "#" + bookmark;
}


function GetNavUrlVars(path,lang,optVars) {	
	var params="";
	if ((path!=null) && (path.length>0))
		params+= "t="+path;	
	if ((lang!=null) && (lang.length>0)) 		
		params+= "&lang="+lang;
	if ((optVars!=null) && (optVars.length>0))		
		params+= "&" + optVars;		
	return params;	
}

//----------------Javascripts used by the framework for navigation---------

// The following javascript function is generated on each hit to hold the
// dynamic state. Things such as the current language, previous page hit,
// the current runtime version, are automatically generated in the 
// querystring. 
//
// Params: key -> the target key
//				 openMode -> can be 'SAME_WINDOW' or 'NEW_WINDOW'
//				 specificQueryString -> a querystring to hold case specific 
//																additional parameters in the querystring.
//																Format: "param1=Bidouille&param2=Boudille".
//																This querystring will be appended to the
//																standard generated querystring that holds
//																the framework standard querystring.
//
// 
// function NavTo(key,openMode,specificQueryString)
//


function LowLevelNavTo(path, openMode, lang, optVars, windowSizes, targetAnchor) {	
	var params = GetNavUrlVars(path,lang,optVars);
	var target = "";
	var defaultNewWindow = "width=800,height=600,top=1,left=1,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";
	var defaultOptions= ",top=1,left=1,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";	
	
	if ((windowSizes!=null) && (windowSizes.length>0))	newWindowVars = windowSizes + defaultOptions;
	else newWindowVars=defaultNewWindow;
	
	if ((targetAnchor!=null) && (targetAnchor.length>0))	
	target = "#"+targetAnchor;	
	  
	if (openMode == 'NEW_WINDOW')
	{
		window.open(GetUrl() + params + target, '_blank' , newWindowVars);
	}
	else
	{		
		document.location = GetUrl() + params + target;
	}
}

//----------------Javascripts that can be used within the site content-----

// The following javascript function is used for links in site content pages.
// It is based on the LowLevelNavTo function, the only difference is that the auth parameter
// is not a member anymore of the optVars argument, the authoring state is retrieved by the
// script itself.
// 

function ContentNavTo(path, openMode, lang, optVars, windowSizes, targetAnchor)
{
	var params = GetNavUrlVars(path,lang,optVars);
	var urlParams = window.location.search.substring(1);
	var target = "";
	var defaultNewWindow = "width=800,height=600,top=1,left=1,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";
	var  defaultOptions= ",top=1,left=1,toolbar=1,location=1,directories=1,status=1,menubar=1,scrollbars=1,resizable=1";	
	
	if(urlParams.length > 0 && urlParams.search("auth=") > 0)
	params += "&auth="+urlParams.charAt(urlParams.search("auth=")+5);
	else params += "&auth=0";
	
	if ((windowSizes!=null) && (windowSizes.length>0))	newWindowVars = windowSizes + defaultOptions;
	else newWindowVars=defaultNewWindow;
	
	if ((targetAnchor!=null) && (targetAnchor.length>0))	
	target = "#"+targetAnchor;	
	  
	if (openMode == 'NEW_WINDOW')
	{
		window.open(GetUrl() + params + target, '_blank' , newWindowVars);
	}
	else
	{		
		document.location = GetUrl() + params + target;
	}
}
