// JavaScript Document
function pad2(numr) {
	return (numr < 10 ? "0" : '')+''+numr;
}
var serv1;
var serv2;
var aftH1;
var aftH2;
var servTOTAL;
var mypax;
var paxNr;

function calcpret(){ //calc the price of Transfer
fromto();
var GPRnr='';
var hours1 = document.calcrate.dep1hour.value;
var hours2 = document.calcrate.dep2hour.value;
var preresult = 0;
var websiteDISCOUNT = 0;
var seasonDISCOUNT = 0;
var seasonDISCserv1 = 0;
var seasonDISCserv2 = 0;
var returnDISCOUNT = 0;
var pickupString = document.calcrate.transferdate1.value;
var year1   = parseFloat(pickupString.substr(0,4));
var month1  = parseFloat(pickupString.substr(5,2));
var day1    = parseFloat(pickupString.substr(8,2));
var returnString = document.calcrate.transferdate2.value;
var year2   = parseFloat(returnString.substr(0,4));
var month2  = parseFloat(returnString.substr(5,2));
var day2    = parseFloat(returnString.substr(8,2));
var pickupmmdd = pad2(month1)+""+pad2(day1);
var returnmmdd = pad2(month2)+""+pad2(day2);
paxNr = document.calcrate.pax.value;
serv1 = 0;
serv2 = 0;
aftH1 = 0;
aftH2 = 0;
servTOTAL = 0;
mypax=""

if (AFThours >= 1) {
	if 	(aftHini1 > aftHend1) {
		if ((hours1 >= aftHini1) || (hours1 <= aftHend1)) { aftH1 = aftHRperc1; }
	} else if (aftHini1 < aftHend1) {
		if ((hours1 >= aftHini1) && (hours1 <= aftHend1)) { aftH1 = aftHRperc1; }
	}
	if 	(aftHini2 > aftHend2) {
		if ((hours1 >= aftHini2) || (hours1 <= aftHend2)) { aftH1 = aftHRperc2; }
	} else if (aftHini2 < aftHend2) {
		if ((hours1 >= aftHini2) && (hours1 <= aftHend2)) { aftH1 = aftHRperc2; }
	}
	if (document.calcrate.checktwo.checked==true) {
		if 	(aftHini1 > aftHend1) {
			if ((hours2 >= aftHini1) || (hours2 <= aftHend1)) { aftH2 = aftHRperc1; }
		} else if (aftHini1 < aftHend1) {
			if ((hours2 >= aftHini1) && (hours2 <= aftHend1)) { aftH2 = aftHRperc1; }
		}
		if 	(aftHini2 > aftHend2) {
			if ((hours2 >= aftHini2) || (hours2 <= aftHend2)) { aftH2 = aftHRperc2; }
		} else if (aftHini2 < aftHend2) {
			if ((hours2 >= aftHini2) && (hours2 <= aftHend2)) { aftH2 = aftHRperc2; }
		}
	}
}
if ((servTYPE>=1) && (servTYPE<=2)) {
if (servTYPE == 2) {
	if ((paxNr>=parseFloat(paxgrp[10][0])) && (paxNr<=parseFloat(paxgrp[10][1]))) {GPRnr=10; mypax=mypax10.slice();}
	calcAirport(GPRnr);
	}else{
	if ((paxNr>=parseFloat(paxgrp[1][0])) && (paxNr<=parseFloat(paxgrp[1][1]))) {GPRnr=1; mypax=mypax1.slice();}
	if ((paxNr>=parseFloat(paxgrp[2][0])) && (paxNr<=parseFloat(paxgrp[2][1]))) {GPRnr=2; mypax=mypax2.slice();}
	if ((paxNr>=parseFloat(paxgrp[3][0])) && (paxNr<=parseFloat(paxgrp[3][1]))) {GPRnr=3; mypax=mypax3.slice();}
	if ((paxNr>=parseFloat(paxgrp[4][0])) && (paxNr<=parseFloat(paxgrp[4][1]))) {GPRnr=4; mypax=mypax4.slice();}
	if ((paxNr>=parseFloat(paxgrp[5][0])) && (paxNr<=parseFloat(paxgrp[5][1]))) {GPRnr=5; mypax=mypax5.slice();} 
	if ((paxNr>=parseFloat(paxgrp[6][0])) && (paxNr<=parseFloat(paxgrp[6][1]))) {GPRnr=6; mypax=mypax6.slice();}
	if ((paxNr>=parseFloat(paxgrp[7][0])) && (paxNr<=parseFloat(paxgrp[7][1]))) {GPRnr=7; mypax=mypax7.slice();}
	if ((paxNr>=parseFloat(paxgrp[8][0])) && (paxNr<=parseFloat(paxgrp[8][1]))) {GPRnr=8; mypax=mypax8.slice();}		  
	if ((paxNr>=parseFloat(paxgrp[9][0])) && (paxNr<=parseFloat(paxgrp[9][1]))) {GPRnr=9; mypax=mypax9.slice();}
	calcAirport(GPRnr);
	}
} else if (servTYPE == 3) {
	if ((paxNr>=parseFloat(paxgrp[1][0])) && (paxNr<=parseFloat(paxgrp[1][1]))) {GPRnr=1; mypax=mypax1.slice();}
	if ((paxNr>=parseFloat(paxgrp[2][0])) && (paxNr<=parseFloat(paxgrp[2][1]))) {GPRnr=2; mypax=mypax2.slice();}
	if ((paxNr>=parseFloat(paxgrp[3][0])) && (paxNr<=parseFloat(paxgrp[3][1]))) {GPRnr=3; mypax=mypax3.slice();}
	if ((paxNr>=parseFloat(paxgrp[4][0])) && (paxNr<=parseFloat(paxgrp[4][1]))) {GPRnr=4; mypax=mypax4.slice();}
	calcGolf(GPRnr);
} else if (servTYPE == 4) {
		var KMpax='';
	if ((paxNr>=parseFloat(paxgrp[1][0])) && (paxNr<=parseFloat(paxgrp[1][1]))) {GPRnr=1; KMpax=KMpax1;}
	if ((paxNr>=parseFloat(paxgrp[2][0])) && (paxNr<=parseFloat(paxgrp[2][1]))) {GPRnr=2; KMpax=KMpax2;}
	if ((paxNr>=parseFloat(paxgrp[3][0])) && (paxNr<=parseFloat(paxgrp[3][1]))) {GPRnr=3; KMpax=KMpax3;}
	if ((paxNr>=parseFloat(paxgrp[4][0])) && (paxNr<=parseFloat(paxgrp[4][1]))) {GPRnr=4; KMpax=KMpax4;}
	if ((paxNr>=parseFloat(paxgrp[5][0])) && (paxNr<=parseFloat(paxgrp[5][1]))) {GPRnr=5; KMpax=KMpax5;}
	if ((document.calcrate.pickup_locID.value!=0) && (document.calcrate.dropoff_locID.value!=0)) {
	var PKid = parseFloat(document.calcrate.pickup_locID.value);
	var DOid = parseFloat(document.calcrate.dropoff_locID.value);
	var PKfee = parseFloat(dist[PKid][GPRnr-1]);
	var DOfee = parseFloat(dist[DOid][GPRnr-1]);
	var arrKM = parseFloat(mypax1[PKid][DOid-1])*KMpax;
	document.calcrate.journey1.value = "Trip: "+mypax1[PKid][DOid-1]+" Km";
	if (aftH1>0){
		if (AFThours==1){serv1=(PKfee+DOfee+arrKM)*aftH1;} else if (AFThours==2){serv1=PKfee+DOfee+arrKM+aftH1;}
	} else { serv1 = PKfee+DOfee+arrKM; }
		if ((document.calcrate.return_pickupID.value!=0) && (document.calcrate.return_dropoffID.value!=0)) {
			var retPKid	= parseFloat(document.calcrate.return_pickupID.value);
			var retDOid	= parseFloat(document.calcrate.return_dropoffID.value);
			var retPKfee =parseFloat(dist[retPKid][GPRnr-1]);
			var retDOfee =parseFloat(dist[retDOid][GPRnr-1]);
			var retKM =parseFloat(mypax1[retPKid][retDOid-1])*KMpax;
			document.calcrate.journey2.value = "Trip: "+mypax1[retPKid][retDOid-1]+" Km";
			if (aftH2>0){
				if (AFThours==1){serv2=(retPKfee+retDOfee+retKM)*aftH2;} else if (AFThours==2){serv2=(retPKfee+retDOfee+retKM)+aftH2; }
			} else {serv2=retPKfee+retDOfee+retKM;}
		} else { document.calcrate.journey2.value ="" }
			document.calcrate.suplier.value = paxgrp[GPRnr][3];
	} else { document.calcrate.journey1.value ="" }
	if (!document.images)
	return
	document.images.pictures.src=paxgrp[GPRnr][2];
	servTOTAL = serv1 + serv2;
	document.vehycle.pass.value=" up to "+paxgrp[GPRnr][1]+" people";
}
	if (websiteDISC >= 1) {
		if (websiteDISC == 1) { 
		websiteDISCOUNT = (servTOTAL * websiteDISC1/100).toFixed(2);
		preresult = servTOTAL - websiteDISCOUNT; 
		}
		if (websiteDISC == 2) { 
		websiteDISCOUNT = websiteDISC1;
		preresult = servTOTAL - websiteDISCOUNT; 
		}
		if (websiteDISC == 3) { 
		websiteDISCOUNT = (servTOTAL * websiteDISC1/100).toFixed(2);
		preresult = servTOTAL + websiteDISCOUNT; 
		}
		if (websiteDISC == 4) { 
		websiteDISCOUNT = websiteDISC1;
		preresult = servTOTAL + websiteDISCOUNT; 
		}
	} else { preresult = servTOTAL; }
	
	if (jSEASON >= 1) {
		if (seasonINI1 > seasonEND1) {
			if ((pickupmmdd >= seasonINI1) || (pickupmmdd <= seasonEND1)) {
				if (jSEASON == 1) { (seasonDISCserv1 = serv1 * seasonDISC1/100).toFixed(2); } else { seasonDISCserv1 = seasonDISC1; }
			}
			if ((returnmmdd >= seasonINI1) || (returnmmdd <= seasonEND1)) {
				if (jSEASON == 1) { (seasonDISCserv2 = serv2 * seasonDISC1/100).toFixed(2); } else { seasonDISCserv2 = seasonDISC1; }
			}
			seasonDISCOUNT = seasonDISCserv1 + seasonDISCserv2;
			document.calcrate.result.value = preresult - seasonDISCOUNT;
		} else {
			if ((pickupmmdd >= seasonINI1) && (pickupmmdd <= seasonEND1)) {
				if (jSEASON == 1) { (seasonDISCserv1 = serv1 * seasonDISC1/100).toFixed(2); } else { seasonDISCserv1 = seasonDISC1; }
			}
			if ((returnmmdd >= seasonINI1) && (returnmmdd <= seasonEND1)) {
				if (jSEASON == 1) { (seasonDISCserv2 = serv2 * seasonDISC1/100).toFixed(2); } else { seasonDISCserv2 = seasonDISC1; }
			}
			seasonDISCOUNT = seasonDISCserv1 + seasonDISCserv2;
			document.calcrate.result.value = preresult - seasonDISCOUNT;
		}
		if (seasonINI2 > seasonEND2) {
			if ((pickupmmdd >= seasonINI2) || (pickupmmdd <= seasonEND2)) {
				if (jSEASON == 1) { (seasonDISCserv1 = serv1 * seasonDISC2/100).toFixed(2); } else { seasonDISCserv1 = seasonDISC2; }
			}
			if ((returnmmdd >= seasonINI2) || (returnmmdd <= seasonEND2)) {
				if (jSEASON == 1) { (seasonDISCserv2 = serv2 * seasonDISC2/100).toFixed(2); } else { seasonDISCserv2 = seasonDISC2; }
			}
			seasonDISCOUNT = seasonDISCserv1 + seasonDISCserv2;
			document.calcrate.result.value = preresult - seasonDISCOUNT;
		} else {
			if ((pickupmmdd >= seasonINI2) && (pickupmmdd <= seasonEND2)) {
				if (jSEASON == 1) { (seasonDISCserv1 = serv1 * seasonDISC2/100).toFixed(2); } else { seasonDISCserv1 = seasonDISC2; }
			}
			if ((returnmmdd >= seasonINI2) && (returnmmdd <= seasonEND2)) {
				if (jSEASON == 1) { (seasonDISCserv2 = serv2 * seasonDISC2/100).toFixed(2); } else { seasonDISCserv2 = seasonDISC2; }
			}
			seasonDISCOUNT = seasonDISCserv1 + seasonDISCserv2;
			document.calcrate.result.value = preresult - seasonDISCOUNT;
		}
	} else { document.calcrate.result.value = preresult; }	
	if((returnDISC >= 1) && (document.calcrate.return_pickupID.value!=0)) {
		if(returnDISC == 1)  {
			returnDISCOUNT = (document.calcrate.result.value*returnDISC1/100).toFixed(2);
		} else {returnDISCOUNT = returnDISC1;}
		document.calcrate.result.value = document.calcrate.result.value - returnDISCOUNT;
	}
	document.calcrate.servTOTAL.value=servTOTAL;
	document.calcrate.websiteDISCOUNT.value=websiteDISCOUNT;
	document.calcrate.seasonDISCOUNT.value=seasonDISCOUNT;
	document.calcrate.returnDISCOUNT.value=returnDISCOUNT;
	document.calcrate.cresult.value=(document.calcrate.result.value*cambio[document.calcrate.curr.value]).toFixed(2);
	document.calcrate.result.value=(document.calcrate.result.value*1).toFixed(2);
	document.calcrate.currencyabr.value=abrmoeda[document.calcrate.curr.value];
	document.calcrate.currencies.value = document.calcrate.curr.options[document.calcrate.curr.selectedIndex].text; 
} // calcrate();

function calcAirport(GPRnrx) {
	if (document.calcrate.dropoff_locID.value!=0) {
		if (aftH1 > 0) {
			if (AFThours == 1) { serv1 = parseFloat(mypax[document.calcrate.dropoff_locID.value][0]) * aftH1; }
			else if (AFThours == 2) { serv1 = parseFloat(mypax[document.calcrate.dropoff_locID.value][0]) + aftH1; }
		} else { serv1 = parseFloat(mypax[document.calcrate.dropoff_locID.value][0]); }
		if (document.calcrate.return_pickupID.value!=0) {
			if (aftH2 > 0) {
				if (AFThours == 1) { serv2 = parseFloat(mypax[document.calcrate.return_pickupID.value][0]) * aftH2; }
				else if (AFThours == 2) { serv2 = parseFloat(mypax[document.calcrate.return_pickupID.value][0]) + aftH2; }
			} else { serv2 = parseFloat(mypax[document.calcrate.return_pickupID.value][0]); }
		} 
		if (suplierGRP==1) {
			document.calcrate.suplier.value = paxgrp[GPRnrx][3];
		} else {
			document.calcrate.suplier.value = mypax[document.calcrate.dropoff_locID.value][1];
		}
	}
	if (!document.images)
	return
	document.images.pictures.src=paxgrp[GPRnrx][2];
	if (servTYPE == 2) {
		serv1 = paxNr * serv1;
		serv2 = paxNr * serv2;
		servTOTAL = serv1 + serv2;
		var peop=document.calcrate.pax.value==1?"person":"people";
		document.vehycle.pass.value="Quote for "+document.calcrate.pax.value+" "+peop;
	} else {
		servTOTAL = serv1 + serv2;
		document.vehycle.pass.value="Quote for up to "+paxgrp[GPRnrx][1]+" people";
	}
}
function calcGolf(GPRnrx) {
	if ((document.calcrate.pickup_locID.value!=0) && (document.calcrate.dropoff_locID.value!=0)) {
	var DOid=document.calcrate.dropoff_locID.value/10-1;
	var retPKid=document.calcrate.return_pickupID.value/10-1;
	document.calcrate.journey1.value = "Trip: "+dist[document.calcrate.pickup_locID.value][DOid]+" Hr";
		if (aftH1 > 0) {
			if (AFThours == 1) { serv1 = parseFloat(mypax[document.calcrate.pickup_locID.value][DOid]) * aftH1; }
			else if (AFThours == 2) { serv1 = parseFloat(mypax[document.calcrate.pickup_locID.value][DOid]) + aftH1; }
		} else { serv1 = parseFloat(mypax[document.calcrate.pickup_locID.value][DOid]); }
		if ((document.calcrate.return_pickupID.value!=0) && (document.calcrate.return_dropoffID.value!=0)) {
			document.calcrate.journey2.value = "Trip: "+dist[document.calcrate.return_dropoffID.value][retPKid]+" Hr";
			if (aftH2 > 0) {
				if (AFThours == 1) { serv2 = parseFloat(mypax[document.calcrate.return_dropoffID.value][retPKid]) * aftH2; }
				else if (AFThours == 2) { serv2 = parseFloat(mypax[document.calcrate.return_dropoffID.value][retPKid]) + aftH2; }
			} else { serv2 = parseFloat(mypax[document.calcrate.return_dropoffID.value][retPKid]); }
		} else { document.calcrate.journey2.value ="" }
			document.calcrate.suplier.value = paxgrp[GPRnrx][3];
	} else { document.calcrate.journey1.value ="" }
	if (!document.images)
	return
	document.images.pictures.src=paxgrp[GPRnrx][2];
	servTOTAL = serv1 + serv2;
	document.vehycle.pass.value=" up to "+paxgrp[GPRnrx][1]+" people";
}

var ret_value = "";
var ERR			='';
var ERRpickup_loc	='';
var ERRdropoff_loc	='';
var ERRdropoff_from	='Select the drop off location\n';
var ERRdropoff_to	='Select the pick up location\n';
var ERRdate1	=''; 
var ERRdep1h	='';
var ERRdep1m	='';
var ERRpkadr	='Fill in the pick up adress\n';
var ERRdoadr	='';
var ERRdep2		='';
var ERRdest2	='Select the return drop off location';
var ERRdate2	=''; 
var ERRdep2h	='';
var ERRdep2m	='';
var ERRretDOadr	='Fill in the return drop off adress\n';
var ERRretPKadr	='';
var ERRarrFLnr	='Fill in your arrival flight number\n';
var ERRfname	='Fill in your first name\n';
var ERRsname	='Fill in your family name\n';
var ERRcountry	='Fill in your country or country calling code\n';
var ERRmobphone	='Fill in your mobile phone number\n';
var ERRmisEmail	='Fill in your Email address\n'
var ERRnvEmail	='Email address format is not valid\n';
var ERRcEmail	='Re-enter your email address for verification\n';
var ERRdEmail	='Confirm your email adress\n';
regExMail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

function retdiff(retRADIO){ 
	ret_value = "";
    var i
    for (i=0;i<retRADIO.length;i++){ 
       if (retRADIO[i].checked) 
          break; 
    } 
    ret_value = retRADIO[i].value 
	if (ret_value == "PKsame") {
		document.calcrate.ret_pickup_adress.className  = 'visib';
		document.calcrate.ret_pickup_adress.disabled = true;
		document.getElementById('samePK').className="verd10"; 
		document.getElementById('diffPK').className="tah10grey";
	}
	if (ret_value == "PKdiff") {
		document.getElementById('samePK').className="tah10grey"; 
		document.getElementById('diffPK').className="verd10";
	}
	if (ret_value == "DOsame") {
		document.calcrate.ret_dropoff_adress.className  = 'visib';
		document.calcrate.ret_dropoff_adress.disabled = true;
		document.getElementById('sameDO').className="verd10"; 
		document.getElementById('diffDO').className="tah10grey";
	}
	if (ret_value == "DOdiff") {
		document.getElementById('sameDO').className="tah10grey"; 
		document.getElementById('diffDO').className="verd10";
	}
}

function valid() {
calcpret();
ERR			='';
ERRpickup_loc	='';
ERRdropoff_loc	='';
if (document.calcrate.dropoff_locID.value==0) { 
	HLdropoff_loc();
	if ((ERRpickup_loc!='') || (ERRdropoff_loc!='')) {
	alert('Please complete:\n\n'+ERRpickup_loc+ERRdropoff_loc);
	return false;}else{return;}		
}
if ((document.calcrate.pickup_type.value=="from") && (servTYPE <= 2)) {
	ERRdate1	='Select the arrival flight date\n'; 
	ERRdep1h	='Select the arrival flight time "hour"\n';
	ERRdep1m	='Select the arrival flight time "min."\n';
} else {
	ERRdate1	='Select the departure pick up date\n'; 
	ERRdep1h	='Select the departure pick up time "hour"\n';
	ERRdep1m	='Select the departure pick up time "min."\n';
}
if (document.calcrate.pickup_type.value=="to") { 
	ERRdoadr	='Fill in the pick up adress or the resort name\n';
} else {
	ERRdoadr	='Fill in your destination adress or the resort name\n';
}
	
	if ((document.calcrate.transferdate1.value=='yyyy-mm-dd') || (document.calcrate.transferdate1.value=='')) {
		document.calcrate.transferdate1.value='';
		if (ERR=='') {document.calcrate.transferdate1.focus();}
		HLdate1();
	}		
	if (document.calcrate.dep1hour.value == "hh") { 
		if (ERR=='') {document.calcrate.dep1hour.focus();}
		HLdep1h(); 
	}
	if (document.calcrate.dep1min.value == "mm") { 
		if (ERR=='') {document.calcrate.dep1min.focus();}
		HLdep1m();
	}		
	if (document.calcrate.checktwo.checked==true) {
		if ((document.calcrate.pickup_type.value=="to") && (servTYPE<=2)) {
			ERRdep2		='Select the return destination\n';
			ERRdate2	='Select the arrival flight date\n'; 
			ERRdep2h	='Select the arrival flight time "hour"\n';
			ERRdep2m	='Select the arrival flight time "min."\n';
		} else {
			ERRdep2		='Select the return pick up location\n';
			ERRdate2	='Select the return pick up date\n'; 
			ERRdep2h	='Select the return pick up time "hour"\n';
			ERRdep2m	='Select the return pick up time "min."\n';
		}
		if (document.calcrate.pickup_type.value=="to") { 
			ERRretPKadr	='Fill in your return destination adress or the resort name\n';
		} else {
			ERRretPKadr	='Fill in the return pick up adress or the resort name\n';
		}
		if (document.calcrate.return_pickupID.value==0) {
			if (ERR=='') {document.calcrate.return_pickupID.focus();}
			HLdep2();
		}
		if ((document.calcrate.return_dropoffID.value==0) && (servTYPE>=3)) {
			if (ERR=='') {document.calcrate.return_dropoffID.focus();}
			HLdest2();
		}	
		if ((document.calcrate.transferdate2.value=='yyyy-mm-dd') || (document.calcrate.transferdate2.value=='')) {
			document.calcrate.transferdate2.value='';
			if (ERR=='') {document.calcrate.transferdate2.focus();}
			HLdate2();
		}		
		if (document.calcrate.dep2hour.value == "hh") { 
			if (ERR=='') {document.calcrate.dep2hour.focus();}
			HLdep2h(); 
		}
		if (document.calcrate.dep2min.value == "mm") { 
			if (ERR=='') {document.calcrate.dep2min.focus();}
			HLdep2m();
		}	
	}
	if (ERR!='') {
		alert('Please complete:\n\n'+ERR);
		return false;
	} else{
		document.calcrate.dropoff_loc.value = document.calcrate.dropoff_locID.options[document.calcrate.dropoff_locID.selectedIndex].text;
		if (servTYPE >= 3) {
			document.calcrate.pickup_loc.value = document.calcrate.pickup_locID.options[document.calcrate.pickup_locID.selectedIndex].text;	
		} else {document.calcrate.pickup_loc.value = airportNAME;}
		
		if (document.calcrate.checktwo.checked==true) {
			document.calcrate.return_pickup.value = document.calcrate.return_pickupID.options[document.calcrate.return_pickupID.selectedIndex].text;
			if (servTYPE >= 3) {
				document.calcrate.return_dropoff.value = document.calcrate.return_dropoffID.options[document.calcrate.return_dropoffID.selectedIndex].text;
			} else {document.calcrate.return_dropoff.value = airportNAME;}
		} else {document.calcrate.return_pickup.value=0; document.calcrate.return_dropoff.value=0;}
		if (document.calcrate.checktwo.checked==true) {
			var pickupString = document.calcrate.transferdate1.value;
			var year1   = parseFloat(pickupString.substr(0,4));
			var month1  = parseFloat(pickupString.substr(5,2));
			var day1    = parseFloat(pickupString.substr(8,2));
			var returnString = document.calcrate.transferdate2.value;
			var year2   = parseFloat(returnString.substr(0,4));
			var month2  = parseFloat(returnString.substr(5,2));
			var day2    = parseFloat(returnString.substr(8,2));
			var pickupnum = year1+""+pad2(month1)+""+pad2(day1);
			var returnnum = year2+""+pad2(month2)+""+pad2(day2);
			if (servTYPE <= 2) {
				if (pickupnum == returnnum) {
					if(confirm('Departure and arrival in the same day ! \n\nAre you shure you want to proceed?')) { return true; } else { return false; }
				}
			}
			if (pickupnum > returnnum) {
				document.calcrate.transferdate1.className = 'dDown10Br';
				document.calcrate.transferdate2.className = 'dDown10Br';
				alert("Pickup date can not be earlier than return date!");
				return false;
			}	
		} else {return true;}
	}
}

function HLdropoff_loc() {
	if (document.calcrate.dropoff_locID.value>0) {
		document.calcrate.dropoff_locID.className  = 'dDown10';
		ERRdropoff_loc ='';
	} else { 
		document.calcrate.dropoff_locID.className  = 'dDown10Br';
		document.calcrate.dropoff_locID.focus();
		document.calcrate.checktwo.checked=false;
		document.calcrate.return_pickupID.value=0;
		ERRdropoff_loc=document.calcrate.pickup_type.value=="from"?ERRdropoff_from:ERRdropoff_to;
	}
	if (servTYPE >=3) {
		if (document.calcrate.pickup_locID.value>0) {
			document.calcrate.pickup_locID.className  = 'dDown10';
			ERRpickup_loc ='';
		} else { 
			document.calcrate.pickup_locID.className  = 'dDown10Br';
			document.calcrate.pickup_locID.focus();
			document.calcrate.checktwo.checked=false;
			document.calcrate.return_pickupID.value=0;
			document.calcrate.return_dropoffID.value=0;
			ERRpickup_loc ='Select the pick up location\n';
		}
	}
	disabreturn();	
}
function HLdate1() {
	if (document.calcrate.transferdate1.value=='') {
		document.calcrate.transferdate1.className = 'dDown10Br';
		ERR = ERR+ERRdate1;
	} else {document.calcrate.transferdate1.className = 'dDown10';}
	if ((servTYPE == 3) && (document.calcrate.checktwo.checked==true)) {document.calcrate.transferdate2.value=document.calcrate.transferdate1.value;}
}
function HLdep1h() {
	if (document.calcrate.dep1hour.value == "hh") {
		document.calcrate.dep1hour.className = 'dDown10Br';
		ERR = ERR+ERRdep1h;
	} else {document.calcrate.dep1hour.className = 'dDown10';}
}
function HLdep1m() {
	if (document.calcrate.dep1min.value == "mm") {
		document.calcrate.dep1min.className = 'dDown10Br';
		ERR = ERR+ERRdep1m;
	} else {document.calcrate.dep1min.className = 'dDown10';}
}
function HLdep2() {
	if (document.calcrate.return_pickupID.value==0) {
		document.calcrate.return_pickupID.className = 'dDown10Br';
		ERR = ERR+ERRdep2;
	} else {document.calcrate.return_pickupID.className = 'dDown10';}
}
function HLdest2() {
	if ((document.calcrate.return_dropoffID.value==0) && (servTYPE>=3)) {
		document.calcrate.return_dropoffID.className = 'dDown10Br';
		ERR = ERR+ERRdest2;
	} else {document.calcrate.return_dropoffID.className = 'dDown10';}
}
function HLdate2() {
	if (document.calcrate.transferdate2.value=='') {
		document.calcrate.transferdate2.className = 'dDown10Br';
		ERR = ERR+ERRdate2;
	} else {document.calcrate.transferdate2.className = 'dDown10';}
	if (document.calcrate.checktwo.checked==false) {document.calcrate.transferdate2.value='';}
}
function HLdep2h() {
	if (document.calcrate.dep2hour.value == "hh") {
		document.calcrate.dep2hour.className = 'dDown10Br';
		ERR = ERR+ERRdep2h;
	} else {document.calcrate.dep2hour.className = 'dDown10';}
}
function HLdep2m() {
	if (document.calcrate.dep2min.value == "mm") {
		document.calcrate.dep2min.className = 'dDown10Br';
		ERR = ERR+ERRdep2m;
	} else {document.calcrate.dep2min.className = 'dDown10';}
}
function return_btn() {
	if (document.calcrate.checktwo.checked==true) {
		if (document.calcrate.dropoff_locID.value>0) {
			document.calcrate.return_pickupID.selectedIndex=document.calcrate.dropoff_locID.selectedIndex;
		}
		if ((servTYPE >= 3) && (document.calcrate.pickup_locID.value>0)) {
			document.calcrate.return_dropoffID.value=document.calcrate.pickup_locID.value;
		}
		if ((servTYPE == 3) && (document.calcrate.transferdate1.value!="")) {
			document.calcrate.transferdate2.value=document.calcrate.transferdate1.value;
		}
	} else {
		document.calcrate.return_pickupID.value=0;
		document.calcrate.return_dropoffID.value=0;
		document.calcrate.transferdate2.value="";
	}
	HLdropoff_loc();
	if ((ERRpickup_loc!='') || (ERRdropoff_loc!='')) {
		alert('Please complete:\n\n'+ERRpickup_loc+ERRdropoff_loc);
	}
	HLdep2();
	HLdest2()
}
function fromto(){
	if (servTYPE <= 2) {
		if (document.calcrate.dropoff_locID.value>=1) {
			document.calcrate.journey1.value = "Trip: "+dist[document.calcrate.dropoff_locID.value][0]+"Km / "+dist[document.calcrate.dropoff_locID.value][1]+"H";
		} else {document.calcrate.journey1.value =""}
		if (document.calcrate.return_pickupID.value>=1) {
			document.calcrate.journey2.value = "Trip: "+dist[document.calcrate.return_pickupID.value][0]+"Km / "+dist[document.calcrate.return_pickupID.value][1]+"H";
		} else {document.calcrate.journey2.value =""}
	
		if (document.calcrate.pickup_type.value=="from") {
			document.calcrate.frto.value="to"; 
			document.calcrate.retFromTo.value="to";
			document.calcrate.pkupdttm.value="Arrival flight date / time:";
			document.calcrate.retdttm.value="Pick up date / time:";
		}
		if (document.calcrate.pickup_type.value=="to") {
			document.calcrate.frto.value="from"; 
			document.calcrate.retFromTo.value="from";
			document.calcrate.pkupdttm.value="Pick up date / time:";
			document.calcrate.retdttm.value="Arrival flight date / time:";
		}
	/*if ((document.calcrate.pickup_type.value=="Golf Transfers"))
		{ resetMenu(); document.location.href = "http://www.algarvegolftransfers.com";} 
		return false;*/
	} else {
		document.calcrate.pickup_type.value=="from"
		document.calcrate.frto.value="to"; 
		document.calcrate.retFromTo.value="to";
		document.calcrate.pkupdttm.value="Pick up date / time:";
		document.calcrate.retdttm.value="Pick up date / time:";
	}
}
function disabreturn() {
calcpret();
	if (document.calcrate.checktwo.checked==true) { // TWO WAY
		document.calcrate.return_pickupID.disabled = false;
		document.calcrate.return_dropoffID.disabled = false;
		document.calcrate.retFromTo.disabled = false;
		document.calcrate.transferdate2.disabled = false;
		document.calcrate.dep2hour.disabled = false;
		document.calcrate.dep2min.disabled = false;
	} else {  // ONE WAY
		document.calcrate.return_pickupID.disabled = true;
		document.calcrate.return_dropoffID.disabled = true;
		document.calcrate.retFromTo.disabled = true;
		document.calcrate.transferdate2.disabled = true;
		document.calcrate.transferdate2.value = '';
		document.calcrate.dep2hour.disabled = true;
		document.calcrate.dep2min.disabled = true;
	}
}




