// script javascript devis GARDICANIN - call ajax mode
var cur_appel=0;

// affichage erreur
function GC_ShowErreur(Msg)
{						
	try{var obj=document.getElementById("GC_DEVIS_ALERTE");obj.innerHTML=Msg;}
	catch (e){alert(Msg);}						
}

// affichage tarif dynamique, pg_dst = page appelle avec parametres
function GC_GetTarif(pg_dst)
{
	//document.location = "../../public/pages/recap_devis.aspx";	
	GC_DevisClearDiv();
	var xhr_object = null; 	
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	GC_ShowErreur("Service non supporte par votre navigateur"); 
	} 	
	
 	try	
		{						
			var obj=document.getElementById("GC_DEVIS_RESULT");
			//document.location = "../../public/pages/recap_devis.aspx";	
			//var obj=document.getElementById("GC_DEVIS_RECAP");
			obj.innerHTML="";			
			xhr_object.open("GET", pg_dst , true);  
			xhr_object.onreadystatechange = function() { 
		  		if(xhr_object.readyState == 4) {	
		  			if(xhr_object.status==200){
		  				obj.innerHTML=xhr_object.responseText;
		  				//document.write(xhr_object.responseText);	
		  				document.getElementById("GC_DEVIS_AFFICHAGE").style.display = 'block';
		  				obj.style.display='block';
		  				obj.style.visibility='visible';
		  				scrolldown(true);
		  			}
		  			else{
		  				// affichage si page trouvee
		  				GC_ShowErreur("Service non disponible.");		  					  				
		  				//document.write("Service non disponible.");
		  			}		  			 
		  		} 
			} 
			xhr_object.send(null);			
		}
	catch (e){
		//alert("Erreur");
		document.write("Erreur");
	}	
}


function scrolldown(toLower) { 
     var h=0; 
     if (toLower) {
         if (window.innerHeight) h = window.innerHeight; 
         else if (document.body && document.body.offsetHeight) h = window.document.body.offsetHeight; 
         else if (document.documentElement && document.documentElement.clientHeight) h = document.documentElement.clientHeight; 
     }
    this.scroll(1,h); 
}        

// clear div
function GC_DevisClearDiv(){
	var obj=document.getElementById("GC_HELP");
	if(obj){obj.innerHTML="";}
	var obj=document.getElementById("GC_DEVIS_RESULT");
	if(obj){obj.innerHTML="";}
	obj=document.getElementById("GC_DEVIS_ALERTE");
	if(obj){obj.innerHTML="";}
}

// change prestation
function GC_DevisChgePrestation(){
	var idpr = document.forms[0].GCDevis_idpr.value;
	ClearTarif()	
	//clear error and result
	//GC_DevisClearDiv();	
}

var temp_recap_tarif_devis = "";
function ShowPromo(linkBtn) {
    if (document.getElementById("recap_tarif_devis")) {
        var innerHTML = document.getElementById("recap_tarif_devis").innerHTML;
        if (temp_recap_tarif_devis == "" || temp_recap_tarif_devis == innerHTML) {
            temp_recap_tarif_devis = innerHTML;
            document.getElementById("recap_tarif_devis").innerHTML = "Saisissez votre code promotionnel<br/><table><tr><td><input type='text' id='CodePromotionnel' name='CodePromotionnel' width='170px' value='' /><a href='javascript:GC_GetDevis();' onclick='this.blur()'><img class='pointer' alt='Valider' src='../images/btn_ok.gif' border='0' /></a></td></tr></table>";
            linkBtn.innerHTML = "Annuler la saisie d'un code promotionnel";
        }
        else {
            var temp_recap_tarif_devis2 = innerHTML;
            document.getElementById("recap_tarif_devis").innerHTML = temp_recap_tarif_devis;
            temp_recap_tarif_devis = temp_recap_tarif_devis2;
            linkBtn.innerHTML = "Saisir un code promotionnel";
        }
    }
    else alert("Service non disponible");
}
function ShowMsgPromo(msg) {
    temp_recap_tarif_devis = document.getElementById("recap_tarif_devis").innerHTML;
    document.getElementById("recap_tarif_devis").innerHTML = msg;
}

function ClearTarif(){
	var objResultat=document.getElementById("GC_DEVIS_RESULT");
	if(objResultat){objResultat.innerHTML="";}
	//var objAffichage=document.getElementById("GC_DEVIS_AFFICHAGE");
	//if(objAffichage){objAffichage.innerHTML="";}
	document.getElementById("GC_DEVIS_AFFICHAGE").style.display = 'none';
	//scrolldown();
}

// call devis module 
function GC_GetDevis(){
	var code =""	
    if (document.forms[0].CodePromotionnel)
	{
	    code = document.forms[0].CodePromotionnel.value;
    }
		//clear error and result
			GC_DevisClearDiv();
	// init parametres
	var pg_dst="";
	var idpr=0;
	var ndog=0;
	var ncat=0;
	var nron=0;
	var nday=1;
	var ddeb="";
	var dend="";

	// verif saisies
	var msg=GC_VerifDevis()
	if (!msg==""){
		GC_ShowErreur(msg);
	}	
	else{
		
		// set variables
		idpr = document.forms[0].GCDevis_idpr.value;
		ndog = document.forms[0].GCDevis_ndog.value;
		ncat = document.forms[0].GCDevis_ncat.value;
		//nron = document.forms[0].GCDevis_nron.value;
		nday = document.forms[0].GCDevis_nday.value;
		ddeb = document.forms[0].GCDevis_ddeb.value;
		dend = document.forms[0].GCDevis_dend.value;
	    
		//alert(GetNbDays(ddeb,dend));
		// si code postal présent  		
		
		var cp=0;
		var ville="";	
		if (document.forms[0].code_postal){if (VerifCodePostal(document.forms[0].code_postal.value)==true){cp=document.forms[0].code_postal.value;}}
		if (document.forms[0].commune){ville=document.forms[0].commune.value;}	
		
		// call tarif
		pg_dst = "../../commun/prg/devis.aspx?idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&cp=" + cp + "&v=" + ville.replace("'", "") + "&code=" + code + "&na=" + GetRandParam();
		//pg_dst="../../public/pages/recap_devis.aspx?idpr="+idpr+"&ndog="+ndog+"&ncat="+ncat+"&nron="+nron+"&nday="+nday+"&ddeb="+ddeb+"&dend="+dend+"&cp="+cp+"&v="+ville+"&na="+GetRandParam();
		GC_GetTarif(pg_dst);
		//GC_GetTarif(pg_dst, ndog, ncat, nron, ddeb, dend);
		// si espace client et div temoignage existe, chargement temoignage
		if (document.getElementById("GC_temoignage")){			
			try{
				document.getElementById("GC_temoignage").innerHTML="";
				Get_GMTemoignage(Get_GMTemoignagePage());}
			catch (e){}			
		}
		
	}
}

// change nb de jours
function ChangeNbDays(N){	
	ClearTarif();			
    	var obj = document.forms[0].GCDevis_ddeb;
    	if(obj){    		    		
    		var D1 = document.forms[0].GCDevis_ddeb.value;
    		var obj = document.forms[0].GCDevis_dend;
    		if (obj){    			
    			if (VerifDate(D1)){       				
    				var ND=parseInt(N)-1;    				
    				obj.value=BT_GetdateAdd("d",ND, D1);   				 
    			}
    		}
    	}

}

// changement de dates
function ChangeDevisDate(obj){	
	try{
		var D1 = document.forms[0].GCDevis_ddeb.value;
		var D2 = document.forms[0].GCDevis_dend.value;
		if (obj==document.forms[0].GCDevis_ddeb){
			ChangeNbDays(document.forms[0].GCDevis_nday.value);
		}
		else{
			if (VerifDate(D1) && VerifDate(D2)){		
				var nday=BT_GetDateDiff("d",D1,D2);	
				if(nday<0){nday=0;}					
				if(nday>document.forms[0].GCDevis_nday.options.length-1){nday=document.forms[0].GCDevis_nday.options.length-1;}
				document.forms[0].GCDevis_nday.selectedIndex=nday;
			}
		}
	}
 	catch (e){}
}

// changement de dates au clavier
function ChangeDevisDateClavier(obj){
	//SetDate(obj);
	if(obj.value.length >= 10){
		try{
			var D1 = document.forms[0].GCDevis_ddeb.value;
			var D2 = document.forms[0].GCDevis_dend.value;
			if (obj==document.forms[0].GCDevis_ddeb){									
				ChangeNbDays(document.forms[0].GCDevis_nday.value);			
			}
			else{
				if (VerifDate(D1) && VerifDate(D2)){		
					var nday=BT_GetDateDiff("d",D1,D2);	
					if(nday<0){nday=0;}					
					if(nday>document.forms[0].GCDevis_nday.options.length-1){nday=document.forms[0].GCDevis_nday.options.length-1;}
					document.forms[0].GCDevis_nday.selectedIndex=nday;
				}
			}
		}
 		catch (e){}
 	}
}

// Change date 
function GC_VerifDevis(){						
	// si code postal présent test validité code postal	
	if (document.forms[0].code_postal){
		if (VerifCodePostal(document.forms[0].code_postal.value)==false)
			{return ("Code postal incorrect");}
		else{
			if (document.forms[0].commune.value == "" ){return ("Indiquez votre commune");}
		}
	}
			
	if (document.forms[0].GCDevis_idpr.value == "0"){return ("Indiquez le type de prestation");}	
	// 1 = promenade
	if (document.forms[0].GCDevis_idpr.value == "1"){
		var n = document.forms[0].GCDevis_ndog.value;
		if (n==0){return ("Indiquez le nombre de chiens");}		
	}
	// 2 = Garde d'animaux chez le DogSitter
	if (document.forms[0].GCDevis_idpr.value == "2"){
		var n = document.forms[0].GCDevis_ndog.value + document.forms[0].GCDevis_ncat.value;
		if (n==0){return ("Indiquez vos animaux");}		
	}
	// 3 = visite de chat
	if (document.forms[0].GCDevis_idpr.value == "3"){
		var n = document.forms[0].GCDevis_ncat.value;
		if (n==0){return ("Indiquez le nombre de chats");}		
	}
	 
	// 4 = Garde d'animaux chez le client
	if (document.forms[0].GCDevis_idpr.value == "4"){
		var n = document.forms[0].GCDevis_ndog.value + document.forms[0].GCDevis_ncat.value;
		if (n==0){return ("Indiquez vos animaux");}		
	}
			
	//var V = document.forms[0].GCDevis_ddeb.value;
	//if (V != ""){if (VerifDate(V)==false){return ("Date souhaitÃ©e incorrecte");}}
	
	//var V = document.forms[0].GCDevis_dend.value;
	//if (V != ""){if (VerifDate(V)==false){return ("Date de fin souhaitÃ©e incorrecte");}}
	
	
	//DEBUT MODIFICATION DE DEND
	var V = document.forms[0].GCDevis_ddeb.value;
	if (V == ""){return ("Date souhaitÃ©e incorrecte");}
	if (VerifDate(V)==false){return ("Date de dÃ©but souhaitÃ©e incorrecte");}
	//if (V != ""){return ("Date souhaitÃ©e incorrecte");}
	//FIN MODIFICATION DE DEND
	
	
	//DEBUT MODIFICATION DE DEND
	var V = document.forms[0].GCDevis_dend.value;
	if (V == ""){return ("Date de fin souhaitÃ©e incorrecte");}
	if (VerifDate(V)==false){return ("Date de fin souhaitÃ©e incorrecte");}
	//if (V != ""){return ("Date de fin souhaitÃ©e incorrecte");}
	//FIN MODIFICATION DE DEND	
	
	var deb = getDate(document.forms[0].GCDevis_ddeb.value);
	var end = getDate(document.forms[0].GCDevis_dend.value);
	var datedujour = new Date();
	if (fCompareDate(deb,datedujour)>0) {return ("Date de d\351but antÃ©rieure \340 la date du jour");}
	if (fCompareDate(deb,end)<0) {return ("Date de d\351but supÃ©rieur \340 la date de fin"+ deb + "|"+ end + " ");}
//	else return deb.toLocaleString()+">"+datedujour.toLocaleString();
	return "";
}

function fCompareDate(pDateDebut,pDateFin) { 
    var DureeDebut = Date.parse(pDateDebut); 
    var DureeFin = Date.parse(pDateFin); 
    var iComparaison= DureeFin - DureeDebut; 
    return iComparaison; 
} 

function getDate(strDate){
    //alert("Date "+ strDate);
    day = strDate.substring(0,2);
    month = strDate.substring(3,5);
    year = strDate.substring(6,10);
    
    d = new Date();
    d.setFullYear(year); 
    d.setMonth(month-1);
    d.setDate(day);
    
    //alert("d " + d )
    return d;  
}
// call temoignage
function Get_GMTemoignagePage(){	
	var CP = document.forms[0].code_postal.value;
	var V = document.forms[0].commune.value;
	var idpr = document.forms[0].GCDevis_idpr.value;
	var ndog = document.forms[0].GCDevis_ndog.value;
	var ncat = document.forms[0].GCDevis_ncat.value;
	var nron = 0; //document.forms[0].GCDevis_nron.value;
	var pg_dst = "../../commun/prg/gc_temoin.aspx?cp=" + CP + "&v=" + V.replace("'", "") + "&idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&na=" + GetRandParam();
	return pg_dst;
}

// affichage infos dynamique
function Get_GMTemoignage(pg_dst){						
	var xhr_object = null; 	
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	var obj=document.getElementById("GC_temoignage");
	   	obj.innerHTML="";
	} 	
 	try	
		{						
			var obj=document.getElementById("GC_temoignage");						
			xhr_object.open("GET", pg_dst , true);  
			xhr_object.onreadystatechange = function() { 
		  		if(xhr_object.readyState == 4) {	
		  			if(xhr_object.status==200){
		  				obj.innerHTML=xhr_object.responseText;		  				
		  				obj.style.visibility='visible';		  				
		  			}
		  			else{
		  				// affichage si erreur
		  				obj.innerHTML="";		  				
		  			}		  			 
		  		} 
			} 
			xhr_object.send(null);			
		}
	catch (e){}	
}

// affichage DS proche google Map 
function ShowProxiDS(){
	try{		
		var CP ="";
		var V = "";
		var obj = document.forms[0].code_postal;
		if (obj) { CP = document.forms[0].code_postal.value; }
		if (VerifCodePostal(CP)) {
		    var obj = document.forms[0].commune;
		    if (obj) { V = document.forms[0].commune.value; }
		    var obj = document.getElementById("google_map");
		    if (obj) { GC_GetProxiDS(CP, V, GC_GetLatCommune(), GC_GetLngCommune()); }
		}
	}
	catch (e){}
}

function VerifCodePostal(V) {
    var reg = new RegExp("^[0-9]{5}$");
    if (reg.test(V)) {
        var nb = parseInt(V);
        if (nb > 01000 && nb < 97899) {
            return true;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
}


// affichage DS proche google Map 
function ShowProxiDogSitter(){
	try{		
		var CP ="";
		var V = "";
		var obj = document.forms[0].code_postal;
		if(obj){CP = document.forms[0].code_postal.value;}				
		var obj = document.forms[0].commune;
		if(obj){V = document.forms[0].commune.value;}
		//document.write("LATITUDE : "+GC_GetLatCommune()+" LONGITUDE : "+GC_GetLngCommune());		
		//document.write("CODE POSTAL : "+CP+"VILLE :"+V);
		//var obj = document.getElementById("google_map");
		//if(obj){GC_GetProxiDS(CP,V,GC_GetLatCommune(),GC_GetLngCommune());}
	}
	catch (e){}
}


// get latitude commune 
function GC_GetLatCommune(){
	var LAT=0;	 			
 	try{LAT=document.forms[0].commune.getAttribute('lat')}catch (e){LAT=-1;}
	return LAT;
}
// get longitude commune 
function GC_GetLngCommune(){
	var LNG=0;	 			
 	try{LNG=document.forms[0].commune.getAttribute('lng')}catch (e){LNG=-1;}
	return LNG;
}

// affichage DS proche google Map suite selection commune dans combo commune
function ShowProxiDSFromVille(obj){
	var CP ="";
	var V = "";
	var LAT=0;
	var LNG=0;
	try{				
		CP = document.forms[0].code_postal.value;		
		V=obj.value;
		LAT = obj.options[obj.selectedIndex].getAttribute('lat');
		LNG = obj.options[obj.selectedIndex].getAttribute('lng'); 							
		GC_GetProxiDS(CP,V,LAT,LNG);	
	}
	catch (e){}			
}

// get info DogSitter and affichage google Map 
function ShowWaitMsg(){
	var obj=document.getElementById("google_map");
	if (obj){obj.innerHTML="Recherche en cours ..."}
}

// get info DogSitter and affichage google Map 
function GC_GetProxiDS(CP,V,LAT,LNG){
	var obj=document.getElementById("GC_DEVIS_DS")
	if (obj){
		obj.innerHTML=""							
		var xhr_object = null; 	
		if(window.XMLHttpRequest) // Firefox 
		   	xhr_object = new XMLHttpRequest(); 
		else if(window.ActiveXObject) // Internet Explorer 
		  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
		else { // XMLHttpRequest non supporté par le navigateur    	
		   	obj.innerHTML=""; 
		} 			
	 	try	
			{		
				ShowWaitMsg();			
				//var pg_dst="../../commun/prg/gc_getdspos.aspx?cp="+CP+"&na="+GetRandParam();						
				var pg_dst="../../commun/prg/gc_getdspos.aspx?cp="+CP+"&v="+V+"&la="+LAT+"&lo="+LNG+"&na="+GetRandParam();				
				xhr_object.open("GET", pg_dst , true);  
				xhr_object.onreadystatechange = function() { 
			  		if(xhr_object.readyState == 4) {	
			  			if(xhr_object.status==200){
			  				obj.innerHTML=xhr_object.responseText;
			  				if(document.getElementById("AffichageNombre")){
			  					NombreDS();
			  					}
			  				load_GMAP(obj,CP,V);		  							  				
			  			} 
			  		} 
				} 
				xhr_object.send(null);				
			}
		catch (e){}			
	}
	else{
		// affichage map google
		load_GMAP(null,CP,V);
	}		
}

// ENREGISTREMENT DE DEVIS
// SaveDevis src:1 pour demande contact, 2 pour pré réservation,id_client identifiant client si espace admin
function GC_GetFrmSaveDevis(src,id_client){	 	 
	// verif saisies
	var msg="";
	if (src=="2"){
		var V = document.forms[0].GCDevis_ddeb.value;
		if (V==""){msg="Indiquez la date de rÃ©servation souhaitÃ©e";}
	}	
	if (msg==""){msg=GC_VerifDevis();}
	if (!msg==""){alert(msg);}	
	else{
		// set variables
		var CP = document.forms[0].code_postal.value;
		var V = document.forms[0].commune.value;
		var idpr = document.forms[0].GCDevis_idpr.value;
		var ndog = document.forms[0].GCDevis_ndog.value;
		var ncat = document.forms[0].GCDevis_ncat.value;
		var nron = 0; //document.forms[0].GCDevis_nron.value;
		var nday = document.forms[0].GCDevis_nday.value;
		var ddeb = document.forms[0].GCDevis_ddeb.value;
		var dend = document.forms[0].GCDevis_dend.value;
		var pg_dst = "../../commun/prg/devis.aspx?cp=" + CP + "&v=" + V.replace("'", "") + "&idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&tdevis=" + src + "&client=" + id_client + "&na=" + GetRandParam();
		GC_LoadDivDevis(pg_dst);
	}	
}

// load contents block 
function GC_LoadDivDevis(pg_dst){	 	 
	var xhr_object = null; 	
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	alert("Service non supporte par votre navigateur"); 
	} 	
 	try	
		{						
			var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
			if (obj){
				obj.innerHTML="";			
				xhr_object.open("GET", pg_dst , true);  
				xhr_object.onreadystatechange = function() { 
			  		if(xhr_object.readyState == 4) {	
			  			if(xhr_object.status==200){
			  				obj.innerHTML=xhr_object.responseText;
			  				obj.style.display='block';	
			  				obj.style.visibility='visible';	
			  				if (obj.innerHTML=="NO_SERVICE"){GC_ShowDivDevis(1);alert("Service non disponible.");}
			  				else{GC_ShowDivDevis(2);}
			  			}
			  			else{
			  				// affichage si page trouvee
			  				alert("Service non disponible.");		  					  				
			  			}		  			 
			  		} 
				} 
				xhr_object.send(null);
			}
			else{alert("Service non disponible.");}	
		}
	catch (e){alert("Service non disponible");}	
}

// affichage/hide block save devis T=1 affichage frm simu devis,2 affichage frm save devis
function GC_ShowDivDevis(T){	 	 
	if(T==1){		
		var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
		if(obj){obj.style.display='none';}
		document.location = "../../public/pages/devis.aspx"
		//var obj=document.getElementById("GC_SIMU_DEVIS");
		//if(obj){obj.style.display='';}
		//if(obj){
			//document.getElementById("GC_SIMU_DEVIS").style.display='block';
			//document.getElementById("GC_SIMU_DEVIS").style.visibility='visible';
		//}
	}
	else{
		var obj=document.getElementById("GC_SIMU_DEVIS");
		if(obj){obj.style.display='none';}
		var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
		if(obj){obj.style.display='block';}
	}
}

// verification du formulaire d'enregistrement de devis	
function GC_VerifSaveDevis(){
		
	if (document.forms[0].GCDevis_civilite.value == ""){return ("Indiquez votre civilite");}
	if (document.forms[0].GCDevis_nom.value == ""){return ("Indiquez votre nom");}
	if (document.forms[0].GCDevis_tel.value == ""){return ("Indiquez votre tÃ©lÃ©phone");}
	if (VerifTelephone(document.forms[0].GCDevis_tel.value)==false){return ("TÃ©lÃ©phone non valide (10 chiffres maximum)");}	
	if (!document.forms[0].GCDevis_email.value == "" ){
		if (VerifAdresseEmail(document.forms[0].GCDevis_email.value)==false){return ("Adresse email incorrecte");}
	}
	return "";
}	

// enregistrement du devis,src=0 formulaire remplit par id_client, 1=formulaire remplit par saisies
function GC_SaveDevis(src){
	if (src==1){	 	 
		var msg=GC_VerifSaveDevis();
		if (!msg==""){
			try{var obj=document.getElementById("GC_DEVIS_FRM_ALERTE");obj.innerHTML=msg;}
			catch (e){alert(msg);}	
		}	
		else{		
			var c=document.forms[0].GCDevis_civilite.value;
			var n=document.forms[0].GCDevis_nom.value;
			var p=document.forms[0].GCDevis_prenom.value;
			var t=document.forms[0].GCDevis_tel.value;
			var e=document.forms[0].GCDevis_email.value;
			var comments=document.forms[0].GCDevis_comments.value;
			var pg_dst="../../commun/prg/devis.aspx";
			var params="action=1&c="+c+"&n="+n+"&p="+p+"&t="+t+"&e="+e+"&com="+comments+"&na="+GetRandParam();
			GC_LoadConfirmSaveDevis(pg_dst,params);
		}
	}
	else{
		var pg_dst="../../commun/prg/devis.aspx";
		var comments=document.forms[0].GCDevis_comments.value;		
		var params="action=1"+"&com="+comments+"&na="+GetRandParam();
		GC_LoadConfirmSaveDevis(pg_dst,params)
		
	}
}

// Save devis and show confirm 
function GC_LoadConfirmSaveDevis(pg_dst,params){		
	var xhr_object = null; 	
	var id_devis = 0;
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	alert("Service non supporte par votre navigateur"); 
	} 	
 	try	
		{						
			var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
			if (obj){
				obj.innerHTML="";			
				xhr_object.open("POST", pg_dst , true); 
				xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
				xhr_object.send(params);
				xhr_object.onreadystatechange = function() { 
			  		if(xhr_object.readyState == 4) {	
			  			if(xhr_object.status==200){
			  				obj.innerHTML=xhr_object.responseText;
			  				id_devis = document.getElementById('identifiant_devis').value;
			  				// modif Arnaud le 04/12/2008
						    // maintenant que les donnees reçues on ete placees dans la page,
						    // il faut executer toutes les balises script :   
			  				document.getElementById('GC_DEVIS_RECAP').style.display = 'none';  
			  				document.getElementById('GC_DEVIS_RECAP').style.visibility = 'hidden';   
			  				//var allscript = obj.getElementsByTagName('script');
						    //for(var i=0;i< allscript.length;i++){
								//window.eval(allscript[i].text);
							//}
							//DEBUT MODIFICATION DE REDIRECTION
							document.location = "../../public/pages/remerciement_devis.aspx?id_devis="+id_devis; 
							//document.location = "../../public/pages/remerciement_devis.aspx"; 
			  			}
			  			else{
			  				// affichage si page trouvee
			  				//alert("Service non disponible.");
			  				document.write("Service non disponible.");		  					  				
			  			}		  			 
			  		} 
				} 
			}
			//else{alert("Service non disponible.");}	
			else{document.write("Service non disponible.");}
		}
	catch (e){
		//alert("Service non disponible");
		document.write("Service non disponible.");
		}	
}

// para aleatoire pour forcer l'appel
function GetRandParam(){
	var id_appel=Math.round(Math.random(0)*2000000)+1;	
	if (cur_appel==id_appel){Math.round(Math.random(0)*2000000)+1;}else{cur_appel=id_appel;}
	return id_appel
}

// identification client
function GCDevis_ident(){
	/*var msg=GC_VerifIdentification();
	if (!msg==""){
		try{var obj=document.getElementById("GC_DEVIS_FRM_ALERTE");obj.innerHTML=msg;}
		catch (e){alert(msg);}	
	}	
	else{		
		var log=document.forms[0].GCDevis_login.value;
		var mdp=document.forms[0].GCDevis_mdp.value;			
		var pg_dst="../../commun/prg/devis.aspx?action=200&log="+log+"&mdp="+mdp+"&na="+GetRandParam();
		GC_LoadConfirmSaveDevis(pg_dst);
	}*/
    if (document.getElementById('items'))
	    document.getElementById('items').innerHTML = "";
	
	if(document.getElementById('GCDevis_login').value != '' && document.getElementById('GCDevis_mdp').value != ''){
		document.getElementById('rapport_identification').style.display = 'none';
		//document.getElementById('DIV_FORMULAIRE_DE_COORDONNEES').style.display = 'block';
		var log = document.getElementById('GCDevis_login').value;
		var mdp = document.getElementById('GCDevis_mdp').value;
		if (document.getElementById("OffreDec")) {
		    if (document.getElementById("OffreDec").value == "OffreDec")
		        var pg_dst = "../../commun/prg/devis.aspx?action=200&log=" + log + "&mdp=" + mdp + "&code=OffreDec&na=" + GetRandParam();
		    else if (document.getElementById("CodePromotionnel"))
		        var pg_dst = "../../commun/prg/devis.aspx?action=200&log=" + log + "&mdp=" + mdp + "&na=" + GetRandParam() + "&code=" + document.getElementById("CodePromotionnel").value;
		    else
		        var pg_dst = "../../commun/prg/devis.aspx?action=200&log=" + log + "&mdp=" + mdp + "&na=" + GetRandParam();
		}
		else if (document.getElementById("CodePromotionnel")) 
		        var pg_dst = "../../commun/prg/devis.aspx?action=200&log=" + log + "&mdp=" + mdp+ "&na=" + GetRandParam() + "&code=" + document.getElementById("CodePromotionnel").value ;
		else
		    var pg_dst = "../../commun/prg/devis.aspx?action=200&log=" + log + "&mdp=" + mdp + "&na=" + GetRandParam();
		GC_LoadConfirmSaveDevisIdentification(pg_dst);
	}
	else{
		document.getElementById('rapport_identification').style.display = 'block';
		if(document.getElementById('GCDevis_login').value == ''){
			document.getElementById('items_identification').innerHTML += "- Login<br />";
		}
		if(document.getElementById('GCDevis_mdp').value == ''){
			document.getElementById('items_identification').innerHTML += "- Mot de passe<br />";
		}
	}
	
	
}

function GC_VerifIdentification(){
	if (document.forms[0].GCDevis_login.value == ""){return ("Indiquez votre login");}
	if (document.forms[0].GCDevis_mdp.value == ""){return ("Indiquez votre mot de passe");}
	return "";
}


//DEBUT MODIFICATION DE IDENTIFICATION
/*function GCDevis_Identification(){
	var msg=GC_VerificationIdentification();
	if (!msg==""){
		try{var obj=document.getElementById("GC_DEVIS_FRM_ALERTE");obj.innerHTML=msg;}
		catch (e){alert(msg);}	
	}	
	else{		
		var log=document.forms[0].GCDevis_login.value;
		var mdp=document.forms[0].GCDevis_mdp.value;			
		var pg_dst="../../commun/prg/devis.aspx?action=200&log="+log+"&mdp="+mdp+"&na="+GetRandParam();
		GC_LoadConfirmSaveDevis(pg_dst);
	}
	//MyHtml+="<div align='center' id='GC_Identification' style='display:none;'>"
	//MyHtml+="Champs obligatoires :<br />" 
	//MyHtml+="<div id='items_identification' class='pink'></div>"
	//MyHtml+="</div>"
}*/

function GC_VerificationIdentification(){
	if (document.forms[0].GCDevis_login.value == ""){return ("Indiquez votre login");}
	if (document.forms[0].GCDevis_mdp.value == ""){return ("Indiquez votre mot de passe");}
	return "";
}
//FIN MODIFICATION DE IDENTIFICATION


//DEBUT MODIFICATION RECAPITULATIF DEVIS
function GC_GetRecapDevis(isRappel)
{
	//clear error and result
	//GC_DevisClearDiv();
	var obj=document.getElementById("GC_HELP");
	if(obj){obj.innerHTML="";}
	obj=document.getElementById("GC_DEVIS_ALERTE");
	if(obj){obj.innerHTML="";}
		
	// init parametres
	var pg_dst="";
	var idpr=0;
	var ndog=0;
	var ncat=0;
	var nron=0;
	var nday=1;
	var ddeb="";
	var dend="";
	if (document.getElementById("CodePromotionnel"))
	    var code = document.getElementById("CodePromotionnel").value;
	var src=2;
	if (isRappel) src=1;
	else src = 2;
	// verif saisies
	var msg=GC_VerifDevis()
	if (!msg==""){GC_ShowErreur(msg);}	
	else{
		
		// set variables
		idpr = document.forms[0].GCDevis_idpr.value;
		ndog = document.forms[0].GCDevis_ndog.value;
		ncat = document.forms[0].GCDevis_ncat.value;
		//nron = document.forms[0].GCDevis_nron.value;
		nday = document.forms[0].GCDevis_nday.value;
		ddeb = document.forms[0].GCDevis_ddeb.value;
		dend = document.forms[0].GCDevis_dend.value;
		//alert(GetNbDays(ddeb,dend));
		// si code postal présent  		
		var cp=0;
		var ville="";	
		if (document.forms[0].code_postal){if (VerifCodePostal(document.forms[0].code_postal.value)==true){cp=document.forms[0].code_postal.value;}}
		if (document.forms[0].commune){ville=document.forms[0].commune.value;}	
		
		
		//DEBUT MODIFICATION COORDONNEES VILLE
		var ListeCommunes = document.getElementById("id_commune");
		var LatitudeVille = 0;
		var LongitudeVille = 0;
		if(ListeCommunes){
			LatitudeVille = ListeCommunes.options[ListeCommunes.selectedIndex].getAttribute('lat'); 
			LongitudeVille = ListeCommunes.options[ListeCommunes.selectedIndex].getAttribute('lng');
		}
		else{
			LatitudeVille = document.forms[0].commune.getAttribute('lat'); 
			LongitudeVille = document.forms[0].commune.getAttribute('lng');
		}
		//FIN MODIFICATION COORDONNEES GOOGLEDEVIS
		if (document.getElementsByName("chkTarif")) {
		    var chktarif = document.getElementsByName("chkTarif");
            if (chktarif[1])
		    if (chktarif[1].checked)
		        code = "OffreDec";
		}
		// call tarif
		pg_dst = "../../commun/prg/devis.aspx?idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&cp=" + cp + "&v=" + ville.replace("'", "") + "&tdevis=" + src + "&latitude=" + LatitudeVille + "&longitude=" + LongitudeVille + "&code=" + code + "&na=" + GetRandParam();
		// si espace client et div temoignage existe, chargement temoignage
		if (document.getElementById("GC_temoignage")){			
			try{
				document.getElementById("GC_temoignage").innerHTML="";
				Get_GMTemoignage(Get_GMTemoignagePage());}
			catch (e){}			
		}
		
	}
	
	//document.location.href = pg_dst;

	var xhr_object = null; 	
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	GC_ShowErreur("Service non supporte par votre navigateur"); 
	} 	
 	try	
		{						
			var obj=document.getElementById("GC_DEVIS_RECAP");
			obj.innerHTML="";			
			xhr_object.open("GET", pg_dst , true);  
			xhr_object.onreadystatechange = function() { 
		  		if(xhr_object.readyState == 4) {	
		  			if(xhr_object.status==200){
		  				obj.innerHTML=xhr_object.responseText;
		  				//document.write(xhr_object.responseText);
		  				//document.getElementById("GC_DEVIS").style.display='block'; 
		  				//document.getElementById("GC_DEVIS").style.visibility='visible'; 
		  				obj.style.display='block';		  				
		  				obj.style.visibility='visible';
		  				document.getElementById("GC_SIMU_DEVIS").style.display='none';
		  				document.getElementById("GC_SIMU_DEVIS").style.visibility='hidden';
		  				scrolldown(false);
		  				if (isRappel)
		  				    document.getElementById("lblTitreRecap").innerHTML="Demande de rappel";
		  				else document.getElementById("lblTitreRecap").innerHTML="R&eacute;capitulatif de votre devis";
		  			}
		  			else{
		  				// affichage si page trouvee
		  				GC_ShowErreur("Service non disponible.");		  					  				
		  				//document.write("Service non disponible.");
		  			}		  			 
		  		} 
			} 
			xhr_object.send(null);			
		}
	catch (e){
		//alert("Erreur");
		document.write("Erreur");
	}
}
//FIN MODIFICATION RECAPITULATIF DEVIS

//DEBUT MODIFICATION REMERCIEMENT DEVIS
function GC_REMERCIEMENT_DEVIS(){

    //VERIFICATION CHAMP
    document.getElementById('items').innerHTML = "";
	
	
    var DemandeClient = "";
    var CiviliteClient = "";
    var LaSelection = "";
    DemandeClient = document.getElementById('DemandeClient'); 
	
	
    if(DemandeClient){
	    CiviliteClient=document.getElementById('civilite');
	    LaSelection=document.getElementById('civilite').value;
    }
    else{
	    CiviliteClient = document.getElementById('civilite');
	    LaSelection=CiviliteClient.options[CiviliteClient.selectedIndex].value;
    }
	
	
    if(LaSelection!=0 && document.getElementById('nom').value != "" && (DemandeClient || (document.getElementById('telephone').value != "" && valid_tel(document.getElementById('telephone')))) && valid_mail(document.getElementById('email'))){
	
	    //DEBUT MODIFICATION ENREGISTREMENT DEVIS
	    var c=LaSelection;
	    var id_client=document.getElementById('champ_id_client').value;
	    //var id_client = "";
	    var n=document.getElementById('nom').value;
	    var p=document.getElementById('prenom').value;
	    var t=document.getElementById('telephone').value;
	    var e=document.getElementById('email').value;
	    var comments=document.getElementById('commentaire').value;
	    var idpr=document.getElementById('champ_idpr').value;
	    var tdevis=document.getElementById('champ_tdevis').value;
	    var ndog=document.getElementById('champ_chien').value;
	    var ncat=document.getElementById('champ_chat').value;
	    var nron=0;
	    var nday=document.getElementById('champ_jour').value;
	    var ddeb=document.getElementById('champ_date_de_debut').value;
	    var dend=document.getElementById('champ_date_de_fin').value;
	    var cp=document.getElementById('champ_code_de_postal').value;
	    var ville=document.getElementById('champ_commune').value;
	    if (document.getElementById('champ_identifiant_de_offre'))
	        var code=document.getElementById('champ_identifiant_de_offre').value;
		
		if (tdevis!=2) {
//      		var id_client = "";
//      		var src="1";
//		    var pg_dst="../../commun/prg/devis.aspx?cp="+cp+"&v="+ville+"&idpr="+idpr+"&ndog="+ndog+"&ncat="+ncat+"&nron="+nron+"&nday="+nday+"&ddeb="+ddeb+"&dend="+dend+"&tdevis="+src+"&client="+id_client+"&na="+GetRandParam();
//        	 	 
//	        var xhr_object = null; 	
//	        if(window.XMLHttpRequest) // Firefox 
//	   	        xhr_object = new XMLHttpRequest(); 
//	        else if(window.ActiveXObject) // Internet Explorer 
//	  	        xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
//	        else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
//	   	        alert("Service non supporte par votre navigateur"); 
//	        } 	
// 	        try	
//		        {						
//			        var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
//			        if (obj){
//				        obj.innerHTML="";			
//				        xhr_object.open("GET", pg_dst , true);  
//				        xhr_object.onreadystatechange = function() { 
//			  		        if(xhr_object.readyState == 4) {	
//			  			        if(xhr_object.status==200){
//			  				        obj.innerHTML=xhr_object.responseText;
//			  				        obj.style.display='block';	
//			  				        obj.style.visibility='visible';	
//			  				        if (obj.innerHTML=="NO_SERVICE"){GC_ShowDivDevis(1);alert("Service non disponible.");}
//			  				        else{GC_ShowDivDevis(2);}
//			  			        }
//			  			        else{
//			  				        // affichage si page trouvee
//			  				        alert("Service non disponible.");		  					  				
//			  			        }		  			 
//			  		        } 
//				        } 
//				        xhr_object.send(null);
//			        }
//			        else{alert("Service non disponible.");}	
//		        }
//	        catch (e){alert("Service non disponible");}	
	        var pg_dst="../../commun/prg/devis.aspx"
	        //var params="action=1&c="+c+"&n="+n+"&p="+p+"&t="+t+"&e="+e+"&com="+comments+"&na="+GetRandParam();
	        var params = "action=4&client=" + id_client + "&c=" + c + "&n=" + n + "&p=" + p + "&t=" + t + "&e=" + e + "&com=" + comments + "&idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&cp=" + cp + "&v=" + ville.replace("'", "") + "&tdevis=1&code=" + code + "&na=" + GetRandParam();
	        //var pg_dst="../../commun/prg/devis.aspx?cp="+cp+"&v="+c+"&idpr="+idpr+"&ndog="+ndog+"&ncat="+ncat+"&nron="+nron+"&nday="+nday+"&ddeb="+ddeb+"&dend="+dend+"&tdevis=1&na="+GetRandParam();
	        GC_LoadConfirmSaveDevis(pg_dst,params);
	        //GC_LoadDivDevis(pg_dst);
        }
        else {
	        var pg_dst="../../commun/prg/devis.aspx"
	        //var params="action=1&c="+c+"&n="+n+"&p="+p+"&t="+t+"&e="+e+"&com="+comments+"&na="+GetRandParam();
	        var params = "action=4&client=" + id_client + "&c=" + c + "&n=" + n + "&p=" + p + "&t=" + t + "&e=" + e + "&com=" + comments + "&idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nron=" + nron + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&cp=" + cp + "&v=" + ville.replace("'", "") + "&tdevis=2&code=" + code + "&na=" + GetRandParam();
	        GC_LoadConfirmSaveDevis(pg_dst,params);
	    }
    }
    else{
	    document.getElementById('rapport').style.display = 'block';
	    if(LaSelection == 0){
		    document.getElementById('items').innerHTML += "- Civilite<br />";
	    }
	    if(document.getElementById('nom').value == ''){
		    document.getElementById('items').innerHTML += "- Nom<br />";
	    }
	    //if(document.getElementById('prenom').value == ''){
	    //	document.getElementById('items').innerHTML += "- Pr&eacute;nom<br />";
	    //}
	    if(document.getElementById('telephone').value == '' || !valid_tel(document.getElementById('telephone'))){
		    document.getElementById('items').innerHTML += "- T&eacute;l&eacute;phone<br />";
	    }
	    if (document.getElementById('email').value == '' || !valid_mail(document.getElementById('email'))) {
		    document.getElementById('items').innerHTML += "- Email<br />";
	    }
	}
}



//FIN MODIFICATION REMERCIEMENT DEVIS

function valid_tel(obj){  //  Vérification validité telephone par REGEXP
		//DEBUT MODIFICATION DE VALID_TEL	
		var regex1 = /^0[1-9]{1}\d{8}$/
		//var regex2 = /^[a-zA-Z0-9._-]{10}$/
		return (regex1.test(obj.value));
		//FIN MODIFICATION DE VALID_TEL		
}

function valid_mail(obj) { // vérif validité email par REGEXP
    var regex1 = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/
   return (regex1.test(obj.value));
}

/*function VerificationDevis() {*/ // DEBUT MODIFICATION VERIFICATION DEVIS
	/*if (document.forms[0].nom.value == ""){return ("Indiquez votre civilite");}
	if (document.forms[0].prenom.value == ""){return ("Indiquez votre nom");}
	if (document.forms[0].telephone.value == ""){return ("Indiquez votre tÃ©lÃ©phone");}
	if (VerifTelephone(document.forms[0].GCDevis_tel.value)==false){return ("TÃ©lÃ©phone non valide (10 chiffres maximum)");}	
	if (!document.forms[0].GCDevis_email.value == "" ){
		if (VerifAdresseEmail(document.forms[0].GCDevis_email.value)==false){return ("Adresse email incorrecte");}
	}
	return "";
}*/
// DEBUT MODIFICATION VERIFICATION DEVIS

function GC_IDENTIFICATION_DEVIS(){
	document.getElementById('DIV_FORMULAIRE_DE_COORDONNEES').style.display = 'none';
	document.getElementById('DIV_FORMULAIRE_DE_IDENTIFICATION').style.display = 'block';	
	//document.getElementById("GCDevis_login").Focus();
}

function NombreDS(){
var obj = document.getElementById("AffichageNombre");
var Nombre = document.getElementById("GC_DS_NOMBRE").value;
if(Nombre == 0){
	obj.innerHTML = "<p class=center style=padding:1px;font-family:arial;font-weight:bold;font-size:10px; color:gray >Il n'y a aucun dog sitter</p>";
}
else{
	obj.innerHTML = "<p class=center style=padding:1px;font-family:arial;font-weight:bold;font-size:10px; color:gray >Il y a " + Nombre + " familles d'accueil dans un rayon de 50 km autre de votre domicile. Cette information est &agrave; titre purement indicative, elle ne prend pas en compte les disponibilit&eacute;s.</p>";
}


}

//DEBUT MODIFICATION PRE-REMPLIR DEVIS
function GC_GetDeCodePostal(){
	var code_postal = document.forms[0].code_postal.value;
	var ville = document.forms[0].commune.value;
	
	
	//DEBUT MODIFICATION COORDONNEES GOOGLEDEVIS
	var LatitudeCommune = document.getElementById("LatitudeVille");
	var LongitudeCommune = document.getElementById("LongitudeVille");
	var ListeCommunes = document.getElementById("id_commune");
		  				 
	if(ListeCommunes){
		LatitudeCommune.value = ListeCommunes.options[ListeCommunes.selectedIndex].getAttribute('lat'); 
		LongitudeCommune.value = ListeCommunes.options[ListeCommunes.selectedIndex].getAttribute('lng');
	}
	else{
		LatitudeCommune.value = document.forms[0].commune.getAttribute('lat'); 
		LongitudeCommune.value = document.forms[0].commune.getAttribute('lng');
	}
	//FIN MODIFICATION COORDONNEES GOOGLEDEVIS
	
	
	document.location = "../../public/pages/devis.aspx?code_postal="+code_postal+"&ville="+ville+"&latitude="+LatitudeCommune.value+"&longitude="+LongitudeCommune.value;
	
	
}
//FIN MODIFICATION PRE-REMPLIR DEVIS


//DEBUT MODIFICATION CONFIRMATION IDENTIFICATION
function GC_LoadConfirmSaveDevisIdentification(pg_dst,params){		
	var xhr_object = null; 	
	//var id_devis = 0;
	if(window.XMLHttpRequest) // Firefox 
	   	xhr_object = new XMLHttpRequest(); 
	else if(window.ActiveXObject) // Internet Explorer 
	  	xhr_object = new ActiveXObject("Microsoft.XMLHTTP"); 
	else { // XMLHttpRequest non supporté par le navigateur renvoie false pour ouvrir une fenetre	   	
	   	alert("Service non supporte par votre navigateur"); 
	} 	
 	try	
		{						
			var obj=document.getElementById("GC_FRM_SAVE_DEVIS");
			if (obj){
				obj.innerHTML="";			
				xhr_object.open("POST", pg_dst , true); 
				xhr_object.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 
				xhr_object.send(params);
				xhr_object.onreadystatechange = function() { 
			  		if(xhr_object.readyState == 4) {	
			  			if(xhr_object.status==200){
			  				//id_devis = document.getElementById('identifiant_devis').value;
			  				// modif Arnaud le 04/12/2008
						    // maintenant que les donnees reçues on ete placees dans la page,
						    // il faut executer toutes les balises script :   
			  				document.getElementById('GC_DEVIS_RECAP').style.display = 'none';  
			  				//document.getElementById('GC_DEVIS_RECAP').style.visibility = 'hidden';
			  				//alert(document.getElementById('DIV_FORMULAIRE_DE_COORDONNEES').style.display + " " + document.getElementById('DIV_FORMULAIRE_DE_COORDONNEES').style.visibility);
			  				document.getElementById('DIV_FORMULAIRE_DE_COORDONNEES').style.display = 'none';
							document.getElementById('DIV_FORMULAIRE_DE_IDENTIFICATION').style.display = 'none';   
			  				obj.innerHTML=xhr_object.responseText;
			  				var allscript = obj.getElementsByTagName('script');
						    for(var i=0;i< allscript.length;i++){
								window.eval(allscript[i].text);
							}
			  			}
			  			else{
			  				// affichage si page trouvee
			  				//alert("Service non disponible.");
			  				document.write("Service non disponible.");		  					  				
			  			}		  			 
			  		} 
				} 
			}
			//else{alert("Service non disponible.");}	
			else{document.write("Service non disponible.");}
		}
	catch (e){
		//alert("Service non disponible");
		document.write("Service non disponible.");
		}	
}
//FIN MODIFICATION CONFIRMATION IDENTIFICATION


//DEBUT MODIFICATION DEMANDE MODIFICATION
function ModificationDemande(){
	var idpr=document.getElementById('champ_idpr').value;
	var ndog=document.getElementById('champ_chien').value;
	var ncat=document.getElementById('champ_chat').value;
	var nday=document.getElementById('champ_jour').value;
	var ddeb=document.getElementById('champ_date_de_debut').value;
	var dend=document.getElementById('champ_date_de_fin').value;
	var cp=document.getElementById('champ_code_de_postal').value;
	var ville=document.getElementById('champ_commune').value;   
	var demande=document.getElementById('champ_demande').value;
	var latitude=document.getElementById('champ_latitude').value;
	var longitude=document.getElementById('champ_longitude').value;
	//var tdevis=document.getElementById('champ_tdevis').value;

	document.location = "../../public/pages/devis.aspx?idpr=" + idpr + "&ndog=" + ndog + "&ncat=" + ncat + "&nday=" + nday + "&ddeb=" + ddeb + "&dend=" + dend + "&code_postal=" + cp + "&ville=" + ville.replace("'", "") + "&latitude=" + latitude + "&longitude=" + longitude + "&demande=" + demande; 	
	
	
}
//FIN MODIFICATION DEMANDE MODIFICATION


//DEBUT MODIFICATION PRE-REMPLIR FORMULAIRE DEVIS
function ModificationFormulaireDeDevis(str){

var Document=String(document.location);
var Signet="";
var n1 = Document.indexOf("?");


//document.write(Document);


if(n1>0){
	var n2 = Document.indexOf("?" + str + "=", n1);
	
	if(n2 < n1){
		n2 = Document.indexOf("&" + str + "=", n1); 
	}
	
	if(n2 >= n1){
		n2 = n2 + ("?" + str + "=").length;
		var n3 = Document.indexOf("&", n2+1);
		
		if(n3 > n2){
			Signet = Document.substring(n2, n3);
		}
		else{
			Signet = Document.substring(n2);
		}
		
	}

}	
	
return Signet;	
		 
}
//FIN MODIFICATION PRE-REMPLIR FORMULAIRE DEVIS


//DEBUT MODIFICATION AFFICHAGE RESULTAT
function AffichageFormulaire(){


var TypeService=ModificationFormulaireDeDevis("idpr");
var NombreChien=ModificationFormulaireDeDevis("ndog");
var NombreChat=ModificationFormulaireDeDevis("ncat");
var NombreJours=ModificationFormulaireDeDevis("nday");
var DateDebut=ModificationFormulaireDeDevis("ddeb");
var DateFin=ModificationFormulaireDeDevis("dend");
var Commune=ModificationFormulaireDeDevis("ville");


//DEBUT MODIFICATION AFFICHAGE SERVICE
var ObjetService = document.getElementById("GCDevis_idpr");
if(ObjetService){
	for (i = 0 ; i < ObjetService.options.length ; i++){
		if(ObjetService.options[i].value == TypeService){
		ObjetService.options[i].selected = true;
		break;
		}
	}
}
//FIN MODIFICATION AFFICHAGE SERVICE


//DEBUT MODIFICATION AFFICHAGE CHIEN
var ObjetChien = document.getElementById("GCDevis_ndog");
if(ObjetChien){
	for (i = 0 ; i < ObjetChien.options.length ; i++){
		if(ObjetChien.options[i].value == NombreChien){
		ObjetChien.options[i].selected = true;
		break;
		}
	}
}
//FIN MODIFICATION AFFICHAGE CHIEN


//DEBUT MODIFICATION AFFICHAGE CHAT
var ObjetChat = document.getElementById("GCDevis_ncat");
if(ObjetChat){
	for (i = 0 ; i < ObjetChat.options.length ; i++){
		if(ObjetChat.options[i].value == NombreChat){
		ObjetChat.options[i].selected = true;
		break;
		}
	}
}
//FIN MODIFICATION AFFICHAGE CHAT


//DEBUT MODIFICATION AFFICHAGE DUREE
var ObjetDuree = document.getElementById("GCDevis_nday");
if(ObjetDuree){
	for (i = 0 ; i < ObjetDuree.options.length ; i++){
		if(ObjetDuree.options[i].value == NombreJours){
		ObjetDuree.options[i].selected = true;
		break;
		}
	}
}
//FIN MODIFICATION AFFICHAGE DUREE


//DEBUT MODIFICATION AFFICHAGE DATE DEBUT
var ObjetDebut = document.getElementById("GCDevis_ddeb");
if(ObjetDebut){
	document.getElementById("GCDevis_ddeb").value = DateDebut; 	
}
//FIN MODIFICATION AFFICHAGE DATE DEBUT


//DEBUT MODIFICATION AFFICHAGE DATE FIN
var ObjetFin = document.getElementById("GCDevis_dend");
if(ObjetFin){
	document.getElementById("GCDevis_dend").value = DateFin; 	
}
//FIN MODIFICATION AFFICHAGE DATE FIN


//DEBUT MODIFICATION AFFICHAGE COMMUNE
var ObjetCommune = document.getElementById("id_commune");
if(ObjetCommune){
	for (i = 0 ; i < ObjetCommune.options.length ; i++){
		if(ObjetCommune.options[i].value == Commune){
		ObjetCommune.options[i].selected = true;
		break;
		}
	}
}


}
//FIN MODIFICATION AFFICHAGE RESULTAT


//DEBUT FONCTION AFFICHAGE NAVIGATEUR
function AffichageLigne(){
  var rv = -1; 
  
  //NOM NAVIGATEUR - MICROSOFT INTERNET EXPLORER
  if (navigator.appName == 'Microsoft Internet Explorer'){
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if(re.exec(ua) != null){
      rv = parseFloat( RegExp.$1 );
    }
  } 
 
  
  //INTERNET EXPLORER VERSION 8 - MODIFICATION AFFICHAGE DIV AFFICHAGE_LIGNE_IE_8
  if(rv == 8){
	document.getElementById("affichage_ligne_IE_7").style.display = "none";
	document.getElementById("affichage_ligne_IE_8").style.display = "block";
	document.getElementById("affichage_ligne_de_OPERA").style.display = "none";
  }
  //INTERNET EXPLORER VERSION 7 - MODIFICATION AFFICHAGE DIV AFFICHAGE_LIGNE_IE_7 
  else if(rv == 7){
	document.getElementById("affichage_ligne_IE_7").style.display = "block";
	document.getElementById("affichage_ligne_IE_8").style.display = "none";
	document.getElementById("affichage_ligne_de_OPERA").style.display = "none";
  }
  //NAVIGATEUR OPERA - MODIFICATION AFFICHAGE BALISE DIV AFFICHAGE_LIGNE_DE_OPERA
  else{
	document.getElementById("affichage_ligne_IE_7").style.display = "none";
	document.getElementById("affichage_ligne_IE_8").style.display = "none";
	document.getElementById("affichage_ligne_de_OPERA").style.display = "block";
  }
}
//FIN FONCTION AFFICHAGE NAVIGATEUR


//DEBUT DE FONCTION SETDATE - FONCTION AJOUT DE SLASH
function SetDate(obj)
{
    if (obj.value.length == 2 || obj.value.length == 5) { obj.value = obj.value + '/'; }
    obj.value = obj.value.replace("//", "/");	
}
//FIN DE FONCTION SETDATE - FONCTION AJOUT DE SLASH


