
function remplacecara(expr,a,b) {
  var i=0;
  while (i!=-1) {
	
	 i=expr.indexOf(a,i);
	 if (i>=0) {
		expr=expr.substring(0,i)+b+expr.substring(i+a.length);
		i+=b.length;
	 }
  }
  return expr;
}
// ************************************* Fonctions pour le rollover des images du menu *************************************************************
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_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_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];}
}
// *****************************************************************************************************************************************


// ******************************************************  SLIDE DIAPORAMA ***************************************************************
// Délais de la rotation
var nBanDelais = 5;
aBannieres = new Array();
// Bannières
aBannieres[0] = new twBanniere('#','images/diapo03.jpg','Tous types de véhicules');
aBannieres[1] = new twBanniere('#','images/diapo01.jpg','De nombreux véhicules');
aBannieres[2] = new twBanniere('#','images/diapo02.jpg','Différentes marques');

// Ne pas modifier le code suivant
function twBanniere(_url,_src,_texte) {this.url=_url;this.src=_src;this.texte=_texte;}
function twRotation(){
  nBanPos=(nBanPos<nBanMax-1)?nBanPos+1:0;
  if (document.all){
    document.images["twban"].style.filter="blendTrans(duration=2)";
    document.images["twban"].style.filter="blendTrans(duration=CrossFadeDuration)";
    document.images["twban"].filters.blendTrans.Apply();
  }
  document.images["twban"].src=aBannieres[nBanPos].src;
  if (document.all) document.images["twban"].filters.blendTrans.Play();
  oTimer = setTimeout('twRotation()',nBanDelais*1000);
}
var nBanPos = 0;
var oTimer;
var nBanMax = aBannieres.length;



// *****************************************************      GOOGLE MAP      ******************************************************************
function load() {
	if (GBrowserIsCompatible()) {
		var map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(48.2617,6.4090), 14);
		map.openInfoWindowHtml(map.getCenter(),
		"<table><tr><td align=\"center\" width=\"150\"><b>Garage HARROUE<\/b><br \/>198 rue de Lorraine<br \/>88150 THAON LES VOSGES<br \/><br \/>Tél. <b>03 29 81 81 81</b><br \/>Fax. 03 29 81 81 82<\/td><\/tr><\/table>");
	}
}
// *****************************************************************************************************************************************

function changeOver(obj,color){
	obj.style.backgroundColor=color;
}

function clone(val) {
	document.data.lib.value = val
}

function clone2(input,val) {
	input.value = val
}

function sendData(balise, param, page){	
	//alert(balise+" "+param+" "+page);
	if(document.all) { 
		//Internet Explorer 
		var XhrObj = new ActiveXObject("Microsoft.XMLHTTP") ; 
	}else{ 
		//Mozilla 
		var XhrObj = new XMLHttpRequest(); 
	}
			
	//définition de l'endroit d'affichage
	var content = document.getElementById(balise); 
	XhrObj.open("POST", page); 
	  
	//Ok pour la page cible 
	XhrObj.onreadystatechange = function() { 
		if (XhrObj.readyState == 4 && XhrObj.status == 200){
			content.innerHTML = XhrObj.responseText ; 
		}
	}
	 
	if (XhrObj.readyState == 4 && XhrObj.status == 200){ 
		content._innerhtml = XhrObj.responseText ; 
		alert(XhrObj.responseText); 
	}
	
	XhrObj.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
	XhrObj.send(param); 
}

function recupDataMinipanier(val1){
	sendData('ajaxMinipanier', "op=sel_liste&id_liste="+val1,'ajax/ajax_minipanier.php');
}

function recupDataPays(id) {
	var indexsite = document.getElementById(id);
	var valeursite = indexsite.options[indexsite.selectedIndex].value;
	return valeursite;
}

function recupDataLibListe() {
	var val1 = document.ajout_liste.libelle_liste.value;
	sendData('ajaxMinipanier', "op=ajt_liste&lib_liste="+val1,'ajax/ajax_minipanier.php');
}

function recupDataRechRapide(){
	var val1 = document.forms[0].marque.options[document.forms[0].marque.selectedIndex].value;
	var val2 = document.forms[0].modele.options[document.forms[0].modele.selectedIndex].value;
	var val3 = document.forms[0].categorie.options[document.forms[0].categorie.selectedIndex].value;
	var val4 = document.forms[0].carburant.options[document.forms[0].carburant.selectedIndex].value;
	sendData('ajaxRechRapide', "marque="+val1+"&modele="+val2+"&categorie="+val3+"&carburant="+val4+"&etat=1",'ajax_rech_rapide.php');
}

function recupData(val1,val2){
	//var val1 = document.detail_commande.commande_cours.options[document.detail_commande.commande_cours.selectedIndex].value;
	sendData('ajaxDetailCommande', "id_commande_cours="+val1+"&id_commande_archive="+val2,'ajax/ajax_commande_client.php');
}

function recupData2(tri,affichage){
	var val1 = document.forms[0].marque.options[document.forms[0].marque.selectedIndex].value;
	var val2 = document.forms[0].modele.options[document.forms[0].modele.selectedIndex].value;
	var val3 = document.forms[0].categorie.options[document.forms[0].categorie.selectedIndex].value;
	var val4 = document.forms[0].carburant.options[document.forms[0].carburant.selectedIndex].value;
	var val5 = document.forms[0].etat.options[document.forms[0].etat.selectedIndex].value;
	var val6 = document.forms[0].nb_page2.options[document.forms[0].nb_page2.selectedIndex].value;
	sendData('ajaxListVehicule', "marque="+val1+"&modele="+val2+"&categorie="+val3+"&carburant="+val4+"&etat="+val5+"&ordre="+tri+"&nb_page="+val6+"&affichage="+affichage,'ajax_liste_voitures.php');
}

function myGetElementById(elemID) {
	if (document.getElementById && document.getElementById(elemID)) {
		return document.getElementById( elemID );
	} else if (document.all && document.all[divID]) {
		return document.all[ divID ];
	} else if (document.layers && document.layers[divID]) {
		return document.layers[ divID ];
	} else {
		return false;
	}
}
			
function ShowHide(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		Pdiv.className = (Pdiv.className=='cache')?'':'cache';
	}
}

function Show(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		if(Pdiv.className=='cache') {
			Pdiv.className = '';
		}
	}
}

function Hide(divID) {
	Pdiv = myGetElementById(divID);
	if (Pdiv) {
		if(Pdiv.className=='') {
			Pdiv.className = 'cache';
		}
	}
}

function changeCouleur(ligne){
	ligne.bgColor = '#c0e0ff';
}

function remetCouleur(ligne){
	ligne.bgColor = '#ffffff';
}

function affichePopup(id_checkbox) {
	var check = document.getElementById(id_checkbox);
	// si la case est cochée, on affiche la popup du comparatif
	if(check.checked) {
		hs.htmlExpand(document.getElementById('lienAfficheComp'), { contentId: 'comparatif-html' } );
	}
}



function codeTouche(evenement)
{
        for (prop in evenement)
        {
                if(prop == "which") return(evenement.which);
        }
        return(evenement.keyCode);
}

/* Controle des caractères de saisis pour des champs ne pouvant pas avoir d'espace ou de caractèrs spèciaux */
function scanTouche(evenement)
{

    var codeDecimal  = codeTouche(evenement);
    var car = String.fromCharCode(codeDecimal);
		
	//Les caractères acceptés.
	var accepter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-";


	if (accepter.indexOf(car) >= 0)
		autorisation =true;
	else
		autorisation =false;

	if (evenement.keyCode==8)
				autorisation=true;

				
		if (!(autorisation))
			document.getElementById('messagErreurcaractere').style.display = "block";
		else
			document.getElementById('messagErreurcaractere').style.display ="none";

			
        return autorisation;
}

function verifChamp(valeur,idObjet)
{
	var accepter = "abcdefghijklmnopqrstuvwxyz0123456789_-";

		
	taille=valeur.length;
    autorisation=true;
    textPseudo="";

   for (i=0; i<=(taille-1); i++){
		if (accepter.indexOf(valeur.charAt(i)) >= 0)
			textPseudo+=valeur.charAt(i);
		else
		{
			if ((valeur.charAt(i)=='à') ||(valeur.charAt(i)=='â')|| (valeur.charAt(i)=='ä'))
			textPseudo+='a';
			else if ((valeur.charAt(i)=='é') ||(valeur.charAt(i)=='è')|| (valeur.charAt(i)=='ê')|| (valeur.charAt(i)=='ë'))
					textPseudo+='e';
				else if ((valeur.charAt(i)=='î') ||(valeur.charAt(i)=='ï'))
						textPseudo+='i';
					else if ((valeur.charAt(i)=='ô') ||(valeur.charAt(i)=='ö'))
							textPseudo+='o';
							else if ((valeur.charAt(i)=='ù') ||(valeur.charAt(i)=='û')||(valeur.charAt(i)=='ü'))
								textPseudo+='o';
								else if (valeur.charAt(i)=='ÿ')
									textPseudo+='y';
										else if (valeur.charAt(i)==' ')
											textPseudo+='_';

			autorisation=false;
		}
			
		
		
		
		
			
   } 
	if (!(autorisation))
	{
			document.getElementById('messagErreurcaractere').style.display = "block";
		    document.getElementById(idObjet).value=textPseudo;
			
	}
		else
			document.getElementById('messagErreurcaractere').style.display ="none";
	
}
 function agrandirimage(imgAchanger)   
 {     
	
	var a=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",100);
	var b=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",200);
	var c=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height+2",300);
	var d=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",400);
	var e=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",500);
	var f=setTimeout("document."+imgAchanger+".height=document."+imgAchanger+".height-2",600);
	
	
 }  

