﻿var regPhone = new RegExp(/^[0-9]{10}$/);
var regPhone = new RegExp(/^[0-9]{10}$/);
var regNum = new RegExp(/^[0-9]$/);
var mailReg = new RegExp(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,8})+$/);


/************************************/

$(function(){
	$("#fields_login,#fields_password,#fileds_numero,#fileds_email").focus(function(){
		$(this).val('');
	});
	$("#fields_date_retour,#fields_date_depart").focus(function(){
		$(this).val('');
	});
	
	afficheMaps();
	validFormEspaceClient();
	validFormMailPerdu();
	validFormMouteurResera();
	getDetailsVehicules();
	
	
	
	
	$('#fields_pays_location').bind('change',getVillesByPays);	
	$('#fields_ville_depart').bind('change',getVillesRetourByDepart);
});

var data_options='';
var id_aloc_auto='';

$('#tr_prix_internet').css("background-color","#FFF6D9");
$('#tr_prix_internet').css("font-weight","bold");

function getDetailsVehicules(){
		var date_depart = $('#date-depart').val();
		var date_retour = $('#date-retour').val();
		$('.offres-pager .offrediv').bind('click',function(){
		///efface la liste des options précedante si existe.
		optionList = null;
		$('#result_wrap').html('<div style="margin-bottom: 10px; text-align: center;"><img src="../web/img/ajax-loader.gif" width="100" height="100" alt="Recherche..." /></div>');
			if ($(this).find('.service').val() == "ooloc") {
				var val = $(this).find('.vehicule').val();
				var val1 = $(this).find('.prix_total').val();
				var vars = 'action=getItemDetailsVehicules&id_tarif=' + val + '&prix_total=' + val1;
				$.ajax({
					type: "POST",
					url: "../include/config.inc.php",
					data: vars,
					success: function(data){
						var obj = document.getElementById("result_wrap");
						obj.innerHTML = data;
						showResButton();
						getTotal();
					}
				});
			} else if ($(this).find('.service').val() == "cartrawler"){
				var val = $(this).find('.vehicule').val();
				var val1 = $(this).find('.prix_total').val();
				var vars = 'ctwl_action=getDetailedCar&id=' + val;
				$.ajax({
					type: "POST",
					url: "../xml/cartrawler_functions.php",
					data: vars,
					success: function(data){
						//getPrixTotal(val1);
						getHiddenValues(val, val1, date_depart, date_retour);
						$('#result_wrap').html(data);
						showResButton();
						getTotal();
					}
				});
			} else if ($(this).find('.service').val() == "amadeus"){
				var val = $(this).find('.vehicule').val();
				var val1 = $(this).find('.prix_total').val();
				var vars = 'ama_action=getDetailedCar&id=' + val;
				$.ajax({
					type: "POST",
					url: "../xml/amadeus_functions.php",
					data: vars,
					success: function(data){
						//getPrixTotal(val1);
						getHiddenValues(val, val1, date_depart, date_retour);
						$('#result_wrap').html(data);
						showResButton();
						getTotal();
					}
				});
			}
		});
}


function getPrixTotal(val1){
	var vars1 = 'action=getItemPrixTotal&prix_total='+val1
	$.ajax({
		type: "POST",url: "../include/config.inc.php", data: vars1,
		success: function(data){
			$('.price-total').html(data);
		}
	});
}
function getHiddenValues(val,val1,date_depart,date_retour){
	var vars1 = 'action=getItemHiddenValues&id_tarif='+val+'&prix_total='+val1+'&date_depart='+date_depart+'&date_retour='+date_retour
	$.ajax({
		type: "POST",url: "../include/config.inc.php", data: vars1,
		success: function(data){
			$('.inputs-hidden').html(data);
			getTotal();
		}
	});
}
//changer tarif
function changeTarif(strid) {
	$("tr[id^='tr_prix_']").css("background-color","#fff");
	$("tr[id^='tr_prix_']").css("font-weight","normal");
	$('#tr_'+strid).css("background-color","#FFF6D9");
	$('#tr_'+strid).css("font-weight","bold");
	getTotal();
}

//changer pack
function changeCat(id_aloc_auto_cat_new, myobj){
	id_pack = id_aloc_auto_cat_new;
	var date_depart = $('#date-dp').val();
	var date_retour = $('#date-rt').val();
	var heure_depart = $('#heure-depart').val();
	var heure_retour = $('#heure-retour').val();
	var depart_ville = $('#depart-ville').val();
	var retour_ville = $('#retour-ville').val();
	var pays = $('#pays').val();
	var pays_res = $('#pays_res').val();
	var age = $('#age').val();
	var conducteur_supp = $('#conducteur_supp').val();
	var jeune_conducteur_supp = $('#jeune_conducteur_supp').val();
	var siege_bebe = $('#siege_bebe').val();
	var rehausseur = $('#rehausseur').val();
	var annulation = $('#annulation').val();
	var rachat_franchise = $('#rachat_franchise').val();
	var id = $('#id').val();
	var send_mail = $('#send_mail').val();
	var send_fax = $('#send_fax').val();
	var send_sms = $('#send_sms').val();
	var code_promo = $('#code_promo').val();
	var precision='';var info_agv='';var en_modif='';var first_client='';
	//getOffres(date_depart,date_retour,heure_depart,heure_retour,depart_ville,retour_ville,pays,age,conducteur_supp,jeune_conducteur_supp,siege_bebe,rehausseur,annulation,rachat_franchise,precision,id,send_mail,send_fax,send_sms,code_promo,first_client,en_modif,info_agv,id_pack);
	
	document.location="etape2.php?date_depart="+date_depart+"&date_retour="+date_retour+"&heure_depart="+heure_depart+"&heure_retour="+heure_retour+"&ville_depart="+depart_ville+"&ville_retour="+retour_ville+
	"&pays_location="+pays+"&pays_residence="+pays_res+"&age="+age+"&nom_pack="+id_pack;
	
	$('.cattab > li > a').removeClass('selected');
	//myobj.addClass('selected');
}

function getOffres(date_depart,date_retour,heure_depart,heure_retour,depart_ville,retour_ville,pays,age,conducteur_supp,jeune_conducteur_supp,siege_bebe,rehausseur,annulation,rachat_franchise,precision,id,send_mail,send_fax,send_sms,code_promo,first_client,en_modif,info_agv,id_pack){

	$('#offres').html('<div style="margin-bottom: 10px; text-align: center;"><img src="../web/img/ajax-loader.gif" width="100" height="100" alt="Recherche..." /></div>');
	
	var vars = 'action=showCars&pays='+pays+'&depart-ville='+depart_ville+'&retour-ville='+retour_ville+'&date-depart='+date_depart+
	'&date-retour='+date_retour+'&heure-depart='+heure_depart+'&heure-retour='+heure_retour+'&age='+age+'&conducteur_supp='+conducteur_supp+'&jeune_conducteur_supp='+jeune_conducteur_supp+'&siege_bebe='+siege_bebe+'&rehausseur='+rehausseur+'&annulation='+annulation+
'&rachat_franchise='+rachat_franchise+'&precision='+precision+'&id='+id+'&send_mail='+send_mail+
'&send_fax='+send_fax+'&send_sms='+send_sms+'&code_promo='+code_promo+'&first_client='+first_client+
'&en_modif='+en_modif+'&info_agv='+info_agv+'&id_pack='+id_pack;
	
	$.ajax({
	  type: "POST",
	  url: "../reservation/v7_functions-reservation.php",
	  data: vars,
	  success: function(data){
		alert(data);
	  }
	});
	
}

function getCar(id_aloc_auto,prix) {
$('#id_aloc_auto').val(id_aloc_auto);
$('#result-resa').html('...');
$('#result-resa-internet').html('...');
$('#result-total').html('...');
$('#result').html('<div style="margin-bottom: 10px;"><img src="/gif/car-loading.gif" width="200" height="150" alt="Recherche..." style="border: solid 1px #ccc;" /></div>');
    $.ajax({
        type: "POST",
        url: "/location/ajax/offres-car.asmx/getCar",
        data: '{"id_aloc_auto":"' + id_aloc_auto + '","date_debut_loc":"' + date_debut + '","date_fin_loc":"' + date_fin + '","the_prix":"' + prix + '"}',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {
            $('#result').setTemplateURL('/location/ajax/car.htm');
            $('#result').processTemplate(msg);
            $('#t-tot-resa').val(prix);
            $('.offrediv').removeClass('offrediv-click');
            $('#offre-' + id_aloc_auto).addClass('offrediv-click');
            if (msg.d.disponible == "1" && msg.d.prix != "0") {
                getFranchise();
                getTotal();
                $('#result-disponible').hide();
                $('#tr_prix_resa').show(); 
                $('#Div1').show();
            } else if (msg.d.disponible == "2" && msg.d.prix != "0") {
                getFranchise();
                getTotal();
                $('#result-disponible').hide();
                $('#Div1').show();
                $('#tr_prix_resa').hide();           
            } else {
            $('#result-disponible').show();
                $('#Div1').hide();
                $('#result-resa').html('...');
                $('#result-resa-internet').html('...');
                $('#result-total').html('...');
            }
            
        }
    });

}

//pager functions
function goToPage(num){
	
	$(".highlight").removeClass('highlight');
	
	$("a[num='"+num+"']").attr('class','highlight');
	
	$(".offrediv").each(
		function() {
			if(($(this).attr("rank") <= (num*8)) && ($(this).attr("rank") > ((num-1)*8))) {
				$(this).show();
			} else {
				$(this).hide();
			}
		}
	);
	
	 $("div[rank='"+(((num-1)*8)+1)+"']").trigger("click");
}
//pager

function filterByCategory(cat) {
	if (cat == null || cat == 0) {
		$(".offrediv").show();
		$("div[rank='1']").trigger("click");
		return;
	}
	var cats = cat.split(",");
	$(".offrediv").hide();
	var triggered = '';
	for(var i = 0; i < cats.length; i++) {
		//$("div[sipp^='"+ cats[i] +"']").show();
		$("div[sipp^='"+ cats[i] +"']").each(
			function(){
				if (triggered == '') {
					triggered = $(this).attr('rank');
				}
				$(this).show();
			}
		);
	}
	
	if(triggered != '') {
		$("div[rank='"+triggered+"']").trigger("click");
	}
}



function getFranchise() {
$.ajax({
  type: "POST",
  url: "/location/ajax/offres-car.asmx/getFranchise",
  data: '{"id_aloc_site1":"'+id_aloc_site1+'","id_aloc_site2":"'+id_aloc_site2+'","date_debut":"'+date_debut+'","date_fin":"'+date_fin+'","id_aloc_auto":"'+$('#id_aloc_auto').val()+'"}',
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
	if (msg.d != null) {
		$('#result-franchise').setTemplateURL('/location/ajax/franchise.htm');
		$('#result-franchise').processTemplate(msg);
	} else {
		$('#result-franchise-div').hide();
	}
	if(document.getElementById("franchise-part-chk") == null && document.getElementById("franchise-tot-chk") == null) {
		$('#result-franchise-div').hide();
	} else {
		$('#result-franchise-div').show();
	};
  }
});
}

function getTaxes() {
$.ajax({
  type: "POST",
  url: "/location/ajax/offres-car.asmx/getTaxes",
  data: '{"id_aloc_site1":"'+id_aloc_site1+'","id_aloc_site2":"'+id_aloc_site2+'","date_debut":"'+date_debut+'","date_fin":"'+date_fin+'"}',
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
	if (msg.d != null) {
		$('#result-taxes').setTemplateURL('/location/ajax/taxes.htm');
		$('#result-taxes').processTemplate(msg);
	} else {
		$('#result-taxes-div').hide();
	}
	getOptions();
  }
});
}

function getOptions() {
	
$.ajax({
  type: "POST",
  url: "/location/ajax/offres-car.asmx/getOptions",
  data: '{"id_aloc_site1":"'+id_aloc_site1+'","id_aloc_site2":"'+id_aloc_site2+'","date_debut":"'+date_debut+'","date_fin":"'+date_fin+'"}',
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function(msg) {
	$('#result-options').setTemplateURL('/location/ajax/options.htm');
	$('#result-options').processTemplate(msg);
	getTotal();
	}
});
}

function doRebind() {

	$("input[name^='btn-']").livequery('click', function(event) { 
        eval($(this).attr('onclick')); 
    });
	$("input[name^='opt-chk-']").livequery('click', function(event) { 
        eval($(this).attr('onclick')); 
    });
    $("input[name^='franchise-part-chk']").livequery('click', function(event) { 
        eval($(this).attr('onclick')); 
    });
    $("input[name^='franchise-tot-chk']").livequery('click', function(event) { 
        eval($(this).attr('onclick')); 
    });
}

var optionList;

function saveOptions(name, amount, count){
	name = name.replace('é','e').replace('è','e');
	if(optionList == null) optionList = new Array();
	var isSet = false;
	amount = amount.replace(',','.');
	for(var i = 0; i < optionList.length; i++){
		
		if(optionList[i]['id'] == name) {
			optionList[i]['count'] = count;
			isSet = true;
		}
	}
	if(!isSet) {
		var newOp = new Array()
			newOp['id'] = name;
			newOp['count'] = count;
			optionList.push(newOp);
	}
}


function calcOptions(id_aloc_option, myaction) {
	var myval = Number($('#t-options-nb-'+id_aloc_option).attr('value'));
	if(myaction == 'add') {
		if(myval < 5) {
			$('#t-options-nb-'+id_aloc_option).attr('value',myval+1);
		}
	} else if(myaction == 'del') {
		if(myval > 0) {
			$('#t-options-nb-'+id_aloc_option).attr('value',myval-1);
		}
	}
	$('#opt-num-'+id_aloc_option).attr('value',$('#t-options-nb-'+id_aloc_option).attr('value'));
	
	saveOptions("t-options-"+id_aloc_option, $('#t-options-'+id_aloc_option).attr('value'), $('#t-options-nb-'+id_aloc_option).attr('value'));
}

function checkOption2(id_aloc_option){
	if($('#opt-chk-'+id_aloc_option).attr('checked')) {
		saveOptions("t-options-"+id_aloc_option, $('#t-options-'+id_aloc_option).attr('value'), 1);
	}else {
		saveOptions("t-options-"+id_aloc_option, $('#t-options-'+id_aloc_option).attr('value'), 0);
	}
	getTotal();
}

function checkOption(id_aloc_option, inCB, nbDays){
	var checked = $('#opt-chk-'+id_aloc_option).attr('checked');
	if(checked) {
		saveOptions("t-options-"+id_aloc_option, $('#t-options-'+id_aloc_option).attr('value'), 1);
	}else {
		saveOptions("t-options-"+id_aloc_option, $('#t-options-'+id_aloc_option).attr('value'), 0);
	}
	if (!inCB) {
		getTotal();
	}else {
		var totalCb =  Number($('#result-resa-internet').attr('value'));
		var total =  Number($('#result-total').attr('value'));
		var opt = Number($('#t-options-'+id_aloc_option).attr('value'));
		if(Number(nbDays) > 0 ) {
			opt *= Number(nbDays);
		}
		
		if(checked) {
			totalCb += opt;
			total += opt;
		}else {
			totalCb -= opt;
			total -= opt;
		}
		
		$('#result-resa-internet').attr('value', totalCb.toFixed(2));
		$('#result-resa-internet').html(totalCb.toFixed(2)+ '&euro;');
		
		$('#result-total').attr('value', total.toFixed(2));
		$('#result-total').html(total.toFixed(2)+ '&euro; TTC');
	}
}



function getTotal() {
	var totalresa = Number($('#result-resa-internet').attr('value'));
	$('#result-resa-internet').html(totalresa.toFixed(2) + '&euro;');
	
	var totalAgency = Number($('#agency').attr('value'));
	if(!(totalAgency > 0)) totalAgency = 0;
	
	var totaltaxes = 0;
	$("input[name^='t-taxe-']").each(function(){totaltaxes = totaltaxes + Number($(this).attr('value').replace(',','.'));});

	$("input[name^='opt-num-']").each(function(){
		$('#'+$(this).attr('name').replace('opt-num-','t-options-nb-')).attr('value',$(this).attr('value'));
	});
	
	$("input[name^='opt-chk-']").each(function(){
		if($(this).attr('checked')){
			$('#'+$(this).attr('name').replace('opt-chk-','t-options-nb-')).attr('value','1');
		} else {
			$('#'+$(this).attr('name').replace('opt-chk-','t-options-nb-')).attr('value','0');
		}
	});
	
	data_options = ''
	var totaloptions = 0;
	$("input[name^='t-options-nb-']").each(function(){
		if ($(this).attr('cb')) {
			
		}
		else {
		
			totaloptions += Number($(this).attr('value')) * Number($('#' + $(this).attr('name').replace('-nb', '')).attr('value').replace(',', '.'));
			
			if ($(this).attr('value') > 0) {
				if (data_options.length > 0) {
					data_options += '@'
				};
				data_options += $(this).attr('name').replace('t-options-nb-', '') + '#' + $(this).attr('value');
			}
		}
		
	});
	
	var totalfranchise = 0;
	$('#rfranch').attr('value','0');
	var franchiseform = document.getElementById("franchise-part-chk");
	if (franchiseform != null) {
		if($('#franchise-part-chk').attr('checked')){
			$('#t-franchise-part-nb').attr('value','1');
			$('#rfranch').attr('value','1');
			totalfranchise = Number($('#t-franchise-part-nb').attr('value')) * Number($('#t-franchise-part').attr('value').replace(',','.'));
		};
	};
	
	franchiseform = null;
	franchiseform = document.getElementById("franchise-tot-chk");
	if (franchiseform != null) {
		if($('#franchise-tot-chk').attr('checked')){
			$('#t-franchise-tot-nb').attr('value','1');
			$('#rfranch').attr('value','2');
			totalfranchise = Number($('#t-franchise-tot-nb').attr('value')) * Number($('#t-franchise-tot').attr('value').replace(',','.'));
		};
	};

	var total;
	
	total = totalresa + totaltaxes + totaloptions + totalAgency;
	$('#result-total').html((Math.round(total*100)/100).toFixed(2) + '&euro; TTC');
	$('#result-total').attr('value',(Math.round(total*100)/100).toFixed(2));
}


function flipFranchise(mycheckid){
	if($('#'+mycheckid).attr('checked')){
		if(mycheckid=='franchise-part-chk') {
			$('#franchise-tot-chk').attr('checked', false);
			$('#franchise-tot-nb').attr('value','0')
		} else {
			$('#franchise-part-chk').attr('checked', false);
			$('#franchise-part-nb').attr('value','0')
		};
	};
	getTotal();
}

function formSubmit() {
	 setTimeout('doformSubmit()',500)
}
function doformSubmit() {
	 $('#aspnetForm').submit();
}

function stripNonNumeric(str)
{
  str += '';
  var rgx = /^\d|\.|-$/;
  var out = '';
  for( var i = 0; i < str.length; i++ )
  {
    if( rgx.test( str.charAt(i) ) ){
      if( !( ( str.charAt(i) == '.' && out.indexOf( '.' ) != -1 ) ||
             ( str.charAt(i) == '-' && out.length != 0 ) ) ){
        out += str.charAt(i);
      }
    }
  }
  return out;
}


/********************************************/

function showResButton() {
	$("#res_no-action").hide();
	$("#res_action").show();
}

function goToStep3(){
		var optionsVar = '';
	if(optionList != null){
		var opt = 'options=';
		for (var i = 0; i < optionList.length; i++) {
			optionsVar += opt + optionList[i]['id'] + ";" + optionList[i]['count'];
			if(opt == 'options=') opt = "|";
		}
	}
	
		if(optionsVar != '') {optionsVar = '?' + optionsVar}
		document.location = "./etape3.php" + optionsVar;
}

window.onbeforeunload = function () {
 //  alert("return");
}

function reloadForm(){
	setTimeout(function() {
			if($("#temp").attr('pop') == "1") {
				$("div[rank=\'1\']").trigger("click");
			}
		}, 300);
}

/******************step 3**************************/
function hideName() {
	if ($('#civilite').val() == "Société" || $('#civilite').val() == "Association" || $('#civilite').val() == "Groupe") {
		
		$('.pren').hide();
	} else {
		$('.pren').show();
	}
}

function validateStep3(){
	
	errorMsg = "Les champs suivant sont incorrects :";
	
	
	$('#ctl00_C_revEmail').hide();
	$('#ctl00_C_rfvEmail').hide();
	$('#ctl00_C_rfv_ux_civilite').hide();
	$('#ctl00_C_RequiredFieldValidator6').hide();
	$('#ctl00_C_RequiredFieldValidator4').hide();
	$('#ctl00_C_RequiredFieldValidator10').hide();
	$('#ctl00_C_RequiredFieldValidator11').hide();
	$('#ctl00_C_RequiredFieldValidator12').hide();
	$('#ctl00_C_RequiredFieldValidator13').hide();
	$('#ctl00_C_RequiredFieldValidator15').hide();
	$('#ctl00_C_RequiredFieldValidator16').hide();
	
	if($('#ctl00_C_ux_prenom_driver').val() == "") {
		$('#ctl00_C_RequiredFieldValidator01').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator01').html();
	}
	
	if($('#ctl00_C_ux_nom_driver').val() == "") {
		$('#ctl00_C_RequiredFieldValidator02').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator02').html();
	}
	
	if($('#civilite').val() == "") {
		$('#ctl00_C_rfv_ux_civilite').show();
		errorMsg += "\n-" + $('#ctl00_C_rfv_ux_civilite').html();
	}
	
	if($('#ctl00_C_ux_prenom').val() == "") {
		if (($('#civilite').val() != "Société") && ($('#civilite').val() != "Association") && ($('#civilite').val() != "Groupe")) {
			
			$('#ctl00_C_RequiredFieldValidator6').show();
			errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator6').html();
		}
	}
	
	if($('#ctl00_C_ux_nom').val() == "") {
		$('#ctl00_C_RequiredFieldValidator4').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator4').html();
	}
	
	if($('#ctl00_C_ux_adresse').val() == "") {
		$('#ctl00_C_RequiredFieldValidator10').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator10').html();
	}
	
	if($('#ctl00_C_ux_cp').val() == "") {
		$('#ctl00_C_RequiredFieldValidator11').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator11').html();
	}
	
	if($('#ctl00_C_ux_ville').val() == "") {
		$('#ctl00_C_RequiredFieldValidator12').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator12').html();
	}
	
	if($('#ctl00_C_ux_id_com_pays').val() == "0") {
		$('#ctl00_C_RequiredFieldValidator13').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator13').html();
	}
	
	if($('#ctl00_C_ux_email').val() == "") {
		$('#ctl00_C_rfvEmail').show();
		errorMsg += "\n-" + $('#ctl00_C_rfvEmail').html();
	}else {
		Exp = new RegExp("^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,}")
		if(!Exp.test($('#ctl00_C_ux_email').val())) {
			$('#ctl00_C_revEmail').show();
			errorMsg += "\n-" + $('#ctl00_C_rfvEmail').html();
		}
	}
	
	if($('#ctl00_C_ux_tel1').val() == "") {
		$('#ctl00_C_RequiredFieldValidator15').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator15').html();
	}
	
	if($('#ctl00_C_ux_tel2').val() == "") {
		$('#ctl00_C_RequiredFieldValidator16').show();
		errorMsg += "\n-" + $('#ctl00_C_RequiredFieldValidator16').html();
	}
	
	if(!$('#ctl00_C_ux_cgv').attr('checked')) {
		errorMsg += "\n-" + "Vous devez accepter les conditions généreales de location";
	}
	
	if(errorMsg != "Les champs suivant sont incorrects :") {
		alert(errorMsg);
	}else {
		var vars = '';
		var then = '';
		
		var driver_prenom = $('#ctl00_C_ux_prenom_driver').val();
		var driver_nom = $('#ctl00_C_ux_nom_driver').val();
		var civ = $('#civilite').val();
		var prenom = $('#ctl00_C_ux_prenom').val();
		var nom = $('#ctl00_C_ux_nom').val();
		var adresse = $('#ctl00_C_ux_adresse').val();
		var code_postal = $('#ctl00_C_ux_cp').val();
		var ville = $('#ctl00_C_ux_ville').val();
		var pays = $('#ctl00_C_ux_id_com_pays').val();
		var mail = $('#ctl00_C_ux_email').val();
		var tel = $('#ctl00_C_ux_tel1').val();
		var tel_mobile = $('#ctl00_C_ux_tel2').val();
		var compagnie_aeriene = $('#ctl00_C_ux_vol_cie').val();
		//var num_train = $('#num_train').val();
		var num_vol = $('#ctl00_C_ux_vol_num').val();
		var observations = $('#ctl00_C_ux_observations').val();
		var newsletter = $('#ctl00_C_ux_newsletter').attr('checked');
		var conditions = $('#ctl00_C_ux_cgv').attr('checked');
		
		var form = '<form name="step3_form" id="step3_form" action="./etape4.php" method="POST" >';
		form += '<input type="hidden" name="prenom_conducteur" id="prenom_conducteur" value="'+ driver_prenom +'" />';
		form += '<input type="hidden" name="nom_conducteur" id="nom_conducteur" value="'+ driver_nom +'" />';
		form += '<input type="hidden" name="titre" id="titre" value="'+civ +'" />';
		form += '<input type="hidden" name="prenom" id="prenom" value="'+ prenom +'" />';
		form += '<input type="hidden" name="nom" id="nom" value="'+ nom +'" />';
		form += '<input type="hidden" name="adresse" id="adresse" value="'+ adresse +'" />';
		form += '<input type="hidden" name="code_postal" id="code_postal" value="'+ code_postal +'" />';
		form += '<input type="hidden" name="ville" id="ville" value="'+ ville +'" />';
		form += '<input type="hidden" name="pays" id="pays" value="'+ pays +'" />';
		form += '<input type="hidden" name="email" id="email" value="'+ mail +'" />';
		form += '<input type="hidden" name="telephone" id="telephone" value="'+ tel +'" />';
		form += '<input type="hidden" name="mobile" id="mobile" value="'+ tel_mobile +'" />';
		form += '<input type="hidden" name="compagnie_aeriene" id="compagnie_aeriene" value="'+ compagnie_aeriene +'" />';
		form += '<input type="hidden" name="num_vol" id="num_vol" value="'+ num_vol +'" />';
		form += '<input type="hidden" name="observations" id="observations" value="'+ observations +'" />';
		form += '<input type="hidden" name="newsletter" id="newsletter" value="'+ newsletter +'" />';
		form += '<input type="hidden" name="flag" id="flag" value="'+ flag +'" />';
		form += '</form>';
		
		$('#frmsbt').html(form);
		
		vars = "?titre=" + civ
			+ "&prenom=" + prenom
			+ "&nom=" + nom
			+ "&adresse=" + adresse
			+ "&code_postal=" + code_postal
			+ "&ville=" + ville
			+ "&pays=" + pays
			+ "&email=" + mail
			+ "&telephone=" + tel
			+ "&mobile=" + tel_mobile
			+ "&compagnie_aeriene=" + compagnie_aeriene
			+ "&num_vol=" + num_vol
			+ "&observations=" + observations
			+ "&newsletter=" + newsletter;
			
		//document.location = "./etape4.php" + vars;
		
		document.step3_form.submit();
			
	}
}


function horaire(nom_pays,nom_loueur,zone)
{
	alert("ld");
	window.open("../info_agence.php?nom_pays=" + nom_pays + "&nom_loueur=" + nom_loueur + "&zone=" + zone, "top=50, left=200, toolbar=no, status=no, scrollbars=no, resizable=no, width=452, height=560");
}

var flag;
function step34Load() {
	flag = $("#flag").val();
	$(".flag").remove();
}

/*********************etape4*******************/


