function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
loadImage = function(){
	MM_preloadImages('images/en/module-acoustic-package.gif', 'images/en/module-front-end.gif','images/en/module-exhaust.gif','images/en/module-door.gif','images/en/module-cockpit.gif','images/en/module-seat.gif' );
	MM_preloadImages('images/fr/module-acoustic-package.gif', 'images/fr/module-front-end.gif','images/fr/module-exhaust.gif','images/fr/module-door.gif','images/fr/module-cockpit.gif','images/fr/module-seat.gif' );

	MM_preloadImages('images/audia4_on.jpg','images/bmwminiclubman_on.jpg','images/bmwx5_on.jpg','images/cadillaccts_on.jpg','images/chevroletmalibu_on.jpg','images/cryslerseberin_on.jpg','images/jeep_on.jpg','images/tiguan_on.jpg')
}


roolVehicles = function(){
lang="en";
vehicle=false;
bascule=false;
langlink=""

	if( location.href.indexOf("vehicles-") != -1 ){
		vehicle = true;
	}


	if( location.href.indexOf("eco-design") != -1 ){
		bascule = true;
	}

	if( location.href.indexOf("_fr.") == -1 ){
		lang = "en"
	}else{
		lang = "fr"
		langlink="_fr"
	}
	
	var li = Array();
	
	if(document.getElementById('footer')!= null){
		li = document.getElementById('footer').getElementsByTagName('h2');
	}else if(document.getElementById('footerautre')!= null){
		li = document.getElementById('footerautre').getElementsByTagName('h2');
	}else if(document.getElementById('footervehicles')!= null){
		li = document.getElementById('footervehicles').getElementsByTagName('h2');
	}
	

	vehicle_on = '<a href="vehicles-equipped'+langlink+'.htm"><img  src="images/'+lang+'/vehicles1_on.gif" width="162" height="54" border="0" alt="" /></a>'
	innovate_on = '<a href="eco-design'+langlink+'.htm" title="eco-design"><img src="images/'+lang+'/eco-design1_on.gif" width="162" height="54" border="0" alt="eco-design" /></a>'
	var vlinks = Array()

	vlinks[0] = '<a href="vehicles-equipped'+langlink+'.htm" title="" onmouseover="MM_swapImage(\'linkvehicles\',\'\',\'images/'+lang+'/vehicles1_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkvehicles" src="images/'+lang+'/vehicles1.gif" width="162" height="54" border="0" alt="" /></a>'
	vlinks[1] = '<a href="vehicles-equipped'+langlink+'.htm" title="" onmouseover="MM_swapImage(\'linkvehicles\',\'\',\'images/'+lang+'/vehicles2_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkvehicles" src="images/'+lang+'/vehicles2.gif" width="162" height="54" border="0" alt="" /></a>'
	vlinks[2] = '<a href="vehicles-equipped'+langlink+'.htm" title="" onmouseover="MM_swapImage(\'linkvehicles\',\'\',\'images/'+lang+'/vehicles3_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkvehicles" src="images/'+lang+'/vehicles3.gif" width="162" height="54" border="0" alt="" /></a>'
	vlinks[3] = '<a href="vehicles-equipped'+langlink+'.htm" title="" onmouseover="MM_swapImage(\'linkvehicles\',\'\',\'images/'+lang+'/vehicles4_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkvehicles" src="images/'+lang+'/vehicles4.gif" width="162" height="54" border="0" alt="" /></a>'	

	
	var ilinks = Array()
	ilinks[0] = '<a href="eco-design'+langlink+'.htm" title="Eco-design" onmouseover="MM_swapImage(\'linkinovate\',\'\',\'images/'+lang+'/eco-design1_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkinovate" src="images/'+lang+'/eco-design1.gif" width="162" height="54" border="0" alt="Eco-design" /></a>'
	//ilinks[1] = '<a href="eco-design'+langlink+'.htm" title="Eco-design" onmouseover="MM_swapImage(\'linkinovate\',\'\',\'images/'+lang+'/eco-design2_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkinovate" src="images/'+lang+'/eco-design2.gif" width="162" height="54" border="0" alt="Eco-design" /></a>'
	//ilinks[2] = '<a href="eco-design'+langlink+'.htm" title="Eco-design" onmouseover="MM_swapImage(\'linkinovate\',\'\',\'images/'+lang+'/eco-design3_on.gif\',1)" onmouseout="MM_swapImgRestore()"><img name="linkinovate" src="images/'+lang+'/eco-design3.gif" width="162" height="54" border="0" alt="Eco-design" /></a>'
	


	for(i=0;i<li.length; i++){
	
		if(!vehicle)
		{
			if(i==1){
				randomnumber=Math.floor(Math.random()*4)
				li[i].innerHTML = vlinks[randomnumber];
			}
		}else{
			if(i==1){
				li[i].innerHTML = vehicle_on;
			}
		}
		
		if(!bascule)
		{
			if(i==3){
				randomnumber=Math.floor(Math.random()*3)
				//li[i].innerHTML = ilinks[randomnumber];
				li[i].innerHTML = ilinks[0];
			}
		}else{
			if(i==3){
				li[i].innerHTML = innovate_on;
			}			
		}
		
	}

}

function addLoadEvent(func) {
	if (window.addEventListener) 
		window.addEventListener("load", func, false);
	else if (window.attachEvent) 
		window.attachEvent("onload", func);
}
addLoadEvent(roolVehicles);
//addLoadEvent(loadImage);


function showparanorth(obj,id){
		
		for(i=1;i<5;i++){
			elt = document.getElementById('text'+i);
			elt.style.display = 'none';
		}
		var a = document.getElementById('navnorth').getElementsByTagName('a');
		for(i=0;i<a.length; i++){
			a[i].className = '';
		}

		elt = document.getElementById('text'+id);
		elt.style.display = 'block';
		obj.className = 'on';	

}


function showvehicles(){
		

			elt = document.getElementById('intro-vehicles');
			elt.style.display = 'none';

			elt = document.getElementById('tableauvehicles');
			elt.style.display = 'block';

}


function hideVehicles(id)
{
	elt = document.getElementById(id);
	if(elt != null)
	{
		elt.style.display = 'none';
	}
}

function showVehicles(id)
{
	for(i=1;i<9;i++){
		hideVehicles('vehicles'+i)
	}

	elt = document.getElementById(id);
	if(elt != null)
	{
		elt.style.display = 'block';
	}
}

var pWin = null

function OpenPopup(pDocument, width, height) {
	if ((pWin != null) && (!pWin.closed)) pWin.close();
	pWin = window.open(pDocument, "Faurecia", "scrollbars=yes,width=" + width + ",height=" + height + ",resizable=no,location=no");
	if (window.focus) pWin.focus();
}



function ShowScollerOrNot(maxY)
{
	elt = document.getElementById("scrollbar");

	if(maxY>0){
		elt.style.display = 'block';
	}else{
		elt.style.display = 'none';
	}
}
