
var continueAnim=false;

/* FONCTION DE DÉFINITION DES CALQUES */
function NameDiv(id){
	if(document.all){ doc = document.all[id]; }
	if(document.getElementById){ doc = document.getElementById(id);}
	return doc;
}
function CheckMove(obj, dec){
	continueAnim=true;
	var nItems = 12;
	var	x = $(obj).style.left;
	x = (x!="") ? parseInt(x) : 0;
	
	if(x/dec==Math.round(x/dec) && ( x >= (dec*(nItems-4)) || (x<0 && dec >0) ) ){ 
		new Effect.Move (obj,{ 
			x: dec, 
			y: 0, 
			mode: 'relative', 
			afterFinish:function(){
				if(continueAnim==true)
					CheckMove(obj, dec)
			}
			
		}); 
	}	
}

//CheckMove('List', 221);

//IMPRESSION
function printPage(){
	split_location = document.location.href.split("?");
	if(split_location.length>1) arg=split_location[1]; else arg="0=0";
	window.open(split_location[0]+"?"+arg+"&print=yes","print","width=636,height=500,scrollbars=yes");
}

function printDealer(){
	split_location = document.location.href.split("?");
	if(split_location.length>1) arg=split_location[1]; else arg="0=0";
	window.open(split_location[0]+"?"+arg+"&print=yes&step=2000&start=0","print","width=636,height=500,scrollbars=yes");
}


//REDIRECT
function redirect(url){
	document.location.replace(url);
}

//POPUP
function launchwin(url,name,feat){
	window.open(url,name,feat);
}

//FENETRE ECATALOGUE
function openToc(lien) {
	var parameter = "toolbar=no,location=no,menubar=no,resizable=yes";
	Fenster1 = window.open(lien,"Fenster",parameter);
}

//FENETRE EXTRANET
function openExtranet(lien) {
	var str = "left=0,screenX=0,top=0,screenY=0";

	if (window.screen) {
	  var ah = screen.availHeight - 30;
	  var aw = screen.availWidth - 10;
	  str += ",height=" + ah;
	  str += ",innerHeight=" + ah;
	  str += ",width=" + aw;
	  str += ",innerWidth=" + aw;
	} else {
	  str += ",resizable";
	} 
	str += ",scrollbars=yes,location=yes,toolbar=yes";
	site = window.open(lien, 'extranet', str);
	site.focus();
}

function validValeoShopForm() {
	var parameter = "toolbar=no,location=no,menubar=no,resizable=yes";
	Fenster1 = window.open("about:blank","Fenster",parameter);
	document.valeoShopForm.submit();
}

//GEOGRAPHIC DETECTION
//http://www.w3.org/WAI/ER/IG/ert/iso639.htm
var langDefault = 0;
var langCodes = new Array("en","fr","es","it","de");
var countryCodes = new Array("england","france","spain","italy","deutschland");
var countryAlias = new Array("England","France","Spain","Italy","Deutschland");

function writeQuicklocation(){
	var languageinfo=navigator.language? navigator.language : navigator.userLanguage;
	for (i=0;i<langCodes.length-1;i++){
		if(languageinfo.substr(0,2)==langCodes[i]){
			html = "<a href='html/" + countryCodes[i] + "/" + langCodes[i] + "/'>" + countryAlias[i] + " (" + langCodes[i].toUpperCase() + ")</a>";
			document.write(html);
			return;
		}
	}
	html = "<a href='html/" + countryCodes[langDefault] + "/" + langCodes[langDefault] + "/'>" + countryAlias[langDefault] + " (" + langCodes[langDefault].toUpperCase() + ")</a>";
	document.write(html);
}

function redirectLangue(langue){
	var languageinfo=navigator.language? navigator.language : navigator.userLanguage;
	var browserLangue = languageinfo.substr(0,2);
	if(browserLangue!=langue){
		document.location.replace("index.php?lang="+browserLangue);
		return;
	}
}

//STATS
function recordStat(page,offsetpath,langue,pays){
	var date = new Date();
	var referrer = escape(document.referrer);
	var current = escape(document.location);
	var tagHtml = "<img width='1' height='1' src='" + offsetpath + "tracer.php?p=" + page + "&h=" + date.getHours() + "&m=" + date.getMinutes() + "&s=" + date.getSeconds() + "&langue=" + langue + "&pays=" + pays + "&r=" + referrer +"&c=" + current + "'>";
	document.write(tagHtml);
}

// SOUS NAVIGATION

function RestoreSubnav(activesubnav){	
	
	if(activesubnav!="") {
			
		document.getElementById("subnav").style.display="none";
		for(i=0; i<subnavs; i++){
			if(i!=activesubnav){
				var lay = "subnav"+i;
				
				if (document.all){
					var pathlay = document.all[lay];
					//window.alert(111);
				} else if (document.getElementById){
					var pathlay = document.getElementById(lay);
					//window.alert(222);
				}
				pathlay.style.display="none";
				//window.alert(pathlay);
			} else {
				var lay = "subnav"+activesubnav;
				
				if (document.all){
					var pathlay = document.all[lay];
					//window.alert(111);
				} else if (document.getElementById){
					var pathlay = document.getElementById(lay);
					//window.alert(222);
				}
				pathlay.style.display="block";
				//window.alert(pathlay);
				
			}
		}
		
	}else{
		document.getElementById("subnav").style.display="block";
		for(i=0; i<subnavs; i++){
			
				var lay = "subnav"+i;
				
				if (document.all){
					var pathlay = document.all[lay];
					//window.alert(111);
				} else if (document.getElementById){
					var pathlay = document.getElementById(lay);
					//window.alert(222);
				}
				pathlay.style.display="none";
				//window.alert(pathlay);
			
		}
		
	}
}
var test;
function StartTO(activesubnav){
	test=window.setTimeout("RestoreSubnav(activesubnav)",2000);	
}

function KillTO(){
	window.clearTimeout(test);
}

function ShowSubnav(){
	// On masque les sous nav qui ne sont pas de la rubrique en cours

	if(activesubnav!="") {
			
		document.getElementById("subnav").style.display="none";
		for(i=0; i<subnavs; i++){
			if(i==activesubnav){
				var lay = "subnav"+i;
				
				if (document.all){
					var pathlay = document.all[lay];
					//window.alert(111);
				} else if (document.getElementById){
					var pathlay = document.getElementById(lay);
					//window.alert(222);
				}
				pathlay.style.display="block";
				//window.alert(pathlay);
			} 
		}
		
	}
}

function SwapSubnav(swapsubnav){
	// On masque les sous nav qui ne sont pas de la rubrique en cours
	document.getElementById("subnav").style.display="none";
	for(i=0; i<subnavs; i++){
		if(i==swapsubnav){
			var lay = "subnav"+i;
			if (document.all){
				var pathlay = document.all[lay];
				//window.alert(111);
			} else if (document.getElementById){
				var pathlay = document.getElementById(lay);
				//window.alert(222);
			}
			pathlay.style.display="block";
			//window.alert(pathlay);
		} else {
			var lay = "subnav"+i;
			if (document.all){
				var pathlay = document.all[lay];
				//window.alert(111);
			} else if (document.getElementById){
				var pathlay = document.getElementById(lay);
				//window.alert(222);
			}
			pathlay.style.display="none";
			//window.alert(pathlay);
		}
	}
}

function openPrevisu(lien,name,width,height) {
	
    var newWindow = window.open(lien, name, 
        "location=no, directories=no, fullscreen=no, menubar=no, status=no, toolbar=no, width=" + width + ", height=" + height + ", scrollbars=no");
    newWindow.document.writeln("<html>");
    newWindow.document.writeln("<body style='margin: 0 0 0 0;'>");
    newWindow.document.writeln("<a href='javascript:window.close();'>");
    newWindow.document.writeln("<img src='" + lien + "' border=0 id='bigImage'/>");
    newWindow.document.writeln("</a>");
    newWindow.document.writeln("</body></html>");
    newWindow.document.close();
}








  
/* FONCTION DE DÉFINITION DES CALQUES */
function NameDiv(id){
	if(document.all){ doc = document.all[id]; }
	if(document.getElementById){ doc = document.getElementById(id); }
	if(document.layers){ doc = document[id]; }
	//alert(doc);
	return doc;
}

/* FONCTION D'AFFICHAGE/MASQUAGE DES ELEMENTS */
// id : id de l'élement
// prop : propriété du display (none, block, inline)
var actualLayer;
function SetObjDisplay(id, prop){
	NameDiv(id);
	if(document.getElementById || document.all){ doc.style.display=prop; }
	if(document.layers){ doc.display=prop; }
	
}

/* FONCTION D'AFFICHAGE/MASQUAGE DES DIV */
// id : id du DIV
// prop : propriété de visiblity (hidden, visible)
function SetObjVisibility(id, prop){
	NameDiv(id);
	//alert(prop);
	if(document.getElementById || document.all){ doc.style.visiblity=prop; }
	if(document.layers){ doc.visiblity=prop; }
}

/* FONCTION D'AFFECTATION DE CLASSE AUX ELEMENTS */
// id : id de l'élement
// cssName : nom de la classe
function SetObjCss(id, cssName){
	NameDiv(id);
	doc.className=cssName;
}

/* TELECOMMANDE DES ACTUALITES DE LA PAGE D'ACCUEIL */
var nItems;
var id;
var Rub;
var actualIditem;
var secondIditem;
var thirdIditem;
var newsnItems;


function AutoSwapLatest(Rub, id, play){
	var lastItem;
	var blastItem;
	lastItem = newsnItems-1;
	blastItem = newsnItems-2;
	//alert(newsnItems+ " - - " + id);
	//alert("Le DIV a afficher pour "+Rub+" est "+Rub+id);
	//alert("On continue avec le nombre "+id+" sur "+nItems+" items");
	
	for(i = 0; i<newsnItems; i++){
		if(id!=lastItem){
			if(id!=blastItem){
				if(i == id || i == id+1 || i == id+2){
					SetObjDisplay(Rub+i, "inline");
				}
				else { SetObjDisplay(Rub+i, "none"); }
			} else{
				if(i == id-1 || i == id|| i == id+1){ SetObjDisplay(Rub+i, "inline"); }
				else { SetObjDisplay(Rub+i, "none"); }
			}
			
		} else{
			if(i == id || i == id-1 || i == id-2){ SetObjDisplay(Rub+i, "inline"); }
			else { SetObjDisplay(Rub+i, "none"); }
		}
	}
	window["actualId"+Rub]=id;
	window["secondId"+Rub]=id+1;
	window["thirdId"+Rub]=id+2;
	
	//alert("ID tirée au hasard : "+id+" - seconde ID : "+window["secondId"+Rub]+" - Nombre d'ID : "+newsnItems+" - Derniere ID : "+lastItem);
	
	if(window["actualId"+Rub]==0){ SetObjDisplay('Prev', "none"); }
	else{ SetObjDisplay('Prev', "inline"); }
	
	if(window["thirdId"+Rub]>=lastItem){ SetObjDisplay('Next', "none"); }
	else{ SetObjDisplay('Next', "inline"); }
	
	
	//alert("le nombre est "+actualId);
	if(play==1 && newsnItems > 3){ TimerLatest(Rub, id, play); }	
}


function SwapLatest(Rub, id){
	var sens;
	var lastItem;
	var blastItem;
	lastItem=newsnItems-1;
	blastItem = newsnItems-2;
	if(id!=0 && id!=1){
		sens = id;
		//alert(newsnItem);
		//alert(window["actualId"+Rub]);
		if(sens=="prev" && window["actualId"+Rub]>0){
			if(window["actualId"+Rub] == 5 || window["actualId"+Rub] == 4){
				if(window["actualId"+Rub] == 5){
					id=window["actualId"+Rub]-3;
				}
				if(window["actualId"+Rub] == 4){
					id=window["actualId"+Rub]-2;
				}
				
			} else{
				id=window["actualId"+Rub]-1;
			}
			
		}
		else {
			if(sens=="prev" && window["actualId"+Rub]==0){
				id=lastItem;
			}
		}
	
		if(sens=="next" && window["actualId"+Rub]<newsnItems){ id=window["actualId"+Rub]+1; }
		else {
			if(sens=="next" && window["actualId"+Rub]==lastItem){
				id=0;
			}
		}
	}
	window["actualId"+Rub] = id;
	window["secondId"+Rub]=id+1;
	window["thirdId"+Rub]=id+2;
	for(i = 0; i<newsnItems; i++){
		if(id!=lastItem){
			if(id!=blastItem){
				if(i == id || i == id+1 || i == id+2){
					SetObjDisplay(Rub+i, "inline");
				}
				else { SetObjDisplay(Rub+i, "none"); }
			} else{
				if(i == id-1 || i == id|| i == id+1){ SetObjDisplay(Rub+i, "inline"); }
				else { SetObjDisplay(Rub+i, "none"); }
			}
			
		} else{
			if(i == id || i == id-1 || i == id-2){ SetObjDisplay(Rub+i, "inline"); }
			else { SetObjDisplay(Rub+i, "none"); }
		}
	}
	//alert("actualId = "+window["actualId"+Rub]);
	
	if(window["actualId"+Rub]==0 && window["thirdId"+Rub]<newsnItems){ SetObjDisplay('Prev', "none"); }
	else{ SetObjDisplay('Prev', "inline"); }
	
	if(window["thirdId"+Rub]>=lastItem){ SetObjDisplay('Next', "none"); }
	else{ SetObjDisplay('Next', "inline"); }

	
	//alert("le nombre est "+actualId);
	window.clearTimeout(window["testlatest"+Rub]);
}

function TimerLatest(Rub, id, play){
	var next;
	var lastItem;
	lastItem = newsnItems-1;
	//alert("Le numéro de la dernière ITEM de "+Rub+" est le "+lastItem);
	if (id == lastItem){
		next=0;
	} else {
		next = id+1;
	}
	
	//alert("le prochain est le nombre "+next+ " ("+ActusLayers[next]+")");
	// LE TEMPS EST PARAMETRÉ A 5 SECONDES
	window["testlatest"+Rub]=window.setTimeout("AutoSwapLatest(\""+Rub+"\", "+next+", "+play+")",5000);
}

function DiapoLatest(Rub, play){
	var lastItem;
	lastItem = newsnItems-1;
	// On attribue un nombre aléatoirement entre 0 et 1
	var id = Math.round(Math.random()*newsnItems);
	if (id==newsnItems){ id=lastItem; }
	AutoSwapLatest(Rub, id, play);
	//alert("L'ID tirée au sort pour "+Rub+" est la n°"+id);
	// On fais apparaitre le calque en conséquence
}





