	// *******************************************************************************************************************
	// détection de la langue
	// *******************************************************************************************************************
	var lng = 'en';
	if(document.location.href.toLowerCase().indexOf('/fr/') > 0) lng = 'fr'; else lng = 'en';
	
	var isloadGoogle = false;
	// var tagNedstats = "http://fr.sitestat.com/renault-group/renault-com/s?renaultcom." + lng + ".geolocalisation";
	var GoogleCodeIso = "";
	var CookieCodeIso = "";
	var timerGoogle = 100;
	var timerGoogleMax = 4000;
	var timerGoogleTotal = 0;
	var timerGoogleRatio = 1.5;
	
	$(function()
	{
		includeGoogleAPI();
		loadMasterVotrePays();
	});
	function setTimeoutGoogle(t)
	{
		if(isloadGoogle) return;
		setTimeout("loadMasterVotrePays();", t);
	}
	function continueTraitement()
	{
	    if(CookieCodeIso != "")
		{
			loadMasterVotrePaysAXD(CookieCodeIso);
		}
		else if(timerGoogleTotal < timerGoogleMax)
		{
			timerGoogle = timerGoogle * timerGoogleRatio;
			timerGoogleTotal += timerGoogle;
			setTimeoutGoogle(timerGoogle);
		}
		else
		{
			loadMasterVotrePaysAXD(GoogleCodeIso);
		}
	}
	function loadMasterVotrePays()
	{
		if(!$("#ulMasterVotrePays").length) return;
		if(isloadGoogle) return;
		
		if(typeof(google) != 'undefined')
		{
			try
			{
				if(google.loader.ClientLocation && google.loader.ClientLocation.address && google.loader.ClientLocation.address.country_code)
					GoogleCodeIso = google.loader.ClientLocation.address.country_code;
				loadMasterVotrePaysAXD(GoogleCodeIso);
			}
			catch(e) 
			{
			    if(typeof(google.loader) != 'undefined')
			    {
			        if(google.loader.ClientLocation && google.loader.ClientLocation.address && google.loader.ClientLocation.address.country_code)
					    GoogleCodeIso = google.loader.ClientLocation.address.country_code;
				    loadMasterVotrePaysAXD(GoogleCodeIso);
			    }
			    else 
		        {
			        continueTraitement();
		        }
			}
		}
		else 
		{
			continueTraitement();
		}
	}

	function loadMasterVotrePaysAXD(curCodeIso)
	{
		if(!$("#ulMasterVotrePays").length) return;
		if(isloadGoogle) return;
		
		if(curCodeIso == "undefined") curCodeIso = "";
		
		$.post('/' + lng + '/MasterVotrePays.axd', { 'CodeIso' : curCodeIso }, function(data) 
		{ 
			if(isloadGoogle) return;
			isloadGoogle = true;
			if(data)
			{
				$("#ulMasterVotrePays").html(data);
				
				if(CookieCodeIso != "")
					var CookieStatut = "ok";
				/*
				else 
				if(GoogleCodeIso != "")
					sitestat(tagNedstats + ".GoogleAPI");
				else
					sitestat(tagNedstats + ".IP");
				*/
			}
			else { /*sitestat(tagNedstats + ".Unknown"); */ }
		});
	}
	function includeJS(srcFile)
	{
		$("body").append("<s"+"cript type=\"text/javascript\" src=\"" + srcFile + "\"></s"+"cript>");
	}
	function includeGoogleAPI()
	{
		if(!$("#ulMasterVotrePays").length) return;
		
		CookieCodeIso = readCookie("MVPCodeIso");
		if(!CookieCodeIso){includeJS("http://www.google.com/jsapi");}
		else{var CookieStatut = "ok";}
	}
	function readCookie(nom) 
	{
		var nameEQ = nom + "=";
		var ca = document.cookie.split(';');
		for(var i=0;i < ca.length;i++) {
			var c = ca[i];
			while (c.charAt(0)==' ') c = c.substring(1,c.length);
			if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
		}
		return null;
	}
