$(document).ready(function() { 
	$(".fancy_img").fancybox();
});
	
	
function jsoncallback_load(data) {
	$('#'+data.cible).html(data.source);
}

//Détection compatibilité navigateurs
function ieversion() {
  $match=preg_match('/MSIE ([0-9]\.[0-9])/',$_SERVER['HTTP_USER_AGENT'],$reg);
  if($match==0)
    return -1;
  else
    return floatval($reg[1]);
}

function load_form(loading){
	//données du formulaire
	data = "";
	if($("select[name='agence']").val()) data += "agence="+$("select[name='agence']").val();
	else data += "agence="+$("input[name='agence']").val();
	data += "&widget_id="+$("input[name='widget_id']").val()+"&admin_etat="+$("input[name='admin_etat']").val()+"&admin_reservation="+$("input[name='admin_reservation']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&heure_depart="+$("select[name='heure_depart']").val()+"&heure_retour="+$("select[name='heure_retour']").val()+"&date_depart="+$("input[name='date_depart']").val()+"&date_retour="+$("input[name='date_retour']").val()+"&km_estimes="+$("input[name='km_estimes']").val();
	if($("input[name='la_version']").val()=="express") data += "&version="+$("input[name='la_version']").val();
	if(loading=="php"){
		$.getJSON("http://www.rentit.fr/get_json.php?module=reservation&appel=ajax&loading="+loading+"&"+data + "&cible=reservation_form&callback=?");
	}
	else{
		var xhr = getXhr()
	  xhr.open("GET","get.php?module=reservation&appel=ajax&"+data ,false);
		xhr.send(null);
		if(document.getElementById('reservation_form_express')){//MAJ reservation express
			document.getElementById('reservation_form_express').innerHTML = xhr.responseText;
			affiche_reservation('reservation_form_express');
		}
		else{//MAJ reservation standard
			document.getElementById('reservation_form').innerHTML = xhr.responseText;
			affiche_reservation('reservation_form');
			window.scrollTo(0, $('#reservation').position().top);
		}
	}
	
}

function load_tarif(){
	//données du formulaire
	data = "etape=2";
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	if($("select[name='vehicule']").val()) data += "&vehicule="+$("select[name='vehicule']").val();
	else data += "&vehicule="+$("input[name='vehicule']").val();
	if($("select[name='agence_retour']").val()) data += "&agence_retour="+$("select[name='agence_retour']").val();
	else data += "&agence_retour="+$("input[name='agence_retour']").val();
	data += "&famille="+$("input[name='famille']").val();
	data += "&widget_id="+$("input[name='widget_id']").val()+"&admin_etat="+$("input[name='admin_etat']").val()+"&admin_reservation="+$("input[name='admin_reservation']").val()+"&promotion="+$("input[name='promotion']").val()+"&heure_depart="+$("select[name='heure_depart']").val()+"&heure_retour="+$("select[name='heure_retour']").val()+"&date_depart="+$("input[name='date_depart']").val()+"&date_retour="+$("input[name='date_retour']").val()+"&km_estimes="+$("input[name='km_estimes']").val();
	if($("input[name='admin_reservation_options']").val()) data += "&"+$("input[name='admin_reservation_options']").val();
	data += "&referer="+location.href;
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","get.php?module=reservation&appel=ajax&"+data ,false);
	xhr.send(null);
	if(($("input[name='vehicule']").val()!="" && $("input[name='vehicule']").val()) || ($("select[name='vehicule']").val()!="" && $("select[name='vehicule']").val()) || $("input[name='promotion']").val()!=""){
		document.getElementById('reservation_forfait').innerHTML = xhr.responseText;
		affiche_reservation('reservation_forfait');
	}
	else{
		document.getElementById('reservation_famille').innerHTML = xhr.responseText;
		affiche_reservation('reservation_famille');
	}
	
	window.scrollTo(0, $('#reservation').position().top);
	$('a.lightbox').lightBox();
}

function refresh_tarif(action){
	//données du formulaire
	data = "etape=2&widget_id="+$("input[name='widget_id']").val()+"&admin_etat="+$("input[name='admin_etat']").val()+"&admin_reservation="+$("input[name='admin_reservation']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&heure_depart="+$("input[name='heure_depart']").val()+"&heure_retour="+$("input[name='heure_retour']").val()+"&date_depart="+$("input[name='date_depart_str']").val()+"&date_retour="+$("input[name='date_retour_str']").val()+"&km_estimes="+$("input[name='km_estimes']").val();
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	if($("select[name='agence_retour']").val()) data += "&agence_retour="+$("select[name='agence_retour']").val();
	else data += "&agence_retour="+$("input[name='agence_retour']").val();
	//ajout des options de type select
	$('select[name*="OPTION_"]').each(function(index) {
    data += "&"+$(this).attr('name')+"="+$(this).val();
  });
	//ajout des options de type input
	$('input[name*="OPTION_"]').each(function(index) {
    data += "&"+$(this).attr('name')+"="+$(this).val();
  });
	data += "&referer="+location.href;
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","get.php?module=reservation&appel=ajax&"+data ,false);
	xhr.send(null);
	document.getElementById('reservation_forfait').innerHTML = xhr.responseText;
	affiche_reservation('reservation_forfait');
	window.scrollTo(0, $('#reservation').position().top);
}

function get_tarif_date(domaine,jour_deb,jour_fin,km_estimes,cat,options_ht,le_type,remise,id_stat,html_erreur){
	options_ht = parseFloat(options_ht);
	reduction=1;
	if(remise!=0) reduction=1-parseFloat(remise/100);
	var xhr = getXhr()
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function(){
		// Si on a tout reçu et que le serveur est ok
		if(xhr.readyState == 4 && xhr.status == 200){
			if(xhr.responseText!=''){
				result = xhr.responseText.split('@@');
				if(result.length>1){
					//MAJ des INPUT
					if(result[2]>km_estimes) $("input[name='km']").val(result[2]);
					else $("input[name='km']").val(km_estimes);
					$("input[name='prix_km_sup']").val(result[3]);
					$("input[name='tarif']").val((Math.round((result[0]*reduction+(options_ht )) *100 )/100));
					$("#admin_total_ht").val((Math.round((result[0]*reduction+(options_ht )) *100 )/100));
					
					//MAJ de l'affichage du forfait
					if(document.getElementById('forfait_tarif_ttc')) document.getElementById('forfait_tarif_ttc').innerHTML = (Math.round((result[1]*reduction+(options_ht)*1.196)*100)/100)+"</b> € TTC";
					if(document.getElementById('forfait_tarif_ht')) document.getElementById('forfait_tarif_ht').innerHTML = (Math.round((result[0]*reduction+(options_ht )) *100 )/100)+" € HT";
					if(document.getElementById('forfait_km_compris')){
						if(parseInt(result[2])>parseInt(km_estimes)) document.getElementById('forfait_km_compris').innerHTML = result[2];
						else document.getElementById('forfait_km_compris').innerHTML = km_estimes;
					} 
					if(document.getElementById('forfait_tarif_ht')) document.getElementById('forfait_km_sup_ht').innerHTML = result[3]+" € HT";
					if(document.getElementById('forfait_km_sup_ttc')) document.getElementById('forfait_km_sup_ttc').innerHTML = result[4]+" € TTC";
					
					if(reduction!=1){
						if(document.getElementById('forfait_remise_ht_comptoir')) document.getElementById('forfait_remise_ht_comptoir').innerHTML = (Math.round(((result[0]*1)+(options_ht)) *100 )/100);
						if(document.getElementById('forfait_remise_ht')) document.getElementById('forfait_remise_ht').innerHTML = (Math.round(((result[0]*1)+(options_ht)) *100 )/100)+" € HT";
						if(document.getElementById('forfait_remise_ttc')) document.getElementById('forfait_remise_ttc').innerHTML = (Math.round(((result[1]*1)+((options_ht)*1.196))*100)/100)+" € TTC";
					}
					else{
						$('#forfait_remise_lib').hide();
						$('#forfait_remise_ht').hide();
						$('#forfait_remise_ttc').hide();
					}
					//if(le_type=="PUBLIC WE") document.getElementById('forfait').innerHTML	+= "<li> <B>Forfait week-end</b>";
					$('#forfait_attente').hide();
					$('#forfait_attente_hitech').show();
				}
				else{
					$('#forfait_attente').hide();
					$('#forfait_attente_hitech').html(html_erreur)
					$('#forfait_attente_hitech').show();
				}
			}
			else{
				//Déclassement	??
				$('#forfait_attente').hide();
				$('#forfait_attente_hitech').html(html_erreur)
				$('#forfait_attente_hitech').show();
			}
		} 
	}
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","../actions/soap_tarif_date.php?domaine="+domaine+"&type="+le_type+"&jour_deb="+jour_deb+"&km_estimes="+km_estimes+"&cat="+encodeURI(cat)+"&jour_fin="+jour_fin+"&options_ht="+options_ht+"&remise="+remise+"&id_stat="+id_stat+"&rand="+Math.random()+String.fromCharCode(34),true);
	xhr.send(null);
}

function check_dispo(domaine,jour_deb,jour_fin,agence,cat,promo,paiement_active,id_stat,dispo_actions){
	if(document.getElementById('type_contact_ko'))  document.getElementById('type_contact_ko').checked = true;
	//surclassement & partage de parc
	params_action="";
	action_en_cours=0;
	tab_actions = dispo_actions.split(";");
	if(dispo_actions!=""){
		tab1 = tab_actions[action_en_cours].split("/");
		params_action = "&action_suivante="+tab1[0]+"&action_suivante_id="+tab1[1]+"&action_suivante_type="+tab1[2]+"&action_suivante_montant="+tab1[3];
		//alert(params_action);
	}
	
	var xhr = getXhr()
	// On défini ce qu'on va faire quand on aura la réponse
	xhr.onreadystatechange = function(){
		// Si on a tout reçu et que le serveur est ok
		//alert(xhr.readyState+"/"+xhr.status);
		if(xhr.readyState == 4 && xhr.status == 200){
			//alert(xhr.responseText);
			if(xhr.responseText!='' && xhr.responseText.indexOf("@@")!=-1){
				result = xhr.responseText.split('@@');
				//MAJ des INPUT
				//Type de réponse result[0] : 0=Vehicule dispo normal, 1=Surclassement sans avertir client, 2=Surclassement au meme prix, 3=Surclassement au tarif de la nouvelle catégorie, 4=Surclassement avec surcoût
				if(document.getElementById('notes')){ //sauvegarde action spéciale (surclassement partage de parc)
					if(result[0].indexOf("@")!=-1){
						temp = result[0].split('@');
						document.getElementById('notes').value = temp[0];	//Libellé action speciale
						if(document.getElementById('flags')) document.getElementById('flags').value = temp[1];	//sauvegarde_id correspondant au surclassement
					}
					else document.getElementById('notes').value = result[0];	
				}
				if(document.getElementById('modele_prefere')) document.getElementById('modele_prefere').value = result[1];
				if(document.getElementById('modele_immat')) document.getElementById('modele_immat').value = result[2];
				if(document.getElementById('disponibilites')) document.getElementById('disponibilites').innerHTML=result[3];
				if(paiement_active==1){//maj bouton de réservation
					if(document.getElementById('forfait_action_reservation')) document.getElementById('forfait_action_reservation').style.display = 'none';
					if(document.getElementById('forfait_action_paiement')) document.getElementById('forfait_action_paiement').style.display = 'block';
				}
				else{
					if(document.getElementById('forfait_action_reservation')) document.getElementById('forfait_action_reservation').style.display = 'none';
					if(document.getElementById('forfait_action_paiement')) document.getElementById('forfait_action_no_paiement').style.display = 'block';
				}
				$('.video_r21').show();
			}
			else{
				//PAS DE DISPONIBILITES	
				//SI ACTION SUIVANTE on poursuit sinon affichage erreur
				//alert(dispo_actions+"/"+action_en_cours+"/"+tab_actions.length);
				if(dispo_actions!="" && (action_en_cours+1)<tab_actions.length){
					//recupération des parametres de l'action suivante
					//alert(action_en_cours+tab_actions.length+tab_actions[action_en_cours]);
					tab1 = tab_actions[action_en_cours].split("/");
					
					//alert(tab1[0]);
					if(tab1[0]=="surclassement"){ //appel de soap dispo sur la catégorie suivante
						params_action = "&action_suivante="+tab1[0]+"&action_suivante_id="+tab1[1]+"&action_suivante_type="+tab1[2]+"&action_suivante_montant="+tab1[3];
						action_en_cours=action_en_cours+1;
						
						//alert("actions/soap_dispo.php?domaine="+domaine+"&agence="+agence+"&jour_deb="+encodeURI(jour_deb)+"&jour_fin="+encodeURI(jour_fin)+"&cat="+cat+"&promo="+promo+"&id_stat="+id_stat+params_action+"&rand="+Math.random()+String.fromCharCode(34));
						//appel de l'action suivante
						xhr.open("GET","actions/soap_dispo.php?domaine="+domaine+"&agence="+agence+"&jour_deb="+encodeURI(jour_deb)+"&jour_fin="+encodeURI(jour_fin)+"&cat="+cat+"&promo="+promo+"&id_stat="+id_stat+params_action+"&rand="+Math.random()+String.fromCharCode(34) ,true);
						xhr.send(null);
					}
					else if(tab1[0]=="surbooking"){ //fin acceptation reservation sans immat
						if(document.getElementById('notes')) document.getElementById('notes').value = "surbooking";
						if(document.getElementById('modele_immat')) document.getElementById('modele_immat').value = result[2];
						if(document.getElementById('disponibilites')) document.getElementById('disponibilites').innerHTML="Véhicule disponible";
						if(paiement_active==1){//maj bouton de réservation
							if(document.getElementById('forfait_action_reservation')) document.getElementById('forfait_action_reservation').style.display = 'none';
							if(document.getElementById('forfait_action_paiement')) document.getElementById('forfait_action_paiement').style.display = 'block';
						}
						else{
							if(document.getElementById('forfait_action_reservation')) document.getElementById('forfait_action_reservation').style.display = 'none';
							if(document.getElementById('forfait_action_paiement')) document.getElementById('forfait_action_no_paiement').style.display = 'block';
						}
					}
				}
				else{
					//if(document.getElementById('disponibilites')) document.getElementById('disponibilites').innerHTML= "<div class='dispo_ko'>Aucun véhicule n'est disponible</div>";
					$('#disponibilites').hide();
					$('.dispo_ko').fadeIn();
					if(document.getElementById('forfait_action_reservation')) document.getElementById('forfait_action_reservation').style.display = 'block';
					$('.video_r22').show();
				}
			}
			$('#forfait_action_disponibilite').hide();
				
		} 
	}
	
	xhr.open("GET","actions/soap_dispo.php?domaine="+domaine+"&agence="+agence+"&jour_deb="+encodeURI(jour_deb)+"&jour_fin="+encodeURI(jour_fin)+"&cat="+cat+"&promo="+promo+"&id_stat="+id_stat+"&rand="+Math.random()+String.fromCharCode(34) ,true);
	xhr.send(null);
}		

function rappel_client_valider(page){
	//données du formulaire
	data = "tel="+$("input[name='tel']").val()+"&nom="+$("input[name='nom']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&date_depart="+$("input[name='date_depart_unix']").val()+"&date_retour="+$("input[name='date_retour_unix']").val()+"&prix_forfait="+$("input[name='tarif']").val()+"";
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	data += "&page="+page;
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","actions/rappel_client.php?appel=ajax&"+data ,false);
	xhr.send(null);
	document.getElementById('rappel_form').innerHTML = xhr.responseText;
	executeJS(document.body);
}

function load_client(action){
	//données du formulaire
	data = "etape=3&widget_id="+$("input[name='widget_id']").val()+"&action_resa="+action+"&options="+$("input[name='options']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&type_calcul="+$("input[name='type_calcul']").val()+"&date_depart="+$("input[name='date_depart_unix']").val()+"&date_retour="+$("input[name='date_retour_unix']").val()+"&nb_jour="+$("input[name='nb_jour']").val()+"&km="+$("input[name='km']").val()+"&franchise="+$("input[name='franchise']").val()+"&prix_km_sup="+$("input[name='prix_km_sup']").val()+"&prix_forfait="+$("input[name='prix_forfait']").val()+"&prix_km_factures="+$("input[name='prix_km_factures']").val()+"&prix_options="+$("input[name='prix_options']").val()+"&prix_variation="+$("input[name='prix_variation']").val()+"&prix_total="+$("input[name='prix_total']").val()+"&modele_prefere="+$("input[name='modele_prefere']").val()+"&immatriculation="+$("input[name='immatriculation']").val()+"&id_stat="+$("input[name='id_stat']").val()+"";
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	if(action=="reservation" && document.getElementById('forfait_remise_ht_comptoir')&& document.getElementById('forfait_remise_ht_comptoir').innerHTML!="") 
		data += "&tarif="+document.getElementById('forfait_remise_ht_comptoir').innerHTML;
	else data += "&tarif="+$("input[name='tarif']").val();
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","get.php?module=reservation&appel=ajax&"+data ,false);
	xhr.send(null);
	document.getElementById('reservation_client').innerHTML = xhr.responseText;
	affiche_reservation('reservation_client');
	window.scrollTo(0, $('#reservation').position().top);
}

function admin_modif_reservation(){
	//Modification réservation partie admin
	//données du formulaire
	data = "&admin_reservation="+$("input[name='admin_reservation']").val()+"&admin_total="+$("input[name='admin_total']").val()+"&admin_etat="+$("select[name='admin_etat']").val()+"&options="+$("input[name='options']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&type_calcul="+"&tarif="+$("input[name='tarif']").val()+"&type_calcul="+$("input[name='type_calcul']").val()+"&date_depart="+$("input[name='date_depart_unix']").val()+"&date_retour="+$("input[name='date_retour_unix']").val()+"&nb_jour="+$("input[name='nb_jour']").val()+"&km="+$("input[name='km']").val()+"&franchise="+$("input[name='franchise']").val()+"&prix_km_sup="+$("input[name='prix_km_sup']").val()+"&prix_forfait="+$("input[name='prix_forfait']").val()+"&prix_km_factures="+$("input[name='prix_km_factures']").val()+"&prix_options="+$("input[name='prix_options']").val()+"&prix_variation="+$("input[name='prix_variation']").val()+"&prix_total="+$("input[name='prix_total']").val()+"&modele_prefere="+$("input[name='modele_prefere']").val()+"&immatriculation="+$("input[name='immatriculation']").val()+"&id_stat="+$("input[name='id_stat']").val()+"";
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	var xhr = getXhr();
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","actions/reservation_update.php?"+data ,false);
	xhr.send(null);
	document.getElementById('reservation_forfait').innerHTML = xhr.responseText;
	window.scrollTo(0, $('#reservation').position().top);
}

function connexion_client(){
	//données du formulaire
	data = "etape=3&widget_id="+$("input[name='widget_id']").val()+"&client_mail="+$("input[name='client_mail']").val()+"&action_resa="+$("input[name='action_resa']").val()+"&options="+$("input[name='options']").val()+"&client_password="+$("input[name='client_password']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&type_calcul="+$("input[name='type_calcul']").val()+"&tarif="+$("input[name='tarif']").val()+"&"+$("input[name='type_calcul']").val()+"&date_depart="+$("input[name='date_depart']").val()+"&date_retour="+$("input[name='date_retour']").val()+"&nb_jour="+$("input[name='nb_jour']").val()+"&km="+$("input[name='km']").val()+"&franchise="+$("input[name='franchise']").val()+"&prix_km_sup="+$("input[name='prix_km_sup']").val()+"&prix_forfait="+$("input[name='prix_forfait']").val()+"&prix_km_factures="+$("input[name='prix_km_factures']").val()+"&prix_options="+$("input[name='prix_options']").val()+"&prix_variation="+$("input[name='prix_variation']").val()+"&prix_total="+$("input[name='prix_total']").val()+"&modele_prefere="+$("input[name='modele_prefere']").val()+"&immatriculation="+$("input[name='immatriculation']").val()+"&id_stat="+$("input[name='id_stat']").val()+"";
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("GET","get.php?module=reservation&appel=ajax&"+data ,false);
	xhr.send(null);
	document.getElementById('reservation_client').innerHTML = xhr.responseText;
	affiche_reservation('reservation_client');
	window.scrollTo(0, $('#reservation').position().top);
}

function load_fin(){
	//données du formulaire
	data = "etape=5&flags="+$("input[name='flags']").val()+"&notes="+$("input[name='notes']").val()+"&widget_id="+$("input[name='widget_id']").val()+"&action_resa="+$("input[name='action_resa']").val()+"&options="+$("input[name='options']").val()+"&vehicule="+$("input[name='vehicule']").val()+"&promotion="+$("input[name='promotion']").val()+"&type_calcul="+$("input[name='type_calcul']").val()+"&date_depart="+$("input[name='date_depart_unix']").val()+"&date_retour="+$("input[name='date_retour_unix']").val()+"&nb_jour="+$("input[name='nb_jour']").val()+"&km="+$("input[name='km']").val()+"&franchise="+$("input[name='franchise']").val()+"&prix_km_sup="+$("input[name='prix_km_sup']").val()+"&prix_forfait="+$("input[name='prix_forfait']").val()+"&prix_km_factures="+$("input[name='prix_km_factures']").val()+"&prix_options="+$("input[name='prix_options']").val()+"&prix_variation="+$("input[name='prix_variation']").val()+"&tarif="+$("input[name='tarif']").val()+"&modele_prefere="+$("input[name='modele_prefere']").val()+"&immatriculation="+$("input[name='immatriculation']").val()+"&id_stat="+$("input[name='id_stat']").val();
	if($("select[name='agence']").val()) data += "&agence="+$("select[name='agence']").val();
	else data += "&agence="+$("input[name='agence']").val();
	data += "&Societe="+$("input[name='Client_Societe']").val()+"&Civ="+$("select[name='Client_Civ']").val()+"&Nom="+$("input[name='Client_Nom']").val()+"&Prenom="+$("input[name='Client_Prenom']").val()+"&Tel="+$("input[name='Client_Tel']").val()+"&Fax="+$("input[name='Client_Fax']").val()+"&Mail="+$("input[name='Client_Le_Mail']").val()+"&Adresse1="+$("input[name='Client_Adresse1']").val()+"&Adresse2="+$("input[name='Client_Adresse2']").val()+"&CP="+$("input[name='Client_CP']").val()+"&Ville="+$("input[name='Client_Ville']").val()+"";
	if($("select[name='agence_retour']").val()) data += "&agence_retour="+$("select[name='agence_retour']").val();
	else data += "&agence_retour="+$("input[name='agence_retour']").val();
	//champs optionnels
	$('input[name^="champ_"]').each(function(index) {
    data += "&"+$(this).attr('name')+"="+$(this).val();
  });
	//alert(data);
	data_post = "Message="+$("textarea[name='Message']").val()+"";
	var xhr = getXhr()
	//alert(url_site+"modules/calendar/populate_timeline.php");
	xhr.open("POST","get.php?module=reservation&appel=ajax&"+data ,false);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");                  
 	xhr.send(data_post);
	document.getElementById('reservation_fin').innerHTML = xhr.responseText;
	affiche_reservation('reservation_fin');
	window.scrollTo(0, $('#reservation').position().top);
}
function verif_client() {
	erreur = false;
	$('.system_message').hide();
	$('input').removeClass('highlight');
	$('textarea').removeClass('highlight');
	$('.ligne').removeClass('highlight_checkbox');
	
	if($('input[name=Client_Nom]').val() == ''){ $('input[name=Client_Nom]').addClass('highlight'); erreur = true;}
	if($('input[name=Client_Prenom]').val() == ''){ $('input[name=Client_Prenom]').addClass('highlight'); erreur = true;}
	if($('input[name=Client_Tel]').val() == ''){ $('input[name=Client_Tel]').addClass('highlight'); erreur = true;}
	if($('input[name=Client_Le_Mail]').val() == ''){ $('input[name=Client_Le_Mail]').addClass('highlight'); erreur = true;}
	
	//Contrôle des champs obligatoires
	
	$('input[name^="champ_sup_"]').each(function(index) {
    if($(this).hasClass('obligatoire') && $(this).val()==""){
    	$(this).addClass('highlight');
    	erreur = true;
    }
  });
	
	//Contrôle des cases à cocher
	var stop = 0;
	$(':checkbox[name^="coche_"]:not(:checked)').each(function(index) {
    //if(stop==0) alert('Vous devez accepter les conditions particulières en cochant les cases correspondantes.'); 
	  //stop = 1;
	  $('#ligne_'+$(this).attr('id')).addClass('highlight_checkbox');
  	erreur = true;
	});
	//if(stop==1) return 0;
	
	
	if(document.getElementById('carte_bancaire') && !document.form_etape3.carte_bancaire.checked){ $('#ligne_carte_bancaire').addClass('highlight_checkbox'); erreur = true;}
	if(document.getElementById('conducteur_majeur') && !document.form_etape3.conducteur_majeur.checked){ $('#ligne_conducteur_majeur').addClass('highlight_checkbox'); erreur = true;}
	if(document.getElementById('acceptation_non_remboursable') && !document.form_etape3.acceptation_non_remboursable.checked){ $('#ligne_acceptation_non_remboursable').addClass('highlight_checkbox'); erreur = true;}
	if(document.getElementById('acceptation_cgv') && !document.form_etape3.acceptation_cgv.checked){ $('#ligne_acceptation_cgv').addClass('highlight_checkbox'); erreur = true;}
	if(erreur){
		$('.system_message').show();
		window.scrollTo(0, $('.system_message').position().top);
		//alert('Merci de compléter les champs obligatoires du formulaire avant de valider.');
	}
	else {
		load_fin();
	}
}
function affiche_reservation(div) {
	$('.reservation_content').hide();
	$('#'+div).fadeIn();
	//document.body
	executeJS(document.getElementById(div));
}

