var pageURL = "" + window.location.href;

function rollOn(name, on){

		pict=document.images[name];
		if (pict == null){
			pict = document.getElementById(name);
		}
		if (on){
			var add = "_on";
		}
		else {
			var add = "";
		}
		base = "/MCPE/_Global/img/nav/";
		newSrc = base+ name + add + ".gif";
		pict.src= newSrc;
	
}


function gotoLanguageURL(strLang) {
	var engfound, frefound, charFound, poundFound;
	var myurl = "" + window.top.location.href;
	var lookforEng = "L=E";
	var lookforFre = "L=F";
	var appendChar = "?";
	var anchorText = "";
	var querystring = "";
	var urlLength = myurl.length
	var re;
	

	poundFound = myurl.indexOf("#");
	engfound = myurl.indexOf(lookforEng);
	frefound = myurl.indexOf(lookforFre);
	charfound = myurl.indexOf(appendChar);
	
	//If there's an L=Anything, that's the easiest, just switch the language and get out
	if (engfound > 0)
	{
		re = new RegExp ('L=E', 'gi');
		myurl = myurl.replace(re, lookforFre);
	}
	else
	if (frefound > 0) 
	{
		re = new RegExp ('L=F', 'gi');
		myurl = myurl.replace(re, lookforEng);
	}
	else //L=Whatever doesn't exist. Check for pounds, cuz they have to go last
	if (poundFound > 0)
	{
		re = newRegExp ('#');
		
		// If there is a ? then we can insert a &L otherwise we insert ?L
		if (charfound > 0)
		{
			if (strLang == "Eng")
				myurl = myurl.replace(re, '&L=F#');
			else
				myurl = myurl.replace(re, '&L=E#');
		}
		else
		{
			if (strLang == "Eng")
				myurl = myurl.replace(re, '?L=F#');
			else
				myurl = myurl.replace(re, '?L=E#');
		}
	}
	else // No #, no L=, so lets just append it
	{
		// if there's an ? then append &L= otherwise append ?L=
		if (charfound > 0)
		{
			if (strLang == "Eng")
				myurl = myurl + '&L=F';
			else
				myurl = myurl + '&L=E';
		}
		else
		{
			if (strLang == "Eng")
				myurl = myurl + '?L=F';
			else
				myurl = myurl + '?L=E';
		}
	}

	
	location.href = myurl;
}
