function UTIL_showHideLayers() {
  var i,p,v,obj,args=UTIL_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=UTIL_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='block')?'block':(v='none')?'none':v; }
    obj.display=v; }
}

function MM_findObj2(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj2(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function retour_message() {
document.formulaire.Submit.value="Veuillez patienter ....";
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj2(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Champs non renseignés ou incorrects! ');
  document.MM_returnValue = (errors == '');
}
function UTIL_findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=UTIL_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var tablou=new Array;
tablou[1]="off";
tablou[2]="off";
tablou[3]="off";
tablou[4]="off";
tablou[5]="off";
tablou[6]="off";
tablou[7]="off";
/*tablou[8]="off";
tablou[9]="off";*/

var tablou_ss=new Array;
tablou_ss[1]="off";
tablou_ss[2]="off";
tablou_ss[3]="off";
tablou_ss[4]="off";
tablou_ss[5]="off";
tablou_ss[6]="off";
tablou_ss[7]="off";
/*tablou_ss[8]="off";
tablou_ss[9]="off";
tablou_ss[10]="off";*/

function affiche_menu(n) {
  var p;
  p='menu_contenu_'+n;

  if (tablou[n]=="off") {
  UTIL_showHideLayers('menu_contenu_'+n,'','block');
  tablou[n]="on";
  }
  else{
  UTIL_showHideLayers('menu_contenu_'+n,'','none');
  tablou[n]="off";
  }
}
function affiche_ss_menu(n) {
  var p;
  p='menu_ss_contenu_'+n;

  if (tablou_ss[n]=="off") {
  UTIL_showHideLayers('menu_ss_contenu_'+n,'','block');
  tablou_ss[n]="on";
  }
  else{
  UTIL_showHideLayers('menu_ss_contenu_'+n,'','none');
  tablou_ss[n]="off";
  }
}

function my_heart(){
window.location.href="produit.php?id="+document.getElementById('raysearch').options[document.getElementById('raysearch').selectedIndex].value;
}








function and_DIVfc(nb){

    $.post('http://www.voyages-duclos.com/choix_vehicule.php',{ nb : nb
	 }, function(data) {

  			$('#vehicule').html(data);
		});


	document.getElementById('and_DIV').innerHTML='' ;
	document.getElementById('and_DIV').innerHTML+='voulez vous renseigner les informations pour chaque personne ?<br /><center><table><tr><td><input type="image" src="button_oui.png" onclick="infos_nb_pers(); "/></td><td><div style="width:20px;"></td><td><input type="image" src="button_non.png" onclick="infos_nb_pers_false();"></center></td></tr></table>';



}

function infos_nb_pers_false(){
       document.getElementById('and_DIV').innerHTML=' ';
}

function infos_nb_pers()
{



 var string="";


     var nb = document.getElementById("nb_part").options[document.getElementById("nb_part").selectedIndex].value;
    document.getElementById('and_DIV').innerHTML='' ;





			    for(i=1;i<=nb;i++)
			    {
			      string += "<div class='bg"+i%2+"'><font size='2' color='#404040'>Nom :</font><input type='text' id='nom_part"+i+"' 					name='nom_part"+i+"'><font size='2' color='#404040'>&nbsp;Pr&eacute;nom :</font><input type='text' id='prenom_part"+				  i+"' name='prenom_part"+i+"'><font size='2' color='#404040'>Personne majeure</font><input type='checkbox'        						name='majeure"+i+"' id='majeure' value='1'><br /><div>";

				}
                document.getElementById('and_DIV').innerHTML=string;









    for(i=1;i<=nb;i++)
    {
	    	$(function() {
    		$("#date_anniv"+i).datepicker();
            $("#format").value = "mm/dd/yy";
    		$("#format").change(function() { $('#date_anniv'+i).datepicker('option', {dateFormat: $(this).val()}); });
    	});
	}


}

//VERIFICATION DU FORMULAIRE

    function reponse_mail(){
    	var display_form = document.getElementsByClassName('form_display'),j;

		for(i=0,j=display_form.length;i<j;i++){
			display_form[i].style.display="none";
		}
    	$.post('http://www.voyages-duclos.com/mail_transfert-reservation.php',{ id_transfert: $('#depart').val(),
		date_transfert: $('#date_transfert').val(),heureDep: $('#heureDep').val(),
		minDep: $('#minDep').val(), nb_part: $('#nb_part').val() }, function(data) {

  			$('#success').html(data);
		});
		return false;
    }
	function check_form(champ, regex_valid){


	  if((document.getElementById(champ).value != "")&&
	   (regex_valid.test(document.getElementById(champ).value))){
            document.getElementById(champ).style.border="1px solid green";
            return false;

		  }

	  else {
		    document.getElementById('error_msg').innerHTML+='Veuillez verifier le champ '
			+ document.getElementById(champ).name +'.<br/>';
			document.getElementById(champ).style.border="1px solid red";

	    	return false;
	  }
	}
    function valid_form(){

    	var regex_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	  	var regex_string =/^([a-zA-ZàÀáÁâÂãÃäÄåÅæÆçÇèÈéÉêÊëËìÌíÍîÎïÏñÑòÒóÓôÔõÕöÖùÙúÚûÛüÜÝœŒ\.\-])+$/;
		var regex_tel =/^([0-9_\.\-]){10,13}$/;
		var regex_date = /^.*$/;
        document.getElementById('error_msg').innerHTML="";

		check_form('mail', regex_mail);
		check_form('nom', regex_string);
		check_form('prenom', regex_string);
		check_form('tel', regex_tel);
		check_form('date_transfert', regex_date);

       if(document.getElementById('error_msg').innerHTML==''){

		/*var mavar = $("#date_transfert").val();
		$.get('http://www.voyages-duclos.com/tarif.php?nom='+mavar+'&test2=2', function(data) {
		  $('#error_msg').html("Votre tarif est de : "+data+" €");
		}); */

		$.post('http://www.voyages-duclos.com/calcul_tarif.php',{ id_transfert: $('#depart').val(),
		date_transfert: $('#date_transfert').val(),heureDep: $('#heureDep').val(),
		minDep: $('#minDep').val(), nb_part: $('#nb_part').val() }, function(data) {

  			$('#result_tarif').html(data);
		});

			document.getElementById('validation').innerHTML='<input type="image" src="http://www.voyages-duclos.com/images/button_demande_devis.png" />';




       		return false;
       }else{
	   		return false;
      }

    }


