function get_booking() {
    if ($("#form1").valid()) {
		$('.prix_ttc').css('display', 'none');
		$('#chercher, #tarif').css('display', 'none');
		$('#ttc_'+$("input[name='tarif']:checked").attr('id')).css('display', 'block');
        $('#contacdiv').css('display', 'none');
		$('#suivant').css('display', 'none');
		$('#devis_par_mail').css('display','none');

		//$('#tarif_div').css('display', 'none');
        $('#loadajax3').html('<img src="' + getHost() + '/images/ajax-loader.gif"><br>' + $('#tr_wait').val() + ' ....');
        var type = 0;
        var veh = 0;
        if (document.getElementById('vehicule').checked == true) {
            veh = 1;
            var vehicule1 = document.getElementById('vehicule1').value;
            var vehicule_origine = vehicule1;
            var longueur_v1 = document.getElementById('longueur_v1').value;
			
            var vehicule2 = document.getElementById('vehicule2').value;
			var longueur_v2 = document.getElementById('longueur_v2').value;
			
            if (vehicule1 == "CAR2") {
                vehicule1 = "CAR"
            }
            if (vehicule2 == "REM2") {
                vehicule2 = "REM"
            }
        }
        if (document.getElementById('aller').checked == false) {
            type = 1
        }
        var adults = document.getElementById('adults').value;
        var enfants = document.getElementById('enfants').value;
		var bebes = document.getElementById('bebes').value;
        var passager = parseInt(adults) + parseInt(enfants);
        var origine = document.getElementById('origine').value;
        var destination = document.getElementById('destination').value;
        var date_dep = document.getElementById('date_aller').value;
        var date_ret = document.getElementById('date_retour').value;
        var code_tarif_a = document.getElementById('code_price_a').value;
		var code_tarif_r = document.getElementById('code_price_r').value;
        var contact_name = document.getElementById('nom').value;
        var contact_telephone = document.getElementById('telephone').value;
        for (i = 1; i <= 80; i++) {
            if (document.getElementById('accommodation_' + i)) {
                if (document.getElementById('accommodation_' + i).checked == true) {
                    var class_accomo = document.getElementById('accommodation_' + i).value
                }
            }
        }
        if (type == 1) {
            for (i = 1; i <= 160; i++) {
                if (document.getElementById('accommodation_r' + i)) {
                    if (document.getElementById('accommodation_r' + i).checked == true) {
                        var class_accomo_r = document.getElementById('accommodation_r' + i).value
                    }
                }
            }
        }
       
        $.ajax({
            type: "POST",
            url: getHost() + "site/getBooking",
            data: "depart=" + origine + "&arrive=" + destination + "&type=" + type + "&date_aller=" + date_dep + "&date_retour=" + date_ret + "&passager=" + passager + "&enfants=" + enfants + "&adults=" + adults + "&bebes="+bebes+"&vehicule=" + veh + "&vehicule1=" + vehicule1 + "&longueur_v1=" + longueur_v1 + "&longueur_v2=" + longueur_v2 + "&vehicule2=" + vehicule2 + "&class_accomo=" + class_accomo + "&dep_time=" + dep_time + "&arr_time=" + arr_time + "&dep_time_r=" + dep_time_r + "&arr_time_r=" + arr_time_r + "&class_accomo_r=" + class_accomo_r + "&contact_name=" + contact_name + "&contact_telephone=" + contact_telephone + "&code_tarif_a=" + code_tarif_a +  "&code_tarif_r=" + code_tarif_r +"&vehicule_origine=" + vehicule_origine,
            dataType: "text",
            success: function (xml) {
				 //alert(xml);
				 
                if (xml != "") {
                    var xml = pxml(xml);
                    var type = $(xml).find('type').text();
                    var ProcessID = $(xml).find('ProcessID').text();
                    var BookingNumber = $(xml).find('BookingNumber').text();
					var BookingNumber_bebe1 = $(xml).find('BookingNumber_bebe1').text();
					var BookingNumber_bebe2 = $(xml).find('BookingNumber_bebe2').text();
                    var ErrorCode = $(xml).find('ErrorCode').text();
                    var ErrorDescription = $(xml).find('ErrorDescription').text();
                    var lapsingdate = $(xml).find('lapsingdate').text();
                    var aff_next = "";
                    $('#lapsingdate').val(lapsingdate);
					 // ErrorCode = 266;
                    if (ErrorCode == 0) {
 $('<div id="bookingZ"></div>').html('<input type="hidden" name="BookingNumber" id="bookingNumber" value="' + BookingNumber + '" /><input type="hidden" name="BookingNumber_bebe1" id="BookingNumber_bebe1" value="' + BookingNumber_bebe1 + '" /><input type="hidden" name="BookingNumber_bebe2" id="BookingNumber_bebe2" value="' + BookingNumber_bebe2 + '" />').appendTo('#tarif_div');
 $('#form1').submit()
                    }
					else if(ErrorCode == 266){
 $('<div id="bookingZ"></div>').html('<input type="hidden" name="BookingNumber" id="bookingNumber" value="266" />').appendTo('#tarif_div');
 $('#form1').submit()
						}
					else {
                        $('#tarif_div').html("<font style=color:#F00>Une erreur est survenue, merci de réessayer ou de nous contacter au 01 75 430 212.<br> Code Erreur : " + ErrorCode + "</font><br><br>");
                        $('#loadajax3').html('');
                       // $('#booking').css('display', 'block')
						$('#chercher, #tarif').fadeIn();
                    }
                }
            }
        })
    }
}
var l = 0;
var div_v = "";
var type = 0;
var dep_time = "";
var arr_time = "";
var dep_time_r = "";
var arr_time_r = "";
var shipcode = "";
var promo = "";
//code_price passengers_price rates_price fee_price
var arrPrice= new Array();
var arrCaPrice= new Array();
var arrCrPrice= new Array();
var arrPPrice= new Array();
var arrRPrice= new Array();
var arrFPrice= new Array();
var arrRestriction= new Array();
var arrRestrictionAcciona= new Array();
function get_price() {
    $('#contacdiv').html('');
    if ($("#form1").valid()) {
        $('#loadajax2').html('<img src="' + getHost() + '/images/ajax-loader.gif"><p>' + $('#tr_wait').val() + ' ....</p>');
        $('#voyages').css('display', 'block');
        $('#tariff').css('display', 'block');
        var type = 0;
        var veh = 0;
        if (document.getElementById('vehicule').checked == true) {
            veh = 1;
            var vehicule1 = document.getElementById('vehicule1').value;
            var vehicule_origine = vehicule1;
            var longueur_v1 = document.getElementById('longueur_v1').value;
            var vehicule2 = document.getElementById('vehicule2').value;
			var longueur_v2 = document.getElementById('longueur_v2').value;
			
            if (vehicule1 == "CAR2") {
                vehicule1 = "CAR"
            }
            if (vehicule2 == "REM2") {
                vehicule2 = "REM"
            }
        }
        if (document.getElementById('aller').checked == false) {
            type = 1
        }
        var adults = document.getElementById('adults').value;
        var enfants = document.getElementById('enfants').value;
		var bebes = document.getElementById('bebes').value;
        var passager = parseInt(adults) + parseInt(enfants);
        var origine = document.getElementById('origine').value;
        var destination = document.getElementById('destination').value;
        var date_dep = document.getElementById('date_aller').value;
        var date_ret = document.getElementById('date_retour').value;
        for (i = 1; i <= 80; i++) {
            if (document.getElementById('accommodation_' + i)) {
                if (document.getElementById('accommodation_' + i).checked == true) {
                    var class_accomo = document.getElementById('accommodation_' + i).value
                }
            }
        }
        if (type == 1) {
            for (i = 1; i <= 160; i++) {
                if (document.getElementById('accommodation_r' + i)) {
                    if (document.getElementById('accommodation_r' + i).checked == true) {
                        var class_accomo_r = document.getElementById('accommodation_r' + i).value
                    }
                }
            }
        }
        $('#tarif_div').html('');
		/**ENV*/
 	var data=env='';
  $.get(getHost() + "site/getPrices?ENV", function(data){env=data;});
        $.ajax({
            type: "POST",
            url: getHost() + "site/getPrices",
            data: "depart=" + origine + "&arrive=" + destination + "&type=" + type + "&date_aller=" + date_dep + "&date_retour=" + date_ret + "&passager=" + passager + "&enfants=" + enfants + "&adults=" + adults + "&bebes="+bebes+"&vehicule=" + veh + "&vehicule1=" + vehicule1 + "&longueur_v1=" + longueur_v1 + "&longueur_v2=" + longueur_v2 + "&vehicule2=" + vehicule2 + "&class_accomo=" + class_accomo + "&dep_time=" + dep_time + "&arr_time=" + arr_time + "&dep_time_r=" + dep_time_r + "&arr_time_r=" + arr_time_r + "&class_accomo_r=" + class_accomo_r + "&vehicule_origine=" + vehicule_origine,
            dataType: "text",
            success: function (xml) {
				 
				//document.write("<XMP>"+xml+"</XMP>");
				 //alert(xml);
                if (xml != "") {
                    var xml = pxml(xml);
					var type;
                    var ProcessID;
                    var code_price_a;
					var code_price_r;
					var code_voyage;
                    var passengers_price;
                    var vehicles_price;
                    var rates_price;
                    var fee_price;
                    var total_price;
                    var ErrorCode;
                    var ErrorDescription;
                    var aff_next;
					var checked_price=0;
					var prices_html='';
					var restriction='';
					var restriction_acciona='';
					var restrictions='';
					var star='';
					var j=0;
					var id_price=1;
					var code_price_name="";
					var nb_prices=$(xml).find('price').length;

					
switch (nb_prices){
case 1 : var labels = new Array('','Tarif Normal'); break;
case 2 : var labels = new Array('','<span style="color:red">Tarif Promo</span>','Tarif Normal'); break;
case 3 : var labels = new Array('','<span style="color:red">Tarif Promo</span>','Tarif Réduit','Tarif Normal'); break;
default: var labels = new Array('','<span style="color:red">Tarif Promo</span>','Tarif Réduit','Tarif Normal','Tarif Normal','Tarif Normal','Tarif Normal'); break;
}
 
					$(xml).find('price').each(function(){
					var afficher_prix = true;
					var txt_chechbox ='';
					j++;
					star+="*";
                    type = $(this).find('type').text();
                    ProcessID = $(this).find('ProcessID').text();
                    code_price_a = $(this).find('code_price_a').text();
					code_price_r = $(this).find('code_price_r').text();
                    passengers_price = $(this).find('passengers_price').text();
                    vehicles_price = $(this).find('vehicles_price').text();
                    rates_price = $(this).find('rates_price').text();
                    fee_price = $(this).find('fee_price').text();
                    total_price = $(this).find('total_price').text();
                    ErrorCode = $(this).find('ErrorCode').text();
                    ErrorDescription = $(this).find('ErrorDescription').text();
					restriction_acciona= $(this).find('Restriction').text();
 
					arrPrice[j]=total_price;
					arrCaPrice[j]=code_price_a;
					arrCrPrice[j]=code_price_r;
					arrPPrice[j]=passengers_price;
					arrRPrice[j]=rates_price;
					arrFPrice[j]=fee_price;
					arrRestrictionAcciona[j]=restriction_acciona;
					
					code_voyage=code_price_a;
					if(type==1){code_voyage=code_price_a+'/'+code_price_r}
                    aff_next = ""; 
 			
switch (code_voyage){
	case 'TG' : code_price_name = 'Tarif Normal'; Restriction='modifiable et Remboursable';id_price=j; break;
	case 'TE' : code_price_name = 'Tarif Promo'; Restriction='Modifiable, non Remboursable'; break;
	case 'TR' : code_price_name = 'Tarif Réduit'; Restriction='Non modifiable, non Remboursable'; break;
	case 'IVR' : code_price_name = 'Tarif Réduit Aller et Retour'; Restriction='Non modifiable, non Remboursable'; break;
	case 'IV' : code_price_name = 'Tarif Promo Aller Retour'; Restriction='Modifiable, non Remboursable'; break;
	case 'TGIV' : code_price_name = 'Tarif Général Aller Retour'; Restriction='Modifiable, Remboursable'; break;
	case 'PCM' : code_price_name = 'Tarif Promo'; Restriction='Modifiable, Remboursable'; break;
	case 'PCH' : code_price_name = 'Tarif Promo'; Restriction='Modifiable, Remboursable'; break;
	case 'IVE2' : code_price_name = 'Tarif Promo Aller Retour'; Restriction='Modifiable, Remboursable'; break;
	case 'TE03' : code_price_name = 'Tarif Economique'; Restriction='Modifiable, non remboursable'; break;
	case 'FSM3' : code_price_name = 'Tarif Forfait Sans Manutention (Sans Repas)'; Restriction='Modifiable, non remboursable'; break;
	case 'FRB4' : code_price_name = 'Tarif Forfait'; Restriction='Modifiable, non remboursable'; break;
	case 'TE01' : code_price_name = 'Tarif Economique'; Restriction='Modifiable, non remboursable'; break;
	case 'FRB1' : code_price_name = 'Tarif Forfait'; Restriction='Modifiable, non remboursable'; break;
	case 'FSM4' : code_price_name = 'Tarif Forfait Sans Manutention (Sans Repas)'; Restriction='Modifiable, non remboursable'; break;
	case 'PRFR' : code_price_name = 'Tarif Promotionnel'; Restriction='Modifiable, non remboursable'; break;
	case 'ERF' : code_price_name = 'Tarif Economique'; Restriction='Modifiable, non remboursable'; break;
	case 'IVMN' : code_price_name = 'Tarif Aller/Retour'; Restriction='Modifiable, non remboursable'; break;
	case 'LRB1' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LRB2' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LRB3' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LRB4' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LCM1' : code_price_name = 'Tarif Promo avec repas'; Restriction='Modifiable , non remboursable'; break;
	case 'LCM2' : code_price_name = 'Tarif Promo avec repas'; Restriction='Modifiable , non remboursable'; break;
	case 'LCM3' : code_price_name = 'Tarif Promo avec repas'; Restriction='Modifiable , non remboursable'; break;
	case 'LCM4' : code_price_name = 'Tarif Promo avec repas'; Restriction='Modifiable , non remboursable'; break;
	case 'LSM1' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LSM2' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LSM3' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LSM4' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'TC2' : code_price_name = 'Tarif économique'; Restriction='Modifiable, remboursable'; break;
	case 'LSM2/LSM2' : code_price_name = 'Tarif Promo'; Restriction='Non modifiable, non Remboursable'; break;
	case 'IV/IV' : code_price_name = 'Tarif Normal'; Restriction='Modifiable et Remboursable'; break;
	case 'IVMN/IVMN' : code_price_name = 'Tarif Aller/Retour'; Restriction='Modifiable et Remboursable'; break;
	case 'TPTN' : code_price_name = 'Tarif Promo'; Restriction='Non modifiable, non remboursable'; break;
	case 'LRB3/LRB3' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'LRB4/LRB4' : code_price_name = 'Tarif Promo'; Restriction='Modifiable , non remboursable'; break;
	case 'TGIV/TGIV' : code_price_name = 'Tarif Normal'; Restriction='modifiable et Remboursable'; break;
	case 'FSM3/FSM3' : code_price_name = 'Tarif Normal'; Restriction='Modifiable mais non remboursable'; break;
	case 'IV/TGIV' : code_price_name = 'Tarif Normal'; Restriction='Modifiable et Remboursable'; break;
	//case '' : code_price_name = '()'; Restriction=''; break;
	default :code_price_name = "Tarif Normal"; Restriction='Non Modifiable, Non Remboursable'; break;
	}
	
	arrRestriction[j]= Restriction;
	
	if(labels[j]){code_price_name = labels[j];}


Restriction = '('+star+') '+Restriction;
code_price_name = code_price_name + ' <span style="font-size: 11px;">('+star+')</span> ';
restrictions += Restriction + '<br>' ;
if($('#host').val().match('test') || $('#host').val().match('local')){code_price_name+=' <b>Code</b> : '+code_price_a+'   '+code_price_r+'<b>WS ACCIONA</b> :'+env +'<br><b>WS RESTRICTION</b> '+arrRestriction[j]+'';}

					aff_next = "onClick='aff_n("+j+")'";
				if(afficher_prix){	txt_chechbox ='<input type="radio" name="tarif" class="tarif" id="'+j+'" value="' + total_price + '" ' + aff_next + ' />';}
prices_html+='<div class="prix_ttc" id="ttc_'+j+'">  '+txt_chechbox+'  <b>' + $('#tr_prix').val() + '</b> : <span class="prix"><b>' + total_price + ' Euros </b></span> - '+ code_price_name +'<br>  </div>';
					});
					
                    if (ErrorCode == 0) {
                        if (code_price_a=='TPTN') {
          $('#tarif_div').html('Le voyage que vous demandez est une <b style="color:#F00">OFFRE SPÉCIALE</b> , la réservation peut se faire au téléphone uniquement. Merci de nous contacter au <b style="color:#F00">01 75 430 212</b>'); $('#loadajax2').html('');return false;
                        }
 
                        $('<div id="_tariff"></div>').html(prices_html).appendTo('#tarif_div');

                        $('<div id="contacdiv"></div>').html('<div style="font-size: 11px;"><br>'+restrictions+'</div><div style="margin-right:10px;border:solid 1px #D1D1D1; padding-top:10px; padding-left:10px;padding-right:10px; margin-top:4px;padding-bottom:4px;">   <div id="etap0" style="width:610px;margin-right:10px;">     <h2>' + $('#tr_fill').val() + '</h2>   </div>   <label style="height:5px; display:block"></label>   <label for="name">' + $('#tr_nom').val() + ' : </label>   <input type="text" name="nom" id="nom" value="' + $('#edit_nom_devis').val() + '" class="required" onkeypress="acc(this)" onblur="acc(this)" maxlength="12"/>   <label style="width:20px"></label>    <label for="telephone">Téléphone</label>   <input type="text" name="telephone" id="telephone" value="' + $('#edit_telephone_devis').val() + '" class="required number" minlength="10" maxlength="23"/> <label style="height:5px; display:block"></label>   </div> <br> <input type="button" class="button" value="' + $('#tr_get_a_estimate').val() + '" id="devis_par_mail" name="devis_par_mail" style="width:160px; margin-left:200px; margin-bottom:10px;text-transform:uppercase; color:#00815A; font-weight:bold; font-size:15px;" onclick="devis()"/> &nbsp;&nbsp;<input type="button" class="button" value="' + $('#tr_booking').val() + '" id="suivant" name="suivant_etap" style="width:200px; margin-bottom:10px;text-transform:uppercase; color:#00815A; font-weight:bold; font-size:15px;" onclick="get_booking()"/>'+ 
 	' <img src="' + getHost() + '/images/unlock.png" style="width:30px; vertical-align:middle"> <div style="margin-left:370px;font-size:10px">Réservation <b><span style="color:red">immédiate</span> (Paiement CB sécurisé)</b><br><br></div>'+																																																																																																																																																																																																																																																																											  	 '<input type="hidden" name="total_price" id="total_price" value="' + arrPrice[id_price] + '"/>'
					+'<input type="hidden" name="code_price_a" id="code_price_a" value="' + arrCaPrice[id_price] + '"/>'
					+'<input type="hidden" name="code_price_r" id="code_price_r" value="' + arrCrPrice[id_price] + '"/>'
					+'<input type="hidden" name="passengers_price" id="passengers_price" value="' + arrPPrice[id_price] + '"/>'
					+'<input type="hidden" name="rates_price" id="rates_price" value="' + arrRPrice[id_price] + '"/>'
					+'<input type="hidden" name="fee_price" id="fee_price" value="' + arrFPrice[id_price] + '"/>'
					+'<input type="hidden" name="restriction_acciona" id="restriction_acciona" value="' + arrRestrictionAcciona[id_price] + '"/>'
					+'<input type="hidden" name="restriction" id="restriction" value="' + arrRestriction[id_price] + '"/>' ).appendTo('#tarif_div')
 $('#'+id_price).attr('checked','checked');
                    } else {
                        if (ErrorCode == 101) {
                            $('#tarif_div').html("<font style=color:#F00>" + $('#tr_no_avai').val() + "</font>")
                        } else {
                            $('#tarif_div').html("<font style=color:#F00>" + $('#tr_err').val() + ".<br> Code Erreur : " + ErrorCode + "</font>")
                        }
                        $('#loadajax2').html('')
                    }
                }
                $('#loadajax2').html('')
            }
        })
    }
}


function liste_voyage() {
var shipcode = "";
var premier_aller=0;
var premier_retour=0;
var nb_aller=0;
var nb_retour=0;
var nb_voyages=0;	
	l=0;
    $('#tarif_div').html('');
    if ($("#form1").valid()) {
        if (document.getElementById('allerretour').checked == true) {
            var d_a = 0;
            var d1 = document.getElementById('date_aller').value;
            d_a = parseInt(d1.substring(6, 10) + "" + d1.substring(3, 5) + "" + d1.substring(0, 2));
            var d_r = 0;
            var d2 = document.getElementById('date_retour').value;
            d_r = parseInt(d2.substring(6, 10) + "" + d2.substring(3, 5) + "" + d2.substring(0, 2));
            if (d_a >= d_r) {
                $("#date_msg").dialog({
                    bgiframe: true,
                    modal: true,
                    title: 'Erreur Date',
                    buttons: {
                        Ok: function () {
                            $(this).dialog('destroy')
                        }
                    },
					 close: function () { $(this).dialog('destroy')}
                });
                return false
            }
        }
 
		$('#tariff,#suivant,#tarif,#booking,#smg_cabine,#msg_bebe_cabine').css('display', 'none');
        $('#loadajax1').html('<img src="' + getHost() + '/images/ajax-loader.gif"><p>' + $('#tr_wait').val() + ' ....</p>');
        $('#voyages').css('display', 'block');
        
        var veh = 0;
        if (document.getElementById('vehicule').checked == true) {
            veh = 1;
            var vehicule1 = document.getElementById('vehicule1').value;
            var vehicule2 = document.getElementById('vehicule2').value;

            if (vehicule1 == "CAR2") {
                vehicule1 = "CAR"
            }
            if (vehicule2 == "REM2") {
                vehicule2 = "REM"
            }
        }
        if (document.getElementById('aller').checked == false) {
            type = 1
        } else {
            type = 0
        }
        var adults = document.getElementById('adults').value;
        var enfants = document.getElementById('enfants').value;
        var passager = parseInt(adults) + parseInt(enfants);
        var origine = document.getElementById('origine').value;
        var destination = document.getElementById('destination').value;
        var date_dep = document.getElementById('date_aller').value;
        var date_ret = document.getElementById('date_retour').value;

        $('#aller_div').html('');
        $('#retour_div').html('');
        $.ajax({
            type: "POST",
            url: getHost() + "site/getJourneys",
            data: "depart=" + origine + "&arrive=" + destination + "&type=" + type + "&date_aller=" + date_dep + "&date_retour=" + date_ret + "&passager=" + passager + "&enfants=" + enfants + "&adults=" + adults + "&vehicule=" + veh + "&vehicule1=" + vehicule1 + "&vehicule2=" + vehicule2,
            dataType: "text",
            success: function (xml) {
				 //document.write(""+xml+"<XMP></XMP>");
                var xml = pxml(xml);
					//alert(xml);
                $('#p_r').css('display', 'none');
                var nbJourney = $(xml).find('nbJourney').text();
                if (nbJourney == "0") {
					 if (origine == "BCN" || destination == "BCN") {
$('<div  id="aucun_b" style="display:none; color:#666; font-size:14px;"></div>').html("La réservation pour cette date ("+date_dep+") n'est pas possible sur notre site. <br>Merci de nous appeler au <b style='color:red'>01 75 430 212</b> pour faire la réservation au téléphone avec nos conseillers<br><br>").appendTo('#aller_div');
                    $('#aucun_b').dialog({
                        bgiframe: true,
                        modal: true,
						width: 600,
                        title: 'Réserver par téléphone',
                        buttons: {
                            Ok: function () {
                                $(this).dialog('destroy')
                            }
                        }
                    });
 					hid();					
	
						return false;
                    }
					
$('<div  id="aucun_b" style="display:none; color:#666; font-size:16px; font-weight:600"></div>').html($('#tr_no_dep').val() + " " + date_dep).appendTo('#aller_div');
                    $('#aucun_b').dialog({
                        bgiframe: true,
                        modal: true,
                        title: 'Aucun depart',
                        buttons: {
                            Ok: function () {
                                $(this).dialog('destroy')
                            }
                        }
                    });
                    $('#msg_info').html('');
                    $('#loadajax1').html('')
                } else {
                    if (origine == "ALG" || destination == "ALG") {
                        $('#msg_info').html('ALGESIRAS-TANGER / ALGESIRAS-CEUTA : Les dates de retours sont indicatives.  Les  Billets sont  <b>"OPEN"</b> pour le RETOUR, valables 1 an à compter de la date d\'émission<br><br>').css('color', 'red')
                    }
 
var months = new Array('','Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre');
var arr = date_dep.split('/');
$('<table id="tbl_aller" class="dispotbl"><tr><td colspan="4"  class="t_header"> Départs disponibles le '+arr[0]+' '+months[parseInt(arr[1],10)]+' </td></tr><tr><td></td><td class="rownames">' + $('#tr_dep2').val() + '</td><td class="rownames">' + $('#tr_arr2').val() + '</td><td class="rownames">' + $('#tr_boat').val() + '</td></tr></table>').appendTo('#aller_div');
if(type == 1){
arr = date_ret.split('/');
$('<table id="tbl_retour" class="dispotbl"><tr><td colspan="4"  class="t_header"> Retours disponibles le '+arr[0]+' '+months[parseInt(arr[1],10)]+'  </td></tr><tr><td></td><td class="rownames">' + $('#tr_dep2').val() + '</td><td class="rownames">' + $('#tr_arr2').val() + '</td><td class="rownames">' + $('#tr_boat').val() + '</td></tr></table>').appendTo('#retour_div');} 
             
			 var hide_aller_checkbox = false;
			 var hide_retour_checkbox = false;
			nb_voyages = $(xml).find('voyage').length;
			if(nb_voyages == 1 && type == 0){hide_aller_checkbox = true;}
			if(nb_voyages == 2 && type == 1){hide_aller_checkbox = true; hide_retour_checkbox = true;}
			$(xml).find('voyage').each(function () {
                        l++;
                        var i = $(this).find('id_voyage').text();
                        var dep_time = $(this).find('dep_time').text();
                        var arr_time = $(this).find('arr_time').text();
                        var dep_date = $(this).find('dep_date').text();
                        var arr_date = $(this).find('arr_date').text();						
						
                        var type = $(this).find('type').text();
                        var shipcode = $(this).find('shipcode').text();
						var ship_description = $(this).find('ship_description').text();
                        var type_acc = "";
 
                        if (type == "aller") {  nb_aller++;
							if(premier_aller==0){premier_aller=l;}
                            div_v = "voyage_";

						    $('<tr><td rowspan="3"><input type="radio" name="time" id="time_' + l + '" value="" onclick="voy(' + l + ');"/></td> </tr><tr class="rowvals"><td>' + dep_date +' '+dep_time + ' </td><td>' + arr_date +' '+ arr_time + ' </td><td> <a href="'+getHost() +'site/ship/code/'+shipcode+'/dep/'+dep_time+'/arr/'+arr_time+'/?depd='+dep_date+'&arrd='+arr_date+'&from='+origine+'&to='+destination+'&width=300" class="jTip" id="ship'+l+'" name="'+ship_description+'">' + ship_description + '</a>  <input type="hidden" id="dep_time' + l + '" value="' + dep_time + '" />  <input type="hidden"  id="arr_time' + l + '" value="' + arr_time + '" /></td></tr><tr><td colspan="3" id="voyage_' + l + '"  class="borber_b"></td></tr>').appendTo('#tbl_aller');
							if(hide_aller_checkbox){$('#time_' + l ).hide();}
                        }
						
                        if (type == "retour") { nb_retour++;
							if(premier_retour==0){premier_retour=l;}
                            div_v = "voyage_r";
                            type_acc = "retour";
                            $('#p_r').css('display', 'inline');
 
						 $('<tr><td rowspan="3" ><input type="radio" name="time_r" id="time_r' + l + '" value="" onclick="voy2(' + l + ');"/></td> </tr><tr class="rowvals"><td>' + dep_date +' '+dep_time + ' </td><td>' + arr_date +' '+ arr_time + ' </td><td> <a href="'+getHost() +'site/ship/code/'+shipcode+'/dep/'+dep_time+'/arr/'+arr_time+'/?depd='+dep_date+'&arrd='+arr_date+'&from='+origine+'&to='+destination+'&width=300" class="jTip" id="ship'+l+'" name="'+ship_description+'">' + ship_description + '</a> <input type="hidden" id="dep_time_r' + l + '" value="' + dep_time + '" />  <input type="hidden"  id="arr_time_r' + l + '" value="' + arr_time + '" /></td></tr><tr><td colspan="3" id="voyage_r' + l + '"  class="borber_b"></td></tr>').appendTo('#tbl_retour');
                       if(hide_retour_checkbox){$('#time_r' + l ).hide();} 
					   }
						
                        var listes = "";
						var imgShared ="";
                        $(this).find('accommodations').each(function () {
                            var j = $(this).find('id').text();
                            var accommodation = $(this).find('accommodation').text();
                            var desc_accommodation = $(this).find('desc_accommodation').text();
if(desc_accommodation.search('[\*]')>-1 && passager!=4){$('#smg_cabine').css('display','block');
if($('#bebes').val()!='0'){$('#msg_bebe_cabine').css('display','block')}
 imgShared='<span class="mytip" title="Cette cabine est partagée avec d\'autres passagers."><img src="' + getHost() + 'images/shared.png"></span>';
 }
 if(desc_accommodation.search('[\*]')>-1 ){desc_accommodation = desc_accommodation.substring(0,desc_accommodation.length-3);}
                            if (type == "aller") {
                                listes += '<span class="accomo"><input type="radio" name="accommodation" id="accommodation_' + j + '" value="' + accommodation + '" onClick="aff_p()"/>' + desc_accommodation + imgShared + '</span><br />'
                            }
                            if (type == "retour") {
                                listes += '<span class="accomo"><input type="radio" name="accommodation_r" id="accommodation_r' + j + '" value="' + accommodation + '" onClick="aff_p()"/>' + desc_accommodation + imgShared+ '</span><br />'
                            }
                        });// end each accomo
                        $('<div class="liste" id="liste_' + type + '_' + l + '" style="display:none"></div>').html(listes).appendTo('#' + div_v + l + '');
                        $('#loadajax1').html('');
						
						 $('#aller_div input[type=radio]:first').attr('checked','checked'); voy(premier_aller); 
						 if(type == "retour" && premier_retour!=''){$('#retour_div input[type=radio]:first').attr('checked','checked');voy2(premier_retour);}
						
                    })
					 premier_aller=premier_retour=0; $('.mytip').tooltip();JT_init();
                }
                if (nb_aller == 0) {
                    $('#aller_div').html('<span style="color:#F00">' + $('#tr_no_aller').val() + '</span>')
                }
                if (nb_retour == 0 && type == 1) {
                    $('#retour_div').html('<span style="color:#F00">' + $('#tr_no_retour').val() + '</span>')
                }
            }
        })
    }
}
 
function devis(){
$('#jsuivant').attr('value','devis');
if($('#edit_devis_bookingnumber').val()!=''){$('<div id="bookingZ"></div>').html('<input type="hidden" name="BookingNumber" id="bookingNumber" value="' + $('#edit_devis_bookingnumber').val() + '" />').appendTo('#tarif_div');}

$('#form1').submit()
	}
function aff_p() {
   // $('#tarif_div').html('');
	$('#tariff').css('display', 'none');
    var i;
    var a = 0;
    var r = 0;
    var ty = 0;
    var msg = "";
    if (document.getElementById('aller').checked == false) {
        ty = 1
    } else {
        ty = 0
    }
    if (ty == "1") {
        $("input[type=radio]:checked").each(function (x) {
            msg = $(this).attr("name");
            if (msg == "accommodation") {
                a = 1
            }
            if (msg == "accommodation_r") {
                r = 1
            }
        });
        if (a == 1 && r == 1) {
            $('#tarif').css('display', 'inline')
        }
    } else {
        $('#tarif').css('display', 'inline')
    }
}
function aff_n(i) {
 
	$('#total_price').val(arrPrice[i]);
	$('#code_price_a').val(arrCaPrice[i]);
	$('#code_price_r').val(arrCrPrice[i]);
	$('#passengers_price').val(arrPPrice[i]);
	$('#rates_price').val(arrRPrice[i]);
	$('#fee_price').val(arrFPrice[i]);
	$('#restriction').val(arrRestriction[i]);
	$('#restriction_acciona').val(arrRestrictionAcciona[i]);

}
function cars() {
    hid();
	if ($('#vehicule2').val() == "") {$('#spanv2').css('display', 'none');}
	if ($('#vehicule1').val() == "") {$('#spanv').css('display', 'none');}
    if ($('#vehicule1').val() == "CAR") {
        $('#spanv').css('display', 'inline');
        $('#longueur_v1').val('4.50').addClass('required').rules("add", {
            min: 3,
            max: 7
        })
    }
    if ($('#vehicule1').val() == "CAR2") {
        $('#spanv').css('display', 'inline');
        $('#longueur_v1').val('4.50').addClass('required').rules("add", {
            min: 3,
            max: 9
        })
    }
    if ($('#vehicule1').val() == "FUR") {
        $('#spanv').css('display', 'inline');
        $('#longueur_v1').val('4.50').addClass('required').rules("add", {
            min: 3,
            max: 9
        })
    }
    if ($('#vehicule1').val() == "BUS") {
        $('#spanv').css('display', 'inline');
        $('#longueur_v1').val('10.00').addClass('required').rules("add", {
            min: 1,
            max: 12
        })
    }
    if ($('#vehicule1').val() == "MHO") {
        $('#spanv').css('display', 'inline');
        $('#longueur_v1').val('0.00').addClass('required').rules("add", {
            min: 1,
            max: 12
        })
    }
    if ($('#vehicule2').val() != "") {
        $('#spanv2').css('display', 'inline');
        $('#longueur_v2').val('5.00').addClass('required').rules("add", {
            min: 1,
            max: 12
        })
    }	
	
    if ($('#vehicule1').val() == "M1") {
        $('#spanv').css('display', 'none')
    }
    if ($('#vehicule1').val() == "M2") {
        $('#spanv').css('display', 'none')
    }
    if ($('#vehicule1').val() == "M3") {
        $('#spanv').css('display', 'none')
    }
}
function voy(num) {
	
    $('#tariff').css('display', 'none');
    $('#booking').css('display', 'none');
    dep_time = document.getElementById('dep_time' + num).value;
    arr_time = document.getElementById('arr_time' + num).value;
    $('#deptime').val(dep_time);
    $('#arrtime').val(arr_time);
	
    for (i = 1; i <= 80; i++) {
        if (document.getElementById('liste_aller_' + i)) {
            document.getElementById('liste_aller_' + i).style.display = "none"
        }
    }
    if (document.getElementById('time_' + num)) {
        if (document.getElementById('time_' + num).checked == true) {
            document.getElementById('liste_aller_' + num).style.display = "block";
			$('#liste_aller_' + num+' input[type=radio]:first').attr('checked','checked');aff_p();//1er classe checked
        }
    }
	
}
function voy2(num) {
    dep_time_r = document.getElementById('dep_time_r' + num).value;
    arr_time_r = document.getElementById('arr_time_r' + num).value;
    $('#deptimer').val(dep_time_r);
    $('#arrtimer').val(arr_time_r);
    $('#tariff').css('display', 'none');
    $('#booking').css('display', 'none');
    for (i = 1; i <= 160; i++) {
        if (document.getElementById('liste_retour_' + i)) {
            document.getElementById('liste_retour_' + i).style.display = "none"
        }
    }
    if (document.getElementById('time_r' + num)) {
        if (document.getElementById('time_r' + num).checked == true) {
            document.getElementById('liste_retour_' + num).style.display = "block";
			$('#liste_retour_' + num+' input[type=radio]:first').attr('checked','checked');aff_p();
        }
    }
}
function vih() {
    hid();
    if (document.getElementById('vehicule').checked == true) {
        document.getElementById('vih').style.display = 'block';
        $('#vehicule1').addClass('required')
    } else {
        document.getElementById('vih').style.display = "none";
        $('#vehicule1').removeClass('required')
    }
}
function adu() {
    hid();
    var ad = document.getElementById('adults').value;
    if (ad == '1') {
        del2();
        document.getElementById('enfants').options[0] = new Option('0', '0');
        document.getElementById('enfants').options[1] = new Option('1', '1');
        document.getElementById('enfants').options[2] = new Option('2', '2');
        document.getElementById('enfants').options[3] = new Option('3', '3');
        document.getElementById('len').style.visibility = "visible"
    }
    if (ad == '2') {
        del2();
        document.getElementById('enfants').options[0] = new Option('0', '0');
        document.getElementById('enfants').options[1] = new Option('1', '1');
        document.getElementById('enfants').options[2] = new Option('2', '2');
        document.getElementById('len').style.visibility = "visible"
    }
    if (ad == '3') {
        del2();
        document.getElementById('enfants').options[0] = new Option('0', '0');
        document.getElementById('enfants').options[1] = new Option('1', '1');
        document.getElementById('len').style.visibility = "visible"
    }
    if (ad == '4') {
        del2();
        document.getElementById('len').style.visibility = "hidden"
    }
}
function typ() {
    hid();
    if (document.getElementById('aller').checked == true) {
        document.getElementById('div_date_retour').style.display = "none";
        $('#date_retour').removeClass('required date')
    }
    if (document.getElementById('allerretour').checked == true) {
        document.getElementById('div_date_retour').style.display = "inline";
        $('#date_retour').addClass('required date')
    }
$('.date').change(function(){$("label.error").hide(); $(".error").removeClass('error');});	
}
function hid() {
   // $('#booking').html('');
    $('#msg_info').html('');
    $('#tarif_div').html('');
    $('#contacdiv').html('');
    $('#voyages').css('display', 'none');
    $('#tariff').css('display', 'none');
    $('#booking').css('display', 'none')
}
var from;
var to;
function e_age(){
//div_age en_age
from = $('#origine').val();
to = $('#destination').val();
if((from=="ALG" && to=="TNG") || (from=="TNG" && to=="ALG") || (from=="TNG" && to=="BCN") || (from=="BCN" && to=="TNG")){
	$('#div_age').html('[4 - 11]');$('#en_age').val('[4 - 11]'); $('#bebe_age').html('[0 - 4]');$('#be_age').val('[0 - 4]');
	$('#lien_age_enfants,#lien_age_bebes').attr('href',getHost()+'site/age/de/4/a/11/?width=520');}//ALGESIRAS-TANGER  & BARCELONE-TANGER
else if((from=="ALG" && to=="CEU") || (from=="CEU" && to=="ALG")||//ALGESIRAS-CEUTA
		(from=="AGP" && to=="MLN") || (from=="MLN" && to=="AGP")||//MALAGA-MELILLA							   
		(from=="LEI" && to=="MLN") || (from=="MLN" && to=="LEI") //ALMERIA-MELILLA
		){$('#div_age').html('[2 - 13]');$('#en_age').val('[2 - 13]');$('#bebe_age').html('[0 - 2]');$('#be_age').val('[0 - 2]');
$('#lien_age_enfants,#lien_age_bebes').attr('href',getHost()+'site/age/de/2/a/13/?width=520');}
else{$('#div_age').html('[2 - 11]');$('#en_age').val('[2 - 11]');$('#bebe_age').html('[0 - 2]');$('#be_age').val('[0 - 2]');
$('#lien_age_enfants,#lien_age_bebes').attr('href',getHost()+'site/age/de/2/a/11/?width=520');} //par defaut
	}
function del2() {
    document.getElementById('enfants').length = 1
}
function del() {
    document.getElementById('destination').length = 1
}
function ori() {
    hid();
    var or = document.getElementById('origine').value;
    var pos_h = document.getElementById('pos_h').value;
    if (pos_h == 0) {
        if (or == "LEI") {
            del();
            document.getElementById('destination').options[1] = new Option('GHAZAOUET', 'GHA');
            document.getElementById('destination').options[2] = new Option('ORAN', 'ORN')
        }
        if (or == "GHA") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI')
        }
        if (or == "ORN") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI')
        }
    } else {
        if (or == "LEI") {
            del();
            document.getElementById('destination').options[1] = new Option('NADOR', 'NDR');
            document.getElementById('destination').options[2] = new Option('MELILLA', 'MLN');
            document.getElementById('destination').options[3] = new Option('GHAZAOUET', 'GHA');
            document.getElementById('destination').options[4] = new Option('ORAN', 'ORN');
        }
        if (or == "AGP") {
            del();
            document.getElementById('destination').options[1] = new Option('MELILLA', 'MLN');
        }
        if (or == "ALG") {
            del();
            document.getElementById('destination').options[1] = new Option('TANGER MED', 'TGM');
            document.getElementById('destination').options[2] = new Option('CEUTA', 'CEU');
        }
        if (or == "NDR") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI');
        }
        if (or == "ORN") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI');
        }
        if (or == "MLN") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI');
            document.getElementById('destination').options[2] = new Option('MALAGA', 'AGP');
        }
        if (or == "GHA") {
            del();
            document.getElementById('destination').options[1] = new Option('ALMERIA', 'LEI')
        }
        if (or == "TNG") {
            del();
			//document.getElementById('destination').options[1] = new Option('ALGECIRAS', 'ALG');
			document.getElementById('destination').options[1] = new Option('BARCELONE', 'BCN');
        }
		if (or == "BCN") {
            del();
            document.getElementById('destination').options[1] = new Option('TANGER VILLE', 'TNG');
        }
		if (or == "TGM") {
            del();
            document.getElementById('destination').options[1] = new Option('ALGECIRAS', 'ALG');
        }		
        if (or == "CEU") {
            del();
            document.getElementById('destination').options[1] = new Option('ALGECIRAS', 'ALG');
        }
    }
}


var t = 14;
var x = 2;
var d = new Date();
var mnt=Date.parse(d);
var arr= new Array(d.getDate(),d.getMonth()+1,d.getFullYear());
var e_max=0;
var e_min=0;
var min_date_enfant = '';
var max_date_enfant = '';
var min_date_adult = '';
var max_date_adult = '';
var min_date_bebe = '';
var max_date_bebe = '';

$(document).ready(function () {
    $("#date_aller").datepicker({
		numberOfMonths:2,
        minDate: 0,
		showAnim: 'fadeIn',
        dateFormat: 'dd/mm/yy'
    });

    $(".dat").datepicker({
        minDate: 0,
		showAnim: 'fadeIn',
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd/mm/yy'
    });

	if($("#date_aller").val()){
	var en_age = $("#en_age").val();
	 switch(en_age){
		case '[2 - 13]' : x=e_min =2;t=e_max =13; break;//+0
		case '[2 - 11]' : x=e_min =2;t=e_max =11; break;//+0
		case '[4 - 11]' : x=e_min =4;t=e_max =11; break;//+0
		 }
	}
	
	max_date_adult = new Date(arr[2]-e_max,arr[1]-1,arr[0]);
    $(".date_naiss").datepicker({ 
		yearRange: '1945:'+(arr[2]-e_max),
        maxDate: max_date_adult ,
		minDate: new Date(1945,0,1),/*'-11y',*/
        changeMonth: true,
        changeYear: true
       
    });
	
	max_date_enfant = new Date(arr[2]-e_min,arr[1]-1,arr[0]);
	min_date_enfant = new Date(arr[2]-e_max,arr[1]-1,arr[0]-(-1));
    $(".date_naiss_e").datepicker({
		yearRange: '1945:'+(arr[2]-e_min),
		maxDate: max_date_enfant,
		minDate: min_date_enfant, //year, month, day
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd/mm/yy'
    })
	//max_date_bebe = new Date(arr[2],arr[1]-1,arr[0]);
	min_date_bebe = new Date(arr[2]-e_min,arr[1]-1,arr[0]-(-1));
	    $(".date_naiss_b").datepicker({
        maxDate: 0,
		minDate: min_date_bebe,
		showAnim: 'fadeIn',
        changeMonth: true,
        changeYear: true,
        dateFormat: 'dd/mm/yy'
    })	
	$("#date_retour").focus(function(){

  var nowdate = new Date();
  var date1 = nowdate.getDate()+'/'+(nowdate.getMonth()+1)+'/'+nowdate.getFullYear();
  var date2 = $("#date_aller").val();
  date1 = date1.split("/");
  date2 = date2.split("/");
  var sDate = new Date(date1[1]+"/"+date1[0]+"/"+date1[2]);
  var eDate = new Date(date2[1]+"/"+date2[0]+"/"+date2[2]);
  var days = Math.abs(Math.round((sDate-eDate)/86400000))+1;
 
		$("#date_retour").datepicker( 'destroy' ).datepicker({
		numberOfMonths:2,
		showAnim: 'fadeIn',
        minDate:  +days,
        dateFormat: 'dd/mm/yy',
		Jdays:data_r
		});
 });		
			
});
var a = 0;
var e = 0;
var j = 1;
var vid = false;
var data_r;
$(document).ready(function () {
	
	$('#origine,#destination,#allerretour').change(function () {
	$("#date_aller").val('');$("#date_retour").val('');
	var f = $('#origine').val();
	var t = $('#destination').val();
	if(f!='' && t!=''){$('#dispo_load').fadeIn();
	 $.post(getHost() + "site/dispo", { from: f, to: t },
  	 function(data){
     $("#date_aller").datepicker( 'destroy' ).datepicker({
		numberOfMonths:2,
        minDate: 0,
		showAnim: 'fadeIn',
        dateFormat: 'dd/mm/yy',
		Jdays:data
    });
  }); 
	 if(document.getElementById('aller').checked == false){
	 $.post(getHost() + "site/dispo", { from: t, to: f },
  	 function(data){
		 data_r = data;
		 });
	 }
	 $('#dispo_load').fadeOut();}
});
	
	
    $('.date_naiss').change(function () {
        if ($(this).val().length != 10 && $(this).val().length != "") {
            $(this).val("")
        }
    });
    $('.date_naiss_e').change(function () {
        if ($(this).val().length != 10 && $(this).val().length != "") {
            $(this).val("")
        }
    });
    $('.dat').blur(function () {
        if ($(this).val().length != 10 && $(this).val().length != "") {
            $(this).val("")
        }
    });
    $('.rappelle').click(function () {
        $("#dialog").dialog({
            bgiframe: true,
            autoOpen: true,
            height: 550,
            width: 370,
            modal: true,
            buttons: {
                'Rappeler moi': function () {
                    if ($("#frm").valid()) {
                        var nom = $('#nom').val();
                        var telephone = $('#telephone').val();
                        var comm = $('#comm').val();
						 var email = $('#email').val();
                        $.ajax({
                            type: "POST",
                            url: getHost() + "site/Rapelle",
                            data: "nom=" + nom + "& telephone=" + telephone + "& comm=" + comm + "& email=" + email,
                            success: function () {
                                $('#frm').hide();
                                $('div.success').fadeIn()
                            }
                        })
                    }
                    return false
                },
                Fermer: function () {
                    $(this).dialog('destroy')
                }
            },
            close: function () {
                $(this).dialog('destroy')
            }
        })
    });
    $('#suivant2').click(function () {
        var vide = false;
        var msg = "";
        var msg2 = "";
        var a = $('#adults').val();
        var e = $('#enfants').val();
        var dat = new Date();
/**/		$('#form1 input[type=text],select').each(function(){
			$(this).css('border-color', '#CCC');
			if($(this).val()==''){$(this).css('border-color', 'red'); msg = $('#tr_all').val();  vide = true; return false;}
			});

 if (vide == false) { 
        $('.date_naiss').each(function () {
            $(this).css('border-color', '#CCC');
           
            var d1 = $(this).attr("value");
			var this_date_naissance = new Date(d1.substring(6, 10),d1.substring(3, 5),d1.substring(0, 2));
			
            //if (this_date_naissance.getTime()>min_date_bebe.getTime()) {
			 if (compare_date(this_date_naissance ,max_date_adult,+1)==false) {
                msg+= 'La date naissance de l\'adulte est incorrect \n (un adulte doit etre né avant '+max_date_adult.getDate()+'/'+(max_date_adult.getMonth() < 11 ? '0' : '') + (max_date_adult.getMonth() + 1)+'/'+max_date_adult.getFullYear()+')';
                vide = true;
                $(this).css('border-color', 'red')
            }
        });/**/
}        
 if (vide == false) {
        $('.date_naiss_e').each(function () {
            $(this).css('border-color', '#CCC');
            var d1 = $(this).attr("value");
			var this_date_naissance = new Date(d1.substring(6, 10),d1.substring(3, 5),d1.substring(0, 2));
           // if (this_date_naissance.getTime()<min_date_enfant.getTime() || this_date_naissance.getTime()>max_date_enfant.getTime()) {
			if (compare_date(min_date_enfant,this_date_naissance,-1)==false || compare_date(this_date_naissance,max_date_enfant,+1)==false ) {
 msg+= 'La date naissance de l\'enfait est incorrect \n (l\'enfant doit etre né entre '+min_date_enfant.getDate()+'/'+(min_date_enfant.getMonth() < 11 ? '0' : '') + (min_date_enfant.getMonth() + 1)+'/'+min_date_enfant.getFullYear()+' et '+max_date_enfant.getDate()+'/'+(max_date_enfant.getMonth() < 11 ? '0' : '') + (max_date_enfant.getMonth() + 1)+'/'+max_date_enfant.getFullYear()+')';
                vide = true;
                $(this).css('border-color', 'red')
            }
        });
 }
 
 if (vide == false) {
        $('.date_naiss_b').each(function () {
            $(this).css('border-color', '#CCC');
           
            var d1 = $(this).attr("value");
			var this_date_naissance = new Date(d1.substring(6, 10),d1.substring(3, 5),d1.substring(0, 2));
			
			//if (this_date_naissance.getTime()<min_date_bebe.getTime()) {
			if (compare_date(min_date_bebe,this_date_naissance,-1)==false || compare_date(this_date_naissance,d,+1)==false ) {
                msg+= 'La date naissance du bébé est incorrect \n (un bébé doit etre né entre '+min_date_bebe.getDate()+'/'+(min_date_bebe.getMonth() < 11 ? '0' : '') + (dat.getMonth() + 1)+'/'+min_date_bebe.getFullYear()+' et '+d.getDate()+'/'+(d.getMonth() < 11 ? '0' : '') + (d.getMonth() + 1)+'/'+d.getFullYear()+')';
                vide = true;
                $(this).css('border-color', 'red')
            }
        });
 }	
 

       /* for (i = 0; i <= a + 1; i++) {
            if ($('#nat' + i).val() == "") {
                vide = true;
                msg = "- " + $('#tr_nat').val()
            }
        }
        for (i = 0; i <= e + 1; i++) {
            if ($('#natE' + i).val() == "") {
                vide = true;
                msg = "- " + $('#tr_nat').val()
            }
        }*/
        if (vide == true) {
            alert(msg + msg2);
            vide = false;
            msg = "";
            return false
        }
    });
	
	
	$('.date').change(function(){$("label.error").hide(); $(".error").removeClass('error');});	
    $("#form1").validate();
    $("#frm").validate()
			 
	
});
function pxml(xml) {
    if (jQuery.browser.msie) {
        var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.loadXML(xml);
        xml = xmlDoc
    }
    return xml
}
function acc(objInput) {
    var reg = /^[a-zA-Z\s]*$/;
    objInput.value = objInput.value.replace('é', 'e');
    objInput.value = objInput.value.replace('è', 'e');
    objInput.value = objInput.value.replace('à', 'a');
    objInput.value = objInput.value.replace('ç', 'c');
    objInput.value = objInput.value.replace('ù', 'u');
    if (!reg.test(objInput.value)) {
        objInput.value = objInput.value.substring(0, objInput.value.length - 1);
	 acc(objInput);
    }
}
function passeport(objInput) {
    var reg = /^[a-zA-Z0-9]*$/;
    objInput.value = objInput.value.replace('é', 'e');
    objInput.value = objInput.value.replace('è', 'e');
    objInput.value = objInput.value.replace('à', 'a');
    objInput.value = objInput.value.replace('ç', 'c');
    objInput.value = objInput.value.replace('ù', 'u');
    if (!reg.test(objInput.value)) {
        objInput.value = objInput.value.substring(0, objInput.value.length - 1);
		passeport(objInput);
    }
}
var vill = "";
function vil(vill) {
    switch (vill) {
    case 'LEI':
        vill = "ALMERIA";
        break;
    case 'NDR':
        vill = "NADOR";
        break;
    case 'ALG':
        vill = "ALGECIRAS";
        break;
    case 'TNG':
        vill = "TANGER";
        break;
    case 'CEU':
        vill = "CEUTA";
        break;
    case 'AGP':
        vill = "MALAGA";
        break;
    case 'MLN':
        vill = "MELILLA";
        break;
    case 'GHA':
        vill = "GHAZAOUET";
        break;
    case 'ORN':
        vill = "ORAN";
        break
	case 'BCN':
        vill = "BARCELONE";
        break	
    }
    return vill
}
function getHost() {
    var host = $('#host').val();
    if (host == "localhost") {
        var site = "http://localhost/job/YII_MF/"
    } else {
        var site = "http://"+host+"/"
    }
    return site;
}

function compare_date(date_1,date_2,i){
	var a = date_1.getFullYear()+(date_1.getMonth() < 11 ? '0' : '') + (date_1.getMonth())+(date_1.getDate() < 11 ? '0' : '') + (date_1.getDate());
	var b = date_2.getFullYear()+(date_2.getMonth() < 11 ? '0' : '') + (date_2.getMonth()+i)+(date_2.getDate() < 11 ? '0' : '') + (date_2.getDate());
	//alert(a+' <= '+b);
	if(a<=b){return true;}
	return false;
	}

function checkAll(sid,sclass){
 $('.'+sclass).each(function(){
 if($('#'+sid).is(':checked')){
$(this).attr("checked","checked");
 }else{ $(this).removeAttr("checked");}
 });	
}
/*
 * jQuery Tooltip plugin 1.3
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}(';(8($){j e={},9,m,B,A=$.2u.2g&&/29\\s(5\\.5|6\\.)/.1M(1H.2t),M=12;$.k={w:12,1h:{Z:25,r:12,1d:19,X:"",G:15,E:15,16:"k"},2s:8(){$.k.w=!$.k.w}};$.N.1v({k:8(a){a=$.1v({},$.k.1h,a);1q(a);g 2.F(8(){$.1j(2,"k",a);2.11=e.3.n("1g");2.13=2.m;$(2).24("m");2.22=""}).21(1e).1U(q).1S(q)},H:A?8(){g 2.F(8(){j b=$(2).n(\'Y\');4(b.1J(/^o\\(["\']?(.*\\.1I)["\']?\\)$/i)){b=1F.$1;$(2).n({\'Y\':\'1D\',\'1B\':"2r:2q.2m.2l(2j=19, 2i=2h, 1p=\'"+b+"\')"}).F(8(){j a=$(2).n(\'1o\');4(a!=\'2f\'&&a!=\'1u\')$(2).n(\'1o\',\'1u\')})}})}:8(){g 2},1l:A?8(){g 2.F(8(){$(2).n({\'1B\':\'\',Y:\'\'})})}:8(){g 2},1x:8(){g 2.F(8(){$(2)[$(2).D()?"l":"q"]()})},o:8(){g 2.1k(\'28\')||2.1k(\'1p\')}});8 1q(a){4(e.3)g;e.3=$(\'<t 16="\'+a.16+\'"><10></10><t 1i="f"></t><t 1i="o"></t></t>\').27(K.f).q();4($.N.L)e.3.L();e.m=$(\'10\',e.3);e.f=$(\'t.f\',e.3);e.o=$(\'t.o\',e.3)}8 7(a){g $.1j(a,"k")}8 1f(a){4(7(2).Z)B=26(l,7(2).Z);p l();M=!!7(2).M;$(K.f).23(\'W\',u);u(a)}8 1e(){4($.k.w||2==9||(!2.13&&!7(2).U))g;9=2;m=2.13;4(7(2).U){e.m.q();j a=7(2).U.1Z(2);4(a.1Y||a.1V){e.f.1c().T(a)}p{e.f.D(a)}e.f.l()}p 4(7(2).18){j b=m.1T(7(2).18);e.m.D(b.1R()).l();e.f.1c();1Q(j i=0,R;(R=b[i]);i++){4(i>0)e.f.T("<1P/>");e.f.T(R)}e.f.1x()}p{e.m.D(m).l();e.f.q()}4(7(2).1d&&$(2).o())e.o.D($(2).o().1O(\'1N://\',\'\')).l();p e.o.q();e.3.P(7(2).X);4(7(2).H)e.3.H();1f.1L(2,1K)}8 l(){B=S;4((!A||!$.N.L)&&7(9).r){4(e.3.I(":17"))e.3.Q().l().O(7(9).r,9.11);p e.3.I(\':1a\')?e.3.O(7(9).r,9.11):e.3.1G(7(9).r)}p{e.3.l()}u()}8 u(c){4($.k.w)g;4(c&&c.1W.1X=="1E"){g}4(!M&&e.3.I(":1a")){$(K.f).1b(\'W\',u)}4(9==S){$(K.f).1b(\'W\',u);g}e.3.V("z-14").V("z-1A");j b=e.3[0].1z;j a=e.3[0].1y;4(c){b=c.2o+7(9).E;a=c.2n+7(9).G;j d=\'1w\';4(7(9).2k){d=$(C).1r()-b;b=\'1w\'}e.3.n({E:b,14:d,G:a})}j v=z(),h=e.3[0];4(v.x+v.1s<h.1z+h.1n){b-=h.1n+20+7(9).E;e.3.n({E:b+\'1C\'}).P("z-14")}4(v.y+v.1t<h.1y+h.1m){a-=h.1m+20+7(9).G;e.3.n({G:a+\'1C\'}).P("z-1A")}}8 z(){g{x:$(C).2e(),y:$(C).2d(),1s:$(C).1r(),1t:$(C).2p()}}8 q(a){4($.k.w)g;4(B)2c(B);9=S;j b=7(2);8 J(){e.3.V(b.X).q().n("1g","")}4((!A||!$.N.L)&&b.r){4(e.3.I(\':17\'))e.3.Q().O(b.r,0,J);p e.3.Q().2b(b.r,J)}p J();4(7(2).H)e.3.1l()}})(2a);',62,155,'||this|parent|if|||settings|function|current||||||body|return|||var|tooltip|show|title|css|url|else|hide|fade||div|update||blocked|||viewport|IE|tID|window|html|left|each|top|fixPNG|is|complete|document|bgiframe|track|fn|fadeTo|addClass|stop|part|null|append|bodyHandler|removeClass|mousemove|extraClass|backgroundImage|delay|h3|tOpacity|false|tooltipText|right||id|animated|showBody|true|visible|unbind|empty|showURL|save|handle|opacity|defaults|class|data|attr|unfixPNG|offsetHeight|offsetWidth|position|src|createHelper|width|cx|cy|relative|extend|auto|hideWhenEmpty|offsetTop|offsetLeft|bottom|filter|px|none|OPTION|RegExp|fadeIn|navigator|png|match|arguments|apply|test|http|replace|br|for|shift|click|split|mouseout|jquery|target|tagName|nodeType|call||mouseover|alt|bind|removeAttr|200|setTimeout|appendTo|href|MSIE|jQuery|fadeOut|clearTimeout|scrollTop|scrollLeft|absolute|msie|crop|sizingMethod|enabled|positionLeft|AlphaImageLoader|Microsoft|pageY|pageX|height|DXImageTransform|progid|block|userAgent|browser'.split('|'),0,{}))
$(document).ready(JT_init);function JT_init(){$("a.jTip").hover(function(){JT_show(this.href,this.id,this.name)},function(){$('#JT').remove()}).click(function(){return false});}
function JT_show(url,linkId,title){if(title==false)title=" ";var de=document.documentElement;var w=self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;var hasArea=w-getAbsoluteLeft(linkId);var clickElementy=getAbsoluteTop(linkId)-3;var queryString=url.replace(/^[^\?]+\??/,'');var params=parseQuery(queryString);if(params['width']===undefined){params['width']=250};if(params['link']!==undefined){$('#'+linkId).bind('click',function(){window.location=params['link']});$('#'+linkId).css('cursor','pointer');}
if(hasArea>((params['width']*1)+75)){$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_left'></div><div id='JT_close_left'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");var arrowOffset=getElementWidth(linkId)+11;var clickElementx=getAbsoluteLeft(linkId)+arrowOffset;}else{$("body").append("<div id='JT' style='width:"+params['width']*1+"px'><div id='JT_arrow_right' style='left:"+((params['width']*1)+1)+"px'></div><div id='JT_close_right'>"+title+"</div><div id='JT_copy'><div class='JT_loader'><div></div></div>");var clickElementx=getAbsoluteLeft(linkId)-((params['width']*1)+15);}
$('#JT').css({left:clickElementx+"px",top:clickElementy+"px"});$('#JT').show();$('#JT_copy').load(url);}
function getElementWidth(objectId){x=document.getElementById(objectId);return x.offsetWidth;}
function getAbsoluteLeft(objectId){o=document.getElementById(objectId)
oLeft=o.offsetLeft
while(o.offsetParent!=null){oParent=o.offsetParent
oLeft+=oParent.offsetLeft
o=oParent}
return oLeft}
function getAbsoluteTop(objectId){o=document.getElementById(objectId)
oTop=o.offsetTop
while(o.offsetParent!=null){oParent=o.offsetParent
oTop+=oParent.offsetTop
o=oParent}
return oTop}
function parseQuery(query){var Params=new Object();if(!query)return Params;var Pairs=query.split(/[;&]/);for(var i=0;i<Pairs.length;i++){var KeyVal=Pairs[i].split('=');if(!KeyVal||KeyVal.length!=2)continue;var key=unescape(KeyVal[0]);var val=unescape(KeyVal[1]);val=val.replace(/\+/g,' ');Params[key]=val;}
return Params;}
function blockEvents(evt){if(evt.target){evt.preventDefault();}else{evt.returnValue=false;}}