var siteZones = {
	"" : 
	{   
				"Belgique" : {"lang" : "fr", "country" : "be", "zone" :"belgium"},
				"België" : {"lang" : "nl", "country" : "be", "zone" :"belgium"},
				"Deutschland" : {"lang" : "de", "country" : "de", "zone" :"deutschland"},
				"España": {"lang" : "es", "country" : "es", "zone" :"espana"},
				"France" : {"lang" : "fr", "country" : "fr", "zone" :"france"},
				"Italia" : {"lang" : "it", "country" : "it", "zone" :"italia"}, 		 
				"Nederland" : {"lang" : "nl", "country" : "nl", "zone" :"nederland"},
				"Österreich" : {"lang" : "de", "country" : "at", "zone" :"oesterreich"},
				"Portugal" : {"lang" : "pt", "country" : "pt", "zone" :"portugal"},
				"Suisse" : {"lang" : "fr", "country" : "ch", "zone" :"switzerland"},
				"Schweiz" : {"lang" : "de", "country" : "ch", "zone" :"switzerland"},		
				"United Kingdom" : {"lang" : "gb", "country" : "gb", "zone" :"united-kingdom"},
				"Brasil" : {"lang" : "pt-br", "country" : "br", "zone" :"brasil"},
				"Asia" : {"lang" : "gb", "country" : "th", "zone" :"asia"},
				"Australia" : {"lang" : "gb", "country" : "au", "zone" :"australia"},
				"New Zealand & Fiji" : {"lang" : "gb", "country" : "nz", "zone" :"new-zealand-fidji"},
				"Africa" : {"lang" : "gb", "country" : "dz" , "zone" :"africa"},
				"Afrique" : {"lang" : "fr", "country" : "dz", "zone" :"africa"},
				"Other countries" : {"lang" : "gb", "country" : "", "zone" :"home"},
				"Autres pays" : {"lang" : "fr", "country" : "", "zone" :"home"},
				"Sonstige Länder" : {"lang" : "de", "country" : "", "zone" :"home"},
				"Outros países" : {"lang" : "pt", "country" : "", "zone" :"home"},
				"Andere landen" : {"lang" : "nl", "country" : "", "zone" :"home"},
				"Altri paesi" : {"lang" : "it", "country" : "", "zone" :"home"},
				"Otros países" : {"lang" : "es", "country" : "", "zone" :"home"}
	}
};

 function getCookieCountry(){
	var i,x,y,ARRcookies=document.cookie.split(";");
	for (i=0;i<ARRcookies.length;i++)
	{
	  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
	  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
	  x=x.replace(/^\s+|\s+$/g,"");
	  if (x=='userBrowsingZoneLocalization')
		{
		return unescape(y);
		}
	  }
}
function createSiteZonesOptions(selectId){
	if(document.getElementById(selectId) && siteZones){
		var zone ='home';
		var currentLang ='';
		var langContent = document.getElementById('languages');
		var countrySelected = getCookieCountry();
		if (countrySelected=="asia-china-japan-india-singapore-malaysia-indonesia") countrySelected="asia"; 
		if (countrySelected != undefined) { var zone = countrySelected; }
		var url = window.location.pathname;
		var currentLang = url.substring(1,url.indexOf("/",1));
		 
		for(var zones in siteZones){
			var oOptgroup = document.createElement('optgroup');
			oOptgroup.label = zones;
			if(siteZones[zones]){
				for(var countryName in siteZones[zones]){
					if(siteZones[zones][countryName]){
						var oOption = document.createElement('option'); 
						oOption.setAttribute("class", siteZones[zones][countryName].zone)
						if(siteZones[zones][countryName].lang == currentLang && siteZones[zones][countryName].zone == zone){
							oOption.setAttribute("selected","selected");
						} 
						oOption.innerHTML = countryName
						oOption.value = "/geo/setZone.jsp?lang="+siteZones[zones][countryName].lang+"&country="+siteZones[zones][countryName].country;
						oOptgroup.appendChild(oOption);
					}
				}
				document.getElementById(selectId).appendChild(oOptgroup);
			}
			langContent.setAttribute("class", zone);
			langContent.setAttribute("className", zone); //ie
		}
	}
}   

