//PUBLIC VARIABLES: Need tweaking
rootFolderLevel = 2; //node level of the main INDEX file. ex: index.html is in the root then = 0
languages = ["en","fr","de","pt"]; //The 1st language in the array is the default. At least 1
countries = ["United Kingdom","France","Germany","Portugal"]; // Names of the respective countries
//PUBLIC ROUTINE: Works as HEAD and FOOT on the Body Tag
function initialScripts(){
	
}
function finalScripts(){
	
}
//PRIVATE ROUTINE
function autoSelectLanguage(){
	if (navigator.userAgent.indexOf('MSIE') != -1){
		curLang = navigator.userLanguage;
	}else{
		curLang = navigator.language.split('-');
		curLang = curLang[0];
	}
	if(location.hash.indexOf("stop")==-1){
		if(languages.toString().indexOf(curLang)!=-1){
			return(document.location = curLang);
		}else{
			return(document.location = languages[0]);
		}
	}
}
function changeLanguage(curLang,subfolderLevel){
	subfolderLevel == null ? subfolderLevel = 1 : null;
	if(subfolderLevel == 0){
		document.location = curLang;
	}
	if(subfolderLevel > 0){
		urlArray = location.toString();
		urlArray = urlArray.split('/');
		if(urlArray[urlArray.length-(Number(subfolderLevel)+1)] != curLang){
			urlArray[urlArray.length-(Number(subfolderLevel)+1)] = curLang;
			newUrl = "";
			for (i=1;i<urlArray.length;i++){
				newUrl = newUrl+"/"+urlArray[i];
			}
			newUrl = urlArray[0]+newUrl;
			document.location = newUrl;
		}
	}
}
function createFlagOrbs(){
	subfolderLevel = location.toString();
	subfolderLevel = subfolderLevel.split('/');
	subfolderLevel = subfolderLevel.length-(4+rootFolderLevel);
	relativePath = "";
	for(i=0;i<subfolderLevel;i++){
		relativePath = relativePath+"../";		
	}
	curLang = location.toString();
	curLang = curLang.split('/');
	curLang = curLang[curLang.length-(Number(subfolderLevel)+1)];
	for (i=0;i<languages.length;i++){
		if (languages[i] != curLang){
			document.write('<img src="'+relativePath+'flagOrbsIcons/'+countries[i].replace(" ","-")+'.png" title="'+countries[i]+'" alt="'+countries[i]+'" border="0" id="'+languages[i]+'" style="cursor:pointer;" onclick="changeLanguage(\''+languages[i]+'\',\''+subfolderLevel+'\')">&nbsp;');
		}
	}
}