// ************************************* 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];}
}
// *****************************************************************************************************************************************

// *****************************************************      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 sendData(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 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].type.options[document.forms[0].type.selectedIndex].value;
	var val4 = document.forms[0].carburant.options[document.forms[0].carburant.selectedIndex].value;
	sendData('ajaxRechRapide', "marque="+val1+"&modele="+val2+"&type="+val3+"&carburant="+val4,'ajax_rech_rapide.php');
}

function recupData(){
	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].type.options[document.forms[0].type.selectedIndex].value;
	var val4 = document.forms[0].carburant.options[document.forms[0].carburant.selectedIndex].value;
	sendData('ajaxListVehicule', "marque="+val1+"&modele="+val2+"&type="+val3+"&carburant="+val4,'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 changeCouleur(ligne){
	ligne.bgColor = '#c0e0ff';
}

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

function PopupImage(image, libelle_vehicule) { 
	var titre=libelle_vehicule; 
	var texte=""; 
	var imgtitle= libelle_vehicule; 
	var alt= libelle_vehicule; 
	var style="styles.css"; 
	var h = 250; 
	var l = 250; 
	var mh = 60; 
	var mv = 20; 
	var ln = 10; 
	var hn = 30; 
	var lfm,hfm,hautfm,gauchefm; 
	if (typeof self.innerHeight != 'undefined'){ 
		ln2 = self.outerWidth-document.body.offsetWidth; 
		hn2 = self.outerHeight-self.innerHeight; 
		hautfm = self.screenY; 
		gauchefm = self.screenX; 
		lfm = self.outerWidth-ln2; 
		hfm = self.innerHeight+hn2; 
	}else if (typeof document.documentElement != 'undefined' && document.documentElement.clientHeight != 'undefined') { 
		hautfm = window.center; 
		gauchefm = window.center; 
		lfm = document.documentElement.clientWidth-ln; 
		hfm = document.documentElement.clientHeight-hn; 
	}else if (typeof document.body != 'undefined'){ 
		hautfm = window.center; 
		gauchefm = window.center; 
		lfm = document.body.clientWidth-ln; 
		hfm = document.body.clientHeight-hn; 
	} 
	var PosX = Math.round(( hfm - h ) / 2)+hautfm; 
	var PosY = Math.round(( lfm - l ) / 2)+gauchefm; 
	var option = "resizable,toolbar=no,scrollbars=no,top="+PosX+",left="+PosY+",width="+l+",height="+h+""; 
	w=open('',"titre",option); 
	w.focus();
	w.document.write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>"); 
	w.document.write("<html xmlns='http://www.w3.org/1999/xhtml'>"); 
	w.document.write("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1' />"); 
	w.document.write("<html><head><title>"+titre+"</title></head>"); 
	w.document.write("<link href='"+style+"' rel='stylesheet' type='text/css' />"); 
	w.document.write("<script type=text/javascript>function checkSize() { if (document.images[0].width > 1 && document.images[0].height > 1) { window.resizeTo(document.images[0].width+"+ln+"+"+mv+",document.images[0].height+"+hn+"+"+mh+")} else { setTimeout('checksize()',250) } }</"+"script>"); 
	w.document.write("<script type=text/javascript>function centerPopup() { window.moveTo(Math.round(("+lfm+"-(document.images[0].width+"+mv+"))/2)+"+gauchefm+",Math.round(("+hfm+"-(document.images[0].height+"+mh+"))/2)+"+hautfm+");}</"+"script>"); 
	w.document.write("<body onload='checkSize();centerPopup()' onblur='window.close()' onclick='window.close()'>"); 
	w.document.write("<div class='cadreh'></div><div class='cadreg'></div><div class='cadrec'><img src='"+image+"' class='image' alt='"+alt+"' title='"+imgtitle+"'></div><div class='cadred'></div><div class='cadreb'><div class='legende'>"+texte+"</div></div>"); 
	w.document.write("</body></html>"); 
	w.document.close(); 
} 