 

window.onload=montre;

function montre(id) {
	var d = document.getElementById(id);
		for (var i = 1; i<=10; i++) {
			if (document.getElementById('smenu'+i)) {document.getElementById('smenu'+i).style.display='none';}
		}
	if (d) {d.style.display='block';}
}

function newverifdevis(){


 	var frmObj = document.devisForm;
 	
 	var dest = frmObj.destination.value;
 	//var veh = frmObj.voiture.value;
 	
 	/* Date Fin */
 	
 	var datedeb=frmObj.date1.value;
 	var tabDateSt = datedeb.split('/');

 	frmObj.jourdebut.value= tabDateSt[0];
 	frmObj.moisdebut.value=tabDateSt[1];
 	frmObj.anneedebut.value=tabDateSt[2];
 	
	var txtstday = tabDateSt[0];
	var txtstmonth = tabDateSt[1];
	var txtstyear = tabDateSt[2];
	
	/* Date Fin */
	
	var datefin=frmObj.date2.value;
 	var tabDateFi = datefin.split('/');
 	
 	frmObj.jourfin.value= tabDateFi[0];
 	frmObj.moisfin.value=tabDateFi[1];
 	frmObj.anneefin.value=tabDateFi[2];
	
	var txtendday = tabDateFi[0];
	var txtendmonth = tabDateFi[1];
	var txtendyear = tabDateFi[2];
	
	
	
	var today =new Date();
	var stdate =new Date(txtstyear,txtstmonth-1,txtstday);
	
	var enddate =new Date(txtendyear,txtendmonth-1,txtendday);
	var minDate = new Date(today.getTime() + 2*24*60*60*1000);
	
	var txtstarthour = frmObj.heuredebut[frmObj.heuredebut.selectedIndex].value;
	var txtstartmins = frmObj.minutesdebut[frmObj.minutesdebut.selectedIndex].value;
	var txtendhour = frmObj.heurefin[frmObj.heurefin.selectedIndex].value;
	var txtendmins = frmObj.minutesfin[frmObj.minutesfin.selectedIndex].value;


	if(dest == "-1")
	{
		alert("You must select a destination!");
		return(false);
	}
 
	if(!isValidDate(txtstday,txtstmonth,txtstyear))
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	if(tabDateSt[0]=="")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}	
	if(tabDateSt[0]=="")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	if(tabDateSt[1]=="undefined")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
		if(tabDateSt[2]=="undefined")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	if(tabDateFi[0]=="")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	if(tabDateFi[1]=="undefined")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
		if(tabDateFi[2]=="undefined")
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	
	if(!isValidDate(txtendday,txtendmonth,txtendyear)){
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	
	if(stdate > enddate){
		alert("Return date must be after rental start date");
		return(false);
	}
	
	if(stdate < today){
	     alert("You cannot rent a vehicle for today or for dates that are before today.");
	     return(false);
	}
	
	if(dest == "30")
	{
		if(nb_jour([txtstday,txtstmonth,txtstyear],[txtendday,txtendmonth,txtendyear])<"2")
		{
			alert("You cannot rent for just 1 day in Corsica");
			return(false);
		}
	}
	
	if(stdate < minDate){
		alert("It is impossible to reserve a vehicle less than 2 days in advance");
		return(false);
	
	}
	
	if(enddate < today){
	     alert("Rental start date must be before rental end date");
	     return(false);
	}
}

function verifdevis(){

 	var frmObj = document.devisForm;
 	
 	var dest = frmObj.destination.value;
 	var veh = frmObj.voiture.value;

	var txtstday = frmObj.jourdebut[frmObj.jourdebut.selectedIndex].value;
	var txtstmonth = frmObj.moisdebut[frmObj.moisdebut.selectedIndex].value;
	var txtstyear = frmObj.anneedebut[frmObj.anneedebut.selectedIndex].value;
	
	var txtendday = frmObj.jourfin[frmObj.jourfin.selectedIndex].value;
	var txtendmonth = frmObj.moisfin[frmObj.moisfin.selectedIndex].value;
	var txtendyear = frmObj.anneefin[frmObj.anneefin.selectedIndex].value;
	var today =new Date();
	var stdate =new Date(txtstyear,txtstmonth-1,txtstday);
	
	var enddate =new Date(txtendyear,txtendmonth-1,txtendday);
	var minDate = new Date(today.getTime() + 2*24*60*60*1000);
	
	var txtstarthour = frmObj.heuredebut[frmObj.heuredebut.selectedIndex].value;
	var txtstartmins = frmObj.minutesdebut[frmObj.minutesdebut.selectedIndex].value;
	var txtendhour = frmObj.heurefin[frmObj.heurefin.selectedIndex].value;
	var txtendmins = frmObj.minutesfin[frmObj.minutesfin.selectedIndex].value;


	if(dest == "-1")
	{
		alert("You must select a destination!");
		return(false);
	}
 
	if(!isValidDate(txtstday,txtstmonth,txtstyear))
	{
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	
	if(!isValidDate(txtendday,txtendmonth,txtendyear)){
	     alert("Sorry, this is not a valid date, please enter a different date");
	     return(false);
	}
	
	if(stdate > enddate){
		alert("Return date must be after rental start date");
		return(false);
	}
	
	if(stdate < today){
	     alert("You cannot rent a vehicle for today or for dates that are before today.");
	     return(false);
	}
	
	if(dest == "30")
	{
		if(nb_jour([frmObj.jourdebut[frmObj.jourdebut.selectedIndex].value,frmObj.moisdebut[frmObj.moisdebut.selectedIndex].value,frmObj.anneedebut[frmObj.anneedebut.selectedIndex].value],[frmObj.jourfin[frmObj.jourfin.selectedIndex].value,frmObj.moisfin[frmObj.moisfin.selectedIndex].value,frmObj.anneefin[frmObj.anneefin.selectedIndex].value])<"2")
		{
			alert("You cannot rent for just 1 day in Corsica");
			return(false);
		}
	}
	
	if(stdate < minDate){
		alert("It is impossible to reserve a vehicle less than 2 days in advance");
		return(false);
	
	}
	
	if(enddate < today){
	     alert("Rental start date must be before rental end date");
	     return(false);
	}
}

function bissextile(annee) {
if (annee%4==0 && annee %100!=0 || annee%400==0) return true; else return false
}

function nb_01_01(date){
nb_mois=new Array(13);
nb_mois=[,0,31,59,90,120,151,181,212,243,273,304,334];
j=eval(date[0]) ; m=eval(date[1]) ; a=eval(date[2]);
nb=nb_mois[m]+j-1 ;
if (bissextile(a) && m>2) nb++;
return nb;
}

function nb_jour_annee(a1,a2){
n=0;
if (a1==a2) n=0 ; else
for (i=a1; i<a2; i++) {n += 365; if (bissextile(i)) n++}
return n;
}

function nb_jour(date1,date2){
a1=eval(date1[2]) ; a2=eval(date2[2]) ; 
nb=nb_jour_annee(date1[2],date2[2]) - nb_01_01(date1) + nb_01_01(date2);
return nb;
}

function isValidDate(strDay,strMonth,strYr){
	var daysInMonth = DaysArray(12)
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)

	if (strMonth == "" || isNaN(strMonth) || isNaN(strDay) || strDay == "" || isNaN(strYr)|| strYr == "" ){
 	    return false;
	}else if ((month==2 && day>daysInFebruary(year)) || (day > daysInMonth[month])){
	    return false;
	}
	return true;
}

function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   	}	
	return this
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,

    // EXCEPT for centurial years which are not also divisible by 400.
	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function SubmitForm(strType){
	
	frmObj = document.resForm;
	var elemSelected;
	elemSelected = true;
	
	
	var txtstday = frmObj.stday[frmObj.stday.selectedIndex].value;
	var txtstmonth = frmObj.stmonth[frmObj.stmonth.selectedIndex].value;
	var txtstyear = frmObj.styear[frmObj.styear.selectedIndex].value;
	var txtendday = frmObj.endday[frmObj.endday.selectedIndex].value;
	var txtendmonth = frmObj.endmonth[frmObj.endmonth.selectedIndex].value;
	var txtendyear = frmObj.endyear[frmObj.endyear.selectedIndex].value;
	var today =new Date();
	
	if(frmObj.destination.value=="6"){
		var minDate = new Date(today.getTime() + 1*24*60*60*1000);
	}
	else{
		var minDate = new Date(today.getTime() + 2*24*60*60*1000);
	}
	
	var stdate =new Date(txtstyear,txtstmonth-1,txtstday);
	var enddate =new Date(txtendyear,txtendmonth-1,txtendday);
	var txtstarthour = frmObj.sthour[frmObj.sthour.selectedIndex].value;
	var txtstartmins = frmObj.stminute[frmObj.stminute.selectedIndex].value;
	var txtendhour = frmObj.endhour[frmObj.endhour.selectedIndex].value;
	var txtendmins = frmObj.endminute[frmObj.endminute.selectedIndex].value;
	var resstartdate =new Date(txtstyear,txtstmonth-1,txtstday,txtstarthour,txtstartmins);
	var resenddate =new Date(txtendyear,txtendmonth-1,txtendday,txtendhour,txtendmins);
	var frmObj = document.resForm;
	
	if(!isValidDate(txtstday,txtstmonth,txtstyear)){
	
	     alert("Sorry, this is not a valid date, please enter a different date");
	
	     frmObj.stday.focus();
	
	}else if(!isValidDate(txtendday,txtendmonth,txtendyear)){
	
	     alert("Sorry, this is not a valid date, please enter a different date");
	
	     frmObj.endday.focus();
	
	}else if(stdate > enddate){
	
	     alert("Return date must be after rental start date");
	
	     frmObj.endday.focus();
	
	}else if(stdate < today){
	
	     alert("You cannot rent a vehicle for today or for dates that are before today.");
	
	     frmObj.stday.focus();
	
	}else if(stdate < minDate){
	
		if(frmObj.destination.value=="6"){
			alert("It is impossible to reserve a vehicle less than 1 day in advance");
		} else {
			alert("It is impossible to reserve a vehicle less than 2 days in advance");
		}
	
		frmObj.stday.focus();
	
	}else if(enddate < today){
	
	     alert("Rental start date must be before rental end date");
	
	     frmObj.endday.focus();
	}
	else if((frmObj.destination.value=="30") && (nb_jour([frmObj.stday[frmObj.stday.selectedIndex].value,frmObj.stmonth[frmObj.stmonth.selectedIndex].value,frmObj.styear[frmObj.styear.selectedIndex].value],[frmObj.endday[frmObj.endday.selectedIndex].value,frmObj.endmonth[frmObj.endmonth.selectedIndex].value,frmObj.endyear[frmObj.endyear.selectedIndex].value])<"2") ){
		
		alert("You cannot rent for just 1 day in Corsica");
	}
	else if(!IsValidTime(frmObj.sthour.value,frmObj.stminute.value)) {
	
				frmObj.sthour.focus();
	
	}else if(!IsValidTime(frmObj.endhour.value,frmObj.endminute.value)){
	
			frmObj.endhour.focus();
	
	}else if(!elemSelected){
	
	    alert("Select the category");
	
	}

	else{
	
		if (strType == 1)
		 {
		 	frmObj.target='_self';
			frmObj.action='Detail.php';
			frmObj.submit()
		}
		else if(strType == 2)
		{
			window.open("","printdetails","toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,resizable=yes,width=550,height=600,left=0,top=0")
			frmObj.action='printResDetail.php';
			frmObj.target='printdetails'
			frmObj.submit();
	    }
		else if (strType == 3)
		{
			frmObj.target='_self';
			frmObj.action='infoline.php';
			frmObj.submit();
		}
		else
		{
			frmObj.target='_self';
			frmObj.action='ReservationForm.php#supp';
			frmObj.submit();
	    }
	 }
}

function clicktel() {
	SubmitForm(3);
}

function y2k(number) { 
	return (number < 1000) ? number + 1900 : number; 
}

function daysElapsed(date1,date2) {
    var difference =
        Date.UTC(y2k(date1.getYear()),date1.getMonth(),date1.getDate(),date1.getHours(),date1.getMinutes(),0)
      - Date.UTC(y2k(date2.getYear()),date2.getMonth(),date2.getDate(),date2.getHours(),date2.getMinutes(),0);
    return difference/1000/60/60/24;
}

function IsValidTime(hour,minute) {

	if (hour==""||minute=="")
	{
		alert("The time of day is not in valid format");
		return false;
	}

	if (isNaN(hour)||isNaN(minute) ) 
	{
		alert("The time of day is not in valid format");
		return false;
	}

	if (hour < 0  || hour > 23) 
	{
		alert("Hour must be between 0 and 23");
		return false;
	}

	if (minute<0 || minute > 59) {
		alert("Minutes must be between 0 and 59");
		return false;
	}
	
	return true;
}

function openPopUp(){
	
   var catid;
   frmObj = document.resForm;
   catid = "";

   for (j=0;j<frmObj.catid.length;j++){
       if (frmObj.catid[j].checked) catid = frmObj.catid[j].value;
   }
   
   window.open("chooseModel.php?catId="+catid, "toolbar=0, resizable=1, status=0, scrollbars=1,width=600,height=400");
}

function openAddress(strType){

   strQs = "offtype=" + strType + "&officeid=";

   if (document.resForm.sourceagent.length > 0){
	   if (strType == 1){
	      strQs += document.resForm.sourceagent[document.resForm.sourceagent.selectedIndex].value;
	   }
	   
	   window.open('showOfficeAddress.php?'+ strQs,'calpreview','toolbar=no,status=no,scrollbars=no,location=no,menubar=no,directories=no,width=230,height=180,left=300,top=300');
   }
}

function showhide(){

	if(document.getElementById("model").style.display=="block")
	{
		document.getElementById("model").style.display="none";
		document.getElementById("voir").innerHTML="<span>See our vehicles</span>";
	}
	else
	{
		document.getElementById("model").style.display="block";
		document.getElementById("voir").innerHTML="<span>Close</span>";
	}
}

function changecatid(number){
	
	document.getElementById(number).selected= true;
	showhide();
}

function printPage(){
   window.print() ;
}

function submitForm(intPayMode){

    var frmObj = document.detForm;

    var elemSelected;

    elemSelected = true;


	var txtstday = frmObj.stday[frmObj.stday.selectedIndex].value;
	var txtstmonth = frmObj.stmonth[frmObj.stmonth.selectedIndex].value;
	var txtstyear = frmObj.styear[frmObj.styear.selectedIndex].value;

	var txtendday = frmObj.endday[frmObj.endday.selectedIndex].value;
	var txtendmonth = frmObj.endmonth[frmObj.endmonth.selectedIndex].value;
	var txtendyear = frmObj.endyear[frmObj.endyear.selectedIndex].value;

	var today =new Date();
	
	if (frmObj.destination.value == "6") {
		var minDate = new Date(today.getTime() + 1*24*60*60*1000);
	}
	else {
		var minDate = new Date(today.getTime() + 2*24*60*60*1000);
	}
	
	var stdate =new Date(txtstyear,txtstmonth-1,txtstday);

	var enddate =new Date(txtendyear,txtendmonth-1,txtendday);


	var txtstarthour = frmObj.sthour[frmObj.sthour.selectedIndex].value;
	var txtstartmins = frmObj.stminute[frmObj.stminute.selectedIndex].value;
	var txtendhour = frmObj.endhour[frmObj.endhour.selectedIndex].value;
	var txtendmins = frmObj.endminute[frmObj.endminute.selectedIndex].value;
	var resstartdate =new Date(txtstyear,txtstmonth-1,txtstday,txtstarthour,txtstartmins);
	var resenddate =new Date(txtendyear,txtendmonth-1,txtendday,txtendhour,txtendmins);
	
	if(!isValidDate(txtstday,txtstmonth,txtstyear)){

	     alert("Sorry, this is not a valid date, please enter a different date");
	     frmObj.stday.focus();

	}else if(!isValidDate(txtendday,txtendmonth,txtendyear)){

	     alert("Sorry, this is not a valid date, please enter a different date");
	     frmObj.endday.focus();

	}else if(stdate > enddate){

     	alert("Return date must be after rental start date");
     	frmObj.endday.focus();

	}else if(stdate < today){

     	alert("It is impossible to reserve a vehicle for a date before today’s date");
     	frmObj.stday.focus();

	}else if(stdate < minDate){
		
		if (frmObj.destination.value == "6") {
			alert("It is impossible to reserve a vehicle less than 2 days in advance");
		} else {
			alert("It is impossible to reserve a vehicle less than 1 day in advance");
		}	

     	frmObj.stday.focus();

	}else if(enddate < today){

     	alert("Rental start date must be before rental end date");
     	frmObj.endday.focus();
	}	
	else if(!elemSelected){

	    alert("");

	}else if(!IsValidTime(frmObj.sthour.value,frmObj.stminute.value)) {

		frmObj.sthour.focus();

	}else if(!IsValidTime(frmObj.endhour.value,frmObj.endminute.value)){

		frmObj.endhour.focus();

	}else if(frmObj.fdrname.value ==""){

	    alert("Please indicate the name of the first driver");
	    frmObj.fdrname.focus();

	}else if(frmObj.fdrfname.value ==""){

	    alert("Please indicate the first driver’s first name");
	    frmObj.fdrfname.focus();
	}
	
  	   else if((frmObj.fdremail.value =="")){

			alert("Please enter a valid email address");
       		frmObj.fdremail.focus();

	   }
	   else if((frmObj.fdremail.value !="") && !isValidEmail(frmObj.fdremail.value))
	   {
       		alert("Please enter a valid email address");
       		frmObj.fdremail.focus();
	   }
	   else if(frmObj.fdremail.value != frmObj.fdremail2.value)
	   		{
       			alert("The two email addresses entered are not identical, please correct.");
       			frmObj.fdremail.focus();
 			}
 		else if(frmObj.fdrlicence.value ==""){
	
	       alert("Please indicate the first driver’s license number");
	       frmObj.fdrlicence.focus();
	
	    }else if(frmObj.fdrlicplace.value ==""){
	
	       alert("Please indicate where the license of the first driver was issued");
	       frmObj.fdrlicplace.focus();
	    }
  
	 else if(frmObj.fdraddr.value =="")
	 {
	   alert("You must enter an address");
	   frmObj.fdraddr.focus();
	
	 }

			 
  		else if (((frmObj.d1day.value !="null") || (frmObj.d1month.value !="null") || (frmObj.d1year.value !="null"))
			  && !isValidDate(frmObj.d1day.value,frmObj.d1month.value,frmObj.d1year.value)){
			
		   alert("Sorry, this is not a valid date, please enter a different date");
		   frmObj.d1day.focus();

		}else if (((frmObj.d1day.value !="null") || (frmObj.d1month.value !="null") || (frmObj.d1year.value !="null"))
			 && !areAgeAndDrivingLicenceCoherent(frmObj.driverage1.value, frmObj.d1day.value, frmObj.d1month.value, frmObj.d1year.value)){

		   alert("Age and license issue date of first driver are inconsistent");
		   frmObj.d1day.focus();

		}else if(((frmObj.d1day.value !="null") || (frmObj.d1month.value !="null") || (frmObj.d1year.value !="null"))
			&& (getNbDays(frmObj.styear[frmObj.styear.selectedIndex].value, frmObj.stmonth[frmObj.stmonth.selectedIndex].value, frmObj.stday[frmObj.stday.selectedIndex].value, frmObj.d1year.value, frmObj.d1month.value, frmObj.d1day.value) < 365)){

		   alert("You must have a currently valid driver’s license and have held it for at least one year for any rental.");
		   frmObj.d1day.focus();

		}else if (((frmObj.d2day.value !="null") || (frmObj.d2month.value !="null") || (frmObj.d2year.value !="null"))
			  && !isValidDate(frmObj.d2day.value,frmObj.d2month.value,frmObj.d2year.value)){

		   alert("Sorry, this is not a valid date, please enter a different date");
		   frmObj.d2day.focus();

		}else if (((frmObj.d2day.value !="null") || (frmObj.d2month.value !="null") || (frmObj.d2year.value !="null"))
			 && !areAgeAndDrivingLicenceCoherent(frmObj.driverage2.value, frmObj.d2day.value, frmObj.d2month.value, frmObj.d2year.value)){

		   alert("Age and license issue date of second driver are inconsistent");
		   frmObj.d2day.focus();

		}else if((frmObj.sdrname.value !="")
			&& ((frmObj.d2day.value !="null") || (frmObj.d2month.value !="null") || (frmObj.d2year.value !="null"))
			&& (getNbDays(frmObj.styear[frmObj.styear.selectedIndex].value, frmObj.stmonth[frmObj.stmonth.selectedIndex].value, frmObj.stday[frmObj.stday.selectedIndex].value, frmObj.d2year.value, frmObj.d2month.value, frmObj.d2day.value) < 365)){

		   alert("You must have a currently valid driver’s license and have held it for at least one year for any rental.");
		   frmObj.d2day.focus();
		}
			
  	else
	{

       	if (intPayMode<0){
       	
	    	frmObj.action='Detail.php#supp';
	   		frmObj.submit();
	   		
		}else{
			if (intPayMode==0)
			{
				frmObj.paymode.value=intPayMode;
				frmObj.target="_self";
				frmObj.action='SaveOrder.php';
				frmObj.submit();
			}
			else
			{
				var dt1 =new Date();
				var dt2 =new Date(txtstmonth+"/"+txtstday+"/"+txtstyear+" "+frmObj.sthour.value+ ":"+frmObj.stminute.value);

				intGap= parseInt((dt2-dt1) / 86400000);

				if (intGap<(6) && intPayMode==3)
				{
					alert("To book a vehicle less than 7 days in advance you cannot pay by cheque. If you do not wish to use this type of payment, please change the pick-up date of your vehicle to a later date.");
				}
				else
				{
					frmObj.paymode.value=intPayMode;
					frmObj.target="_blank";
					frmObj.action='SaveOrder.php';
					frmObj.submit();
				}
			}
	    }
	}

}

function isValidEmail(strEmail) {

	var txtfdvalue1=strEmail.lastIndexOf("@")
	var txtfdvalue2=strEmail.indexOf("@")
	if(txtfdvalue1!=txtfdvalue2)
	{
		return false;
	}

	if(txtfdvalue1==-1)
	{
		return false;
	}

	var txt1=strEmail.lastIndexOf(".")
	var txt2=strEmail.indexOf(".")

	if(txt1==-1)
	{
		return false;
	}

	var k=strEmail.substring(txtfdvalue2,txt2)

	if(k.length<2)
	{
		return false;
	}

	if(txt1==(strEmail.length-1))
	{
		return false;
	}

	return true;
}

function isValidDate(strDay,strMonth,strYr){
	return true
}


function areAgeAndDrivingLicenceCoherent(age,day,month,year) {
	var curDate = new Date;
	// Nombre d'année de permis
	var drivingYears = curDate.getYear() - year;
	if ((age - drivingYears) < 18) return false;
	return true;
}

function getNbDays(date1year, date1month, date1day, date2year, date2month, date2day) {
	var dt1 =new Date(date1year, date1month, date1day);
	var dt2 =new Date(date2year, date2month, date2day);
	return parseInt((dt1-dt2) / 86400000);
}


/* ------------- ACCES PRO -------------- */

function validateForm(){
	if (document.agentlogin.agentUserid.value=="") 
	{
		alert("Veuillez écrire le nom de votre agence");
		document.agentlogin.agentUserid.focus();
		return false;
	}
	if (document.agentlogin.Pwd.value=="") 
	{
		alert("Veuillez entrer le mot de passe");
		document.agentlogin.Pwd.focus();
		return false;

	}
	return true;
}

function openPopUp(){
	var catid;
	frmObj = document.resForm;
	frmObj.submit();
}

function openReserver(){
    var catid;
    frmObj = document.resForm;
    frmObj.action="Detail.php"
    frmObj.submit();
}

function openReserverTel(){
    var catid;
    frmObj = document.resForm;
    frmObj.action="infoline.php"
    frmObj.submit();
}

function showModelcar(catid,modelid){
	window.open("showModelcar.php?catId="+catid+"&modelId="+modelid,"openModel", "toolbar=0,resizable=1,status=0,scrollbars=1,width=650,height=250");
}

function openAllModels(){
	window.close();
	window.opener.location='showModels.php';
	//window.open("chooseModel.php","openModel", "toolbar=0, status=0, scrollbars=1,width=650,height=500");
}

function printDocument(orderId){
	window.open("printOrder.php?orderId=" + orderId,"printmodel","toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=700,height=500,resizable=yes,left=0,top=0");
}

function printRIB(orderId){
	window.open("openauth.php?orderId=" + orderId,"printmodel","toolbar=no,status=no,scrollbars=yes,location=no,menubar=no,directories=no,width=700,height=500,resizable=yes,left=0,top=0");
}

function printPage(){

  if (window.print) {
      window.print();
  }
  else 
  {
       var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
       document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
       WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";
  }
  window.close();
}

function affiche(parc)
{

	if(document.getElementById(parc).style.display=='none')
		document.getElementById(parc).style.display='block';
	else
		document.getElementById(parc).style.display='none';
}

function SubmitRates(page,num)
{
	if(page==0)
	{
		frmObj=document.form1;
		frmObj.action="Detail.php";
	    frmObj.submit();
	}
	else
	{
		frmObj=document.form1;
	    frmObj.action="ReservationForm.php";
	    frmObj.submit();
	}
}

function ShowHoraires(ofid)
{

	document.getElementById('horaires').innerHTML=document.getElementById(ofid).innerHTML;
	
	if(document.getElementById("disp" + ofid).value == "0")
	{
		document.getElementById('validation_form').style.display="none";
	}
	else
	{
		document.getElementById('validation_form').style.display="block";
	}

}


function check_default_horaire()
{

if(document.getElementById('horaires').innerHTML=="<strong>Il est impossible de réserver cette catégorie de véhicule ou cette agence de location à la période demandée, merci de modifier votre demande, pour tout complément d'information, n'hésitez pas à nous contacter par mail : info@voituresdesiles.com</strong>")
{
	document.getElementById('validation_form').style.display="none";
}
else
{
	document.getElementById('validation_form').style.display="block";
}

}

function cache()
{
	document.getElementById('validation_form').style.display="none";
	
	document.getElementById('recalculate').style.display="block";
}

function mention(id,text)
{
	if(id=="44")
	{
		document.getElementById("supstmartin").innerHTML="<p>" + text + "</p>";
	}
	else
	{
		document.getElementById("supstmartin").innerHTML="";
	}
}

function copie(){
	document.getElementById("date2").value=document.getElementById("date1").value;
}
