// JavaScript Document
<!--
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);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function printit(){  
if (window.print) {
    window.print() ;  
} else {
    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  
}
}
//Affiche ou non un objet
function show_hideObj(param1) { 

  // Booléen reconnaissant le navigateur (vu en partie 2)
  isIE = (document.all) 
  isNN6 = (!isIE) && (document.getElementById)
	
	nb = show_hideObj.arguments.length;
    
    for (var i = 0; i < nb; i++)
    {
         if (isIE) DIV = document.all[show_hideObj.arguments[i]];
	  	 if (isNN6) DIV = document.getElementById(show_hideObj.arguments[i]);
		 if (DIV.style.display == "none"){
			// Cas ou le tableau est caché
			DIV.style.display = ""
	  	 } else {
			// On le cache
			DIV.style.display = "none"
	   	 }
	   
    }
	return false;
  
}

//Fonction modifiée pour afficher le popup au centre de l'écran
function openCenteredWindow(theURL,winName,width,height,features) { //v2.0
	var top=(screen.height-height)/2;
    var left=(screen.width-width)/2;
	window.open(theURL,winName,"top="+top+",left="+left+",width="+width+",height="+height+","+features);
}
function searchCatAndGo(cat_nom){
	
	//Si on a le moteur de recherche affiché
	var locat = new String(window.location);
	if(document.all['moreSearch'] || document.getElementById('moreSearch')){
	
		for(var i = 0;i< document.forms[0].searchCat.options.length;i++){
			if(document.forms[0].searchCat.options[i].text == cat_nom){
				document.forms[0].searchCat.selectedIndex =i;
			}
		}
		document.forms[0].submit();
	}
}

/* Fonction du catalogue */
function DisplayingDiv(elmt)
{
	if(elmt!="select_cat_id")
	{
		if(document.getElementById('select_cat_id'))
		{
			document.getElementById('select_cat_id').style.display='none';
		}
	}
	
	if(elmt!="select_marque_id")
	{
		if(document.getElementById('select_marque_id'))
		{
			document.getElementById('select_marque_id').style.display='none';
		}
	}
	
	if(elmt!="select_fab_id")
	{
		if(document.getElementById('select_fab_id'))
		{
			document.getElementById('select_fab_id').style.display='none';
		}
	}
	
	if(elmt!="select_pilote_id")
	{
		if(document.getElementById('select_pilote_id'))
		{
			document.getElementById('select_pilote_id').style.display='none';
		}
	}
	
	if(elmt!="select_modele_id")
	{
		if(document.getElementById('select_modele_id'))
		{
			document.getElementById('select_modele_id').style.display='none';
		}
	}
	
	if(elmt!="select_echelle_id")
	{
		if(document.getElementById('select_echelle_id'))
		{
			document.getElementById('select_echelle_id').style.display='none';
		}
	}
	
	if(elmt!="select_type_id")
	{
		if(document.getElementById('select_type_id'))
		{
			document.getElementById('select_type_id').style.display='none';
		}
	}
	
	if(document.getElementById(elmt))
	{
		if(document.getElementById(elmt).style.display=='block')
			document.getElementById(elmt).style.display='none';
		else
			document.getElementById(elmt).style.display='block';
	}
}

function ResetCatalogue(lang)
{
	if(document.getElementById("cat_id"))
	{
		document.getElementById("cat_id").selectedIndex=0;
	}
	
	if(document.getElementById("marque_id"))
	{
		document.getElementById("marque_id").selectedIndex=0;
	}
	
	if(document.getElementById("fab_id"))
	{
		document.getElementById("fab_id").selectedIndex=0;
	}
	
	if(document.getElementById("pilote_id"))
	{
		document.getElementById("pilote_id").selectedIndex=0;
	}
	
	if(document.getElementById("mod_id"))
	{
		document.getElementById("mod_id").selectedIndex=0;
	}
	
	if(document.getElementById("prod_mod"))
	{
		//modele
		if(lang=='fr')
		{
			document.getElementById("prod_mod").value='MODELE';
		}
		else
		{
			document.getElementById("prod_mod").value='MODEL';
		}
	}
	
	if(document.getElementById("prod_version"))
	{
		//modele
		document.getElementById("prod_version").value='VERSION';
	}
	
	if(document.getElementById("ech_id"))
	{
		document.getElementById("ech_id").selectedIndex=0;
	}
	
	if(document.getElementById("type_id"))
	{
		document.getElementById("type_id").selectedIndex=0;
	}
	
	if(document.getElementById("search_date"))
	{
		//type
		if(lang=='fr')
		{
			document.getElementById("search_date").value="ANNEE";
		}
		else
		{
			document.getElementById("search_date").value="YEAR";
		}
	}
}


function Ajout_Option(val1,val2,elmt,bool_disabled)
{
	eval("document.getElementById('"+elmt+"').options[document.getElementById('"+elmt+"').options.length]= new Option('"+val2.replace("'","\\'")+"','"+val1+"')");
	if(bool_disabled)
	{
		eval("document.getElementById('"+elmt+"').options[1].disabled=true");
	}
}

function file(fichier)
{
	if(window.XMLHttpRequest) // FIREFOX
		xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // IE
		xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return(false);
	
	xhr_object.open("GET", fichier, false);
	xhr_object.send(null);
	
	if(xhr_object.readyState == 4) 
		return(xhr_object.responseText);
	else return(false);
}

//initialise la liste des modeles en fonctions de la marque
function init_Modele(selecteur,marque_id,lang)
{
	if(texte = file("/fr/recup_modele.php?marque_id="+marque_id))
	{
		switch(lang)
		{
			case 'fr':
			{
				libelle="MODELE";
			}break;
			case 'uk':
			{
				libelle="MODEL";
			}break;
		}
		
		eval(texte);
		
		if(tableau.length>0)
		{
			document.getElementById(selecteur).innerHTML="";
		
			Ajout_Option("MODELE",libelle,selecteur,false);
			Ajout_Option('',"----------------------------------------",selecteur,true);
			
			for(var i=0;i<tableau.length;i++)
			{
				Ajout_Option(tableau[i][0],tableau[i][1],selecteur,false);
			}
			
			document.getElementById(selecteur).selectedIndex=0;
		}
		else
		{
			document.getElementById(selecteur).innerHTML="";
		
			Ajout_Option("MODELE",libelle,selecteur,false);
			Ajout_Option("MODELE","----------------------------------------",selecteur,true);
		}		
	}
}

//initialise la liste des modeles en fonctions de la marque
//et selectionne le modele dans la liste
function init_Modele_Selected(selecteur,marque_id,mod_id,lang)
{
	if(texte = file("/fr/recup_modele.php?marque_id="+marque_id))
	{
		switch(lang)
		{
			case 'fr':
			{
				libelle="MODELE";
			}break;
			case 'uk':
			{
				libelle="MODEL";
			}break;
		}
		
		eval(texte);
		
		if(tableau.length>0)
		{
			document.getElementById(selecteur).innerHTML="";
		
			Ajout_Option("MODELE",libelle,selecteur,false);
			Ajout_Option('',"----------------------------------------",selecteur,true);
			
			num_selected=0;
			for(var i=0;i<tableau.length;i++)
			{
				if(tableau[i][0]==mod_id)
				{
					num_selected=i;
				}
				Ajout_Option(tableau[i][0],tableau[i][1],selecteur,false);
			}
			
			//on ajoute 2 pour prendre en compte les deux première options non cliquable
			document.getElementById(selecteur).selectedIndex=num_selected+2;
		}
		else
		{
			document.getElementById(selecteur).innerHTML="";
		
			Ajout_Option("MODELE",libelle,selecteur,false);
			Ajout_Option("MODELE","----------------------------------------",selecteur,true);
		}		
	}
}

function change_search_mode_click(lang,lid) {
  s = document.getElementById('search_mode');
  old = s.value;
  s.value = lid;

  i = document.getElementById('search_mode_img_' + old);
  i.src = "../imgs/" + lang + "/02_left/00_catalogue/type_cat_0" + old + ".jpg";

  s =  document.getElementById('search_select_by_type');
  if(lid == 2 || lid == 3) {
    s.style.visibility = "hidden";
		s = document.getElementById('type_id');
		s.selectedIndex = 0;
  } else {
    s.style.visibility = "visible";
  }

}

function change_search_mode_out(t, lang, lid) {
  s = document.getElementById('search_mode');
  s = s.value;
  if(s == lid) {
    t.src = "../imgs/" + lang + "/02_left/00_catalogue/type_cat_0" + lid + "_over.jpg";
  } else {
    t.src = "../imgs/" + lang + "/02_left/00_catalogue/type_cat_0" + lid + ".jpg";
  }
}
//-->
