

var dateXml = new Date();
var strDateXml = "";
var strDateXml= strDateXml + dateXml.getYear();
var strDateXml= strDateXml + "_" + dateXml.getMonth();
var strDateXml= strDateXml + "_" + dateXml.getDate();
var strDateXml= strDateXml + "_" + dateXml.getHours();
var strDateXml= strDateXml + "_" + dateXml.getMinutes();
var strDateXml= strDateXml + "_" + dateXml.getSeconds();

var initValueRecherche = 'Rechercher';

var version_min = 8;
var version = deconcept.SWFObjectUtil.getPlayerVersion();
var enableFlash = true;

var divParentIdFlash = 'container';
var divIdFlash = 'flash-home';

var pathFlash = '/securite-routiere/Images/20100324_1_main.swf';
var pathIncFooter = '/securite-routiere/inc/footer.xml?d=' + strDateXml;
var pathIncHeader = '/securite-routiere/inc/header.xml?d=' + strDateXml;
var pathIncActus = '/securite-routiere/inc/actushome.xml.aspx?d=' + strDateXml;
var pathIncMenu = '/securite-routiere/inc/menu.xml?d=' + strDateXml;
var pathIncContent = '/securite-routiere/inc/contenthome.xml?d=' + strDateXml;

var minWidth = 774;
//var interWidth = 975;
var minHeight = 590;

$(function()
{
	// Mettre l'argument : ....?verifFlash=false   pour afficher la page d'accueil sans le flash
	var parametre=PrmUrl();
     	if(parametre['verifFlash'] == 'false')
     	{
     		enableFlash = false;
     	}

	if(version["major"] > version_min && $('#'+divIdFlash).length && enableFlash)
	{
		var so = new SWFObject(pathFlash , 'RenaultSPT', '100%', '100%', version_min, '#FFFFFF');
		so.addParam('quality','high');
		so.addParam('wmode','transparent');
		so.addParam('allowScriptAccess','sameDomain');
		so.addVariable("langue", "fr");
		so.addVariable('footer', pathIncFooter);
		so.addVariable('header',pathIncHeader);
		so.addVariable('actus',pathIncActus);
		so.addVariable('menu',pathIncContent);
		so.addVariable('homepage',pathIncMenu);
		so.write(divIdFlash);

		// #######################################################
		// ########### Applique les css utilisé sur la home flash uniquement
		// ########### Récupéré sur l'ancienne home flash
		// hide from ie on mac
		$('html').css('height','100%');
		$('#'+divIdFlash).css('height','100%');
		// end hide
		$('body').css({'height':'100%','margin':'0px','padding':'0px','background-color':'#FFFFFF'});
		$('#'+divParentIdFlash).css({'width':'100%','height':'590px'});
		// #######################################################
		
		window.onresize = checkHomepageSize;
		checkHomepageSize();
		
	}
	else
	{
		initHome();

	}
	sitestat('http://fr.sitestat.com/renault-group/securite/s?renaultsptportail.fr.index');
});

var enableFlashHeight = false;
function checkHomepageSize()
{
	var height = document.getElementById(divParentIdFlash).offsetHeight;
	var width = document.getElementById(divParentIdFlash).offsetWidth;
	// if(width<interWidth) minHeight = 860;
	// else minHeight = 580;
	if(width>minWidth) { document.getElementById(divIdFlash).style.width = "100%"; }
	else { document.getElementById(divIdFlash).style.width = minWidth+"px"; }
	if(!enableFlashHeight)
	{
		if(height>minHeight) { document.getElementById(divIdFlash).style.height = "100%";	}
		else { document.getElementById(divIdFlash).style.height = minHeight+"px";	}
	}
	if(height<minHeight)
		document.getElementById(divIdFlash).style.height = minHeight+"px";
}
function newFlashHeight(newHeight) 
{
	if(jQuery.url.param("enable_height") == 'false' || !enableFlashHeight) return;
	document.getElementById(divIdFlash).style.height = parseInt(newHeight)+"px";	
	if(jQuery.url.param("confirm_height") == 'true')
	{
		if(!confirm("newFlashHeight : " + parseInt(newHeight) + "px\n\n\tContinue ?")) enableFlashHeight = false;
	}
}

function initHome()
{
	$("#rechercher").click(function(){ 
		if(this.value=='Rechercher'){ this.value = '';} 
	});
	$("#rechercher").blur(function(){  
		if(this.value=='') { this.value = initValueRecherche;} 
		else { initValueRecherche = this.value; } 
	});
	$("#formRechercher").submit(function(){ 
		var obj = document.getElementById('rechercher')
		if(obj){ if(obj.value=='Rechercher'){ return false;} }
	});
	$(".centre .middle .milieu p").hover(function(){
		$(".centre .middle .milieu p").css('text-decoration','underline');
	},function(){
		$(".centre .middle .milieu p").css('text-decoration','none');
	});
}

function selection_pays(pays)
{
	if(pays.options[pays.options.selectedIndex].value!="")
	{
		window.open(pays.options[pays.options.selectedIndex].value, 'popup', '');
		pays.options.selectedIndex = 0;
	}
}