function openRegionBox(regionboxname) {
    closeRegionBox();
    
	setVisibility(getLayerRef(regionboxname), true); 
}

function closeRegionBox() {
	setVisibility(getLayerRef('regionboxnorthamerica'), false); 
	setVisibility(getLayerRef('regionboxlatinamerica'), false); 
	setVisibility(getLayerRef('regionboxeurope'), false); 
	setVisibility(getLayerRef('regionboxafrica'), false); 
	setVisibility(getLayerRef('regionboxasiaoceania'), false);
}		

var choise = "false";

function checkBox()
{
	if (choise == "true")
		choise = "false";
	else
		choise = "true";
}

function jumpTo(country)
{
	var countryLink = document.getElementById(country);
	if (countryLink)
	{
		var countryHref = countryLink.href;
		if (choise == "true")
		{
			if (countryHref.indexOf('?')>=0)
			{
				countryHref += "&Choise="+ choise;
			}
			else
			{
				countryHref += "?Choise="+ choise;
			}
			
		}
			
		document.location.href = countryHref;
	}
}
function jumpTo2(country)
{
	var countryLink = document.getElementById(country);
	if (countryLink)
	{
		if (choise == "true")
		{
			return "&Choise="+ choise;
		}
		else
			return "";
	}
}
function setCookie(country)
{
//after url rewriting was introduced the viewsplashpage-start pipeline 
//wasn't called anymore, when clicking a country link on splashpage.
//due to this  the cookie will be set per javascript at the onclick event of the country links
	//if checkbox 'remember my choice' is set
	if (choise == "true")
	{
		var currentDate=new Date();
		var expirationDate=new Date( currentDate.getFullYear()+1,currentDate.getMonth(),currentDate.getDate());		
		
		var cookieContent='country='+escape(country)+'; expires='+expirationDate.toGMTString()+';';
		document.cookie=cookieContent;
	}
}

function setOldSessionID(sessionid) {
	var currentDate=new Date();
	var expirationDate=new Date( currentDate.getFullYear()+1,currentDate.getMonth(),currentDate.getDate());			
	var cookieContent='oldsid='+sessionid+'; expires='+expirationDate.toGMTString()+';path=/';
	document.cookie=cookieContent;
}

function detectCountry() {
	if (document.cookie) {
		a = document.cookie;
		if (a.lastIndexOf('country') != -1) {
			if(a.substring(a.lastIndexOf('country')).indexOf(';') != -1) {
				cookiewert = a.substring(a.lastIndexOf('country')+8,a.substring(a.lastIndexOf('country')).indexOf(';')+a.lastIndexOf('country'));
			}
			else {
				cookiewert = a.substr(a.lastIndexOf('country')+8,a.length);
			}
			return cookiewert;
		}
		else {
			return '';
		}
	}
}

function getOldSessionID() {
	if (document.cookie) {
		a = document.cookie;
		if (a.lastIndexOf('oldsid') != -1) {
			if(a.substring(a.lastIndexOf('oldsid')).indexOf(';') != -1) {
				cookiewert = a.substring(a.lastIndexOf('oldsid')+7,a.substring(a.lastIndexOf('oldsid')).indexOf(';')+a.lastIndexOf('oldsid'));
			}
			else {
				cookiewert = a.substr(a.lastIndexOf('oldsid')+7,a.length);
			}
			return cookiewert;
		}
		else {
			return '';
		}
	}
}

function getSessionID() {
	if (document.cookie) {
		a = document.cookie;
		if (a.lastIndexOf('sid') != -1) {
			if(a.substring(a.lastIndexOf('sid')).indexOf(';') != -1) {
				cookiewert = a.substring(a.lastIndexOf('sid')+4,a.substring(a.lastIndexOf('sid')).indexOf(';')+a.lastIndexOf('sid'));
			}
			else {
				cookiewert = a.substr(a.lastIndexOf('sid')+4,a.length);
			}
			return cookiewert;
		}
		else {
			return '';
		}
	}
}

function getRefHost(referrer) {
	var ref = ""+referrer;
	if (ref.indexOf('https') != -1) {
		startindex = 8;
		if (ref.indexOf(':') != -1) {
			endindex = ref.replace('https://','').indexOf(':');
		} else {
			endindex = ref.replace('https://','').indexOf('/');
		}
		endindex+=8;
	} else {
		startindex = 7;
		endindex = ref.replace('http://','').indexOf('/');
		endindex+=7;
	}
	var ret = ref.substring(startindex,endindex);
	return ret;
}
function getCurrHost(currURL) {
	var curr = ""+currURL;
	if (curr.indexOf('https') != -1) {
		startindex = 8;
		if (curr.indexOf(':',startindex) != -1) {
			endindex = curr.replace('https://','').indexOf(':');
		} else {
			endindex = curr.replace('https://','').indexOf('/');
		}
		endindex+=8;
	} else {
		startindex = 7;
		if (curr.indexOf(':',startindex) != -1) {
			endindex = curr.replace('http://','').indexOf(':');
		} else {
			endindex = curr.replace('http://','').indexOf('/');
		}
		endindex+=7;
	}
	var ret = curr.substring(startindex,endindex);
	return ret;
}