// Javascript for booking (modified to include airport bookings) var obSrc=new Object; var obTrg=new Object; var oWin; var xWin; var iStage=0; var iFail=0; var sFail=""; var iFirst=0; var xtra=""; var selfstatus=""; var iAllow=0; function debug(sInfo){self.status=sInfo;} function doDateDiff(strDay1,strMonth1,strYear1,strDay2,strMonth2,strYear2) { var valDay1 = parseInt(Math.abs(strDay1)); var valMonth1 = parseInt(Math.abs(strMonth1)) - 1; var valYear1 = parseInt(Math.abs(strYear1)); var valDay2 = parseInt(Math.abs(strDay2)); var valMonth2 = parseInt(Math.abs(strMonth2)) - 1; var valYear2 = parseInt(Math.abs(strYear2)); var valDate1 = Date.UTC(valYear1, valMonth1, valDay1)/1000; var valDate2 = Date.UTC(valYear2, valMonth2, valDay2)/1000; if (valDate2 > valDate1) { //Start date shouldn't be later than end date return 0; }else{ return 1; } } function CheckMonthReturnDate(strbkday,strbkmonth,strbkyear,strlastday,strlastmonth,strlastyear) { var Start_Date=new Date(strbkyear,strbkmonth-1,strbkday) var Return_Date=new Date(strlastyear,strlastmonth-1,strlastday) var Year_Diff=Return_Date.getYear()-Start_Date.getYear() var Month_Diff=Return_Date.getMonth()-Start_Date.getMonth() if(Month_Diff<0) { Month_Diff+=12 Year_Diff-- } var Day_Diff=Return_Date.getDate()-Start_Date.getDate() //alert(strDay1 + ' - ' + strMonth1 + ' - ' + strYear1) //alert(Return_Date.toString()) //alert(Start_Date.toString()) //alert(Year_Diff + ' - ' + Month_Diff + ' - ' + Day_Diff) if(Year_Diff>1)return 1; if(Month_Diff>12 && Day_Diff>0)return 1; return 0 } function Check_Multi_Time(Hour,Minute) { if(isNaN(Hour) || Hour<0 || Hour>23) return 1 if(isNaN(Minute) || Minute<0 || Minute>59) return 1 return 0 } function CheckYearDate(strDay1,strMonth1,strYear1) { var Today=new Date() var This_Date=new Date(strYear1,strMonth1-1,strDay1) var Year_Diff=This_Date.getYear()-Today.getYear() var Month_Diff=This_Date.getMonth()-Today.getMonth() var Day_Diff=This_Date.getDate()-Today.getDate() //alert(strDay1 + ' - ' + strMonth1 + ' - ' + strYear1) //alert(This_Date.toString()) //alert(Today.toString()) //alert(Year_Diff + ' - ' + Month_Diff + ' - ' + Day_Diff) if(Year_Diff>1)return 1; if(Year_Diff==1) { if(Month_Diff>0)return 1; if(Day_Diff>0)return 1; } return 0 } function doDateTimeDiff(strDay1,strMonth1,strYear1,strHour1,strMinutes1,strampm1,strDay2,strMonth2,strYear2,strHour2,strMinutes2,strampm2) { var valDay1 = parseInt(Math.abs(strDay1)); var valMonth1 = parseInt(Math.abs(strMonth1)) - 1; var valYear1 = parseInt(Math.abs(strYear1)); var valHour1 = parseInt(Math.abs(strHour1)); var valMinutes1 = parseInt(Math.abs(strMinutes1)); if (strampm1 == "PM") { if (valHour1 > 11) { }else{ valHour1 = valHour1 + 12; } }else{ if (valHour1 == 12) { valHour1 = 0; } } var valDay2 = parseInt(Math.abs(strDay2)); var valMonth2 = parseInt(Math.abs(strMonth2)) - 1; var valYear2 = parseInt(Math.abs(strYear2)); var valHour2 = parseInt(Math.abs(strHour2)); var valMinutes2 = parseInt(Math.abs(strMinutes2)); if (strampm2 == "PM") { if (valHour2 > 11) { }else{ valHour2 = valHour2 + 12; } }else{ if (valHour2 == 12) { valHour2 = 0; } } var valDate1 = Date.UTC(valYear1, valMonth1, valDay1, valHour1, valMinutes1)/1000; var valDate2 = Date.UTC(valYear2, valMonth2, valDay2, valHour2, valMinutes2)/1000; strDate = new Date(valYear1, valMonth1, valDay1, valHour1, valMinutes1) strDate2 = new Date(valYear2, valMonth2, valDay2, valHour2, valMinutes2) if (valDate2 > valDate1) { //Start date shouldn't be later than end date return 0; }else{ return 1; } } function debug(vInfo){self.status=vInfo;} function checkMultiBooking(){ iFail=0; var sFail = ""; var strbkday = document.form.bkday.value; var strbkmonth = document.form.bkmonth.value; var strbkyear = document.form.bkyear.value; var strbkhour = document.form.bkhour.value; var strbkminutes = document.form.bkminutes.value; var objAMPM = document.form.radbkAMPM; var strlastday = document.form.lastday.value; var strlastmonth = document.form.lastmonth.value; var strlastyear = document.form.lastyear.value; strbkampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strbkampm = objAMPM[i].value; } } for (var i=0; i < document.form.radReturnType.length; i++) { if (document.form.radReturnType[i].checked) { var rad_val = document.form.radReturnType[i].value; } } if (testLength('OurRef',1,-1)!=0){ sFail=sFail+"Your Reference\n"; } if (testLength('Patron',1,-1)!=0){ sFail=sFail+"Passenger's name"; setFocus('Patron'); } //check date if (CheckDate(strbkday,strbkmonth,strbkyear)!=0){ if (iFail==1){ sFail=sFail+"Valid booking date"; setFocus('bkday'); }else{ sFail=sFail+"\nValid booking date"; } } //check time if (CheckTime(strbkhour,strbkminutes)!=0){ if (iFail==1){ sFail=sFail+"Valid booking time"; setFocus('bkhour'); }else{ sFail=sFail+"\nValid booking time"; } } //check last date if (CheckDate(strlastday,strlastmonth,strlastyear)!=0){ if (iFail==1){ sFail=sFail+"Valid last date"; setFocus('lastday'); }else{ sFail=sFail+"\nValid last date"; } } //check return time if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ var strretday = strbkday; var strretmonth = strbkmonth; var strretyear = strbkyear; var strrethour = document.form.rethour.value; var strretminutes = document.form.retminutes.value; var objAMPM = document.form.radretAMPM; strretampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strretampm = objAMPM[i].value; } } if (CheckDate(strretday,strretmonth,strretyear)!=0){ if (iFail==1){ sFail=sFail+"Valid return time"; setFocus('rethour'); }else{ sFail=sFail+"\nValid return time"; } } } obTrg=document.form.PickUpList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields pkbuilding = document.form.PKBuilding.value; pkairport = document.form.PKAirport.value; pkstreetnum = document.form.PKStreetNum.value; pkstreet = document.form.PKStreet.value; pkarea = document.form.PKArea.value; pktown = document.form.PKTown.value; var oAirport=getObjByID("pkShowAirport"); //must have street name and either street no or building if (pkstreet.length>0 || pkAirport.length > 0) { if (pkstreetnum.length>0||pkbuilding.length>0) { if (pkarea.length>0||pktown.length>0) { bnoaddress = false; } else { sAddress="Area name or town for pick up"; bnoaddress = true; } } else { sAddress="Building name or number for pick up"; bnoaddress = true; } } else { sAddress="Street name for pick up"; bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+sAddress; }else{ sFail=sFail+"\n" + sAddress; } } } } for (i=0; i < obTrg.length;i++){ obTrg[i].selected = true; } obTrg=document.form.DropOffList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields doarea = document.form.DOArea.value; if (doarea.length>0) { bnoaddress = false; }else{ bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+"Area name for drop off"; }else{ sFail=sFail+"\nArea name for drop off"; } } } } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } if (iFail!=0){ sFail = "To make a booking you must enter following details:\n\n" + sFail alert(sFail); return; } //check future date if (CheckFutureDate(strbkday,strbkmonth,strbkyear,strbkhour,strbkminutes,strbkampm)!=0){ sFail="Journeys must be in the future"; alert(sFail); setFocus('bkday'); iFail=0; return; } //check date is less than a year in the future if (CheckYearDate(strbkday,strbkmonth,strbkyear)!=0){ sFail="Journeys cannot be booked more than one year in advance"; alert(sFail); setFocus('bkday'); iFail=0; return; } //check date is less than a year in the future if (CheckMonthReturnDate(strbkday,strbkmonth,strbkyear,strlastday,strlastmonth,strlastyear)!=0){ sFail="First and last dates of travel can be no more than one year apart"; alert(sFail); setFocus('bkday'); iFail=0; return; } //Compare first and last dates if (CheckTime(strbkhour,strbkminutes)==0){ var jsDD=doDateDiff(strbkday,strbkmonth,strbkyear,strlastday,strlastmonth,strlastyear) if (jsDD>0){ alert("Please check your start and end dates as the date for your first journey is after your return journey"); return; } } //Compare outgoing date/time with return date/time if (CheckTime(strbkhour,strbkminutes)==0){ if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ var jsDD=doDateTimeDiff(strbkday,strbkmonth,strbkyear, strbkhour, strbkminutes, strbkampm, strretday ,strretmonth ,strretyear, strrethour, strretminutes, strretampm); if (jsDD>0){ alert("Please check your start and end dates as the date for your first journey is after your return journey"); return; } } } //check passenger no var vehicletypeid = document.form.VehicleType.value; var noofpassengers = document.form.Passengers.value; var noofvehicles = document.form.VehiclesRequired.value; for (i=0;i<=document.form.noofvehicles.value;i++){ if (vehicletypeid == arrSelection[i][0]) { //compare no of passengers with allowed if (arrSelection[i][1] > 0) { var noofallowedpassengers = noofvehicles * arrSelection[i][1] if (arrSelection[i][1] > 0) { if (noofpassengers > noofallowedpassengers) { alert("You have selected too many passengers for this vehicle"); return; } } } } } //document.form.action="ConfirmMultiBooking.asp"; document.form.action="MultiBookingInfo2.asp"; document.form.submit(); } function checkRepeatJourneys() { var noofoptions = 0; var strdayname; var strbkday = document.form.bkday.value; var strbkmonth = document.form.bkmonth.value; var strbkyear = document.form.bkyear.value; var strbkhour = document.form.bkhour.value; var strbkminutes = document.form.bkminutes.value; var objAMPM = document.form.radbkAMPM; var strlastday = document.form.lastday.value; var strlastmonth = document.form.lastmonth.value; var strlastyear = document.form.lastyear.value; strbkampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strbkampm = objAMPM[i].value; } } for (var i=0; i < document.form.radReturnType.length; i++) { if (document.form.radReturnType[i].checked) { var rad_val = document.form.radReturnType[i].value; } } if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ noofoptions = 0; for (i=0; i < document.form.returnfield.length; i++) { if (document.form.returnfield[i].checked) { strdayname = document.form.returnfield[i].value; noofoptions++; } } if (noofoptions == 0) { alert("You must select the days on which you want the return journey to be repeated"); return; } } //Good god! This is so utterly stupid. iFail=0 for (i=0; i < document.form.every.length; i++) { if (document.form.every[i].checked) { strdayname = document.form.every[i].value; switch(strdayname) { case "monday":iFail+=Check_Multi_Time(document.form.monhour.value,document.form.monminutes.value);break; case "tuesday":iFail+=Check_Multi_Time(document.form.tuehour.value,document.form.tueminutes.value);break; case "wednesday":iFail+=Check_Multi_Time(document.form.wedhour.value,document.form.wedminutes.value);break; case "thursday":iFail+=Check_Multi_Time(document.form.thuhour.value,document.form.thuminutes.value);break; case "friday":iFail+=Check_Multi_Time(document.form.frihour.value,document.form.friminutes.value);break; case "saturday":iFail+=Check_Multi_Time(document.form.sathour.value,document.form.satminutes.value);break; case "sunday":iFail+=Check_Multi_Time(document.form.sunhour.value,document.form.sunminutes.value);break; } //alert("checked " + strdayname + " - " + iFail) } } for (i=0; i < document.form.returnfield.length; i++) { if (document.form.returnfield[i].checked) { strdayname = document.form.returnfield[i].value; switch(strdayname) { case "monday":iFail+=Check_Multi_Time(document.form.monRethour.value,document.form.monRetminutes.value);break; case "tuesday":iFail+=Check_Multi_Time(document.form.tueRethour.value,document.form.tueRetminutes.value);break; case "wednesday":iFail+=Check_Multi_Time(document.form.wedRethour.value,document.form.wedRetminutes.value);break; case "thursday":iFail+=Check_Multi_Time(document.form.thuRethour.value,document.form.thuRetminutes.value);break; case "friday":iFail+=Check_Multi_Time(document.form.friRethour.value,document.form.friRetminutes.value);break; case "saturday":iFail+=Check_Multi_Time(document.form.satRethour.value,document.form.satRetminutes.value);break; case "sunday":iFail+=Check_Multi_Time(document.form.sunRethour.value,document.form.sunRetminutes.value);break; } //alert("checked " + strdayname + " - " + iFail) } } if (iFail!=0) { sFail = "Please enter valid times for your journeys"; alert(sFail); return; } iFail=0 for (i=0; i < document.form.returnfield.length; i++) { if (document.form.every[i].checked && document.form.returnfield[i].checked) { strdayname = document.form.returnfield[i].value; switch(strdayname) { case "monday":iFail+=(parseInt(document.form.monhour.value)>parseInt(document.form.monRethour.value) || (parseInt(document.form.monhour.value)==parseInt(document.form.monRethour.value) && parseInt(document.form.monminutes.value)>=parseInt(document.form.monRetminutes.value)));break; case "tuesday":iFail+=(parseInt(document.form.tuehour.value)>parseInt(document.form.tueRethour.value) || (parseInt(document.form.tuehour.value)==parseInt(document.form.tueRethour.value) && parseInt(document.form.tueminutes.value)>=parseInt(document.form.tueRetminutes.value)));break; case "wednesday":iFail+=(parseInt(document.form.wedhour.value)>parseInt(document.form.wedRethour.value) || (parseInt(document.form.wedhour.value)==parseInt(document.form.wedRethour.value) && parseInt(document.form.wedminutes.value)>=parseInt(document.form.wedRetminutes.value)));break; case "thursday":iFail+=(parseInt(document.form.thuhour.value)>parseInt(document.form.thuRethour.value) || (parseInt(document.form.thuhour.value)==parseInt(document.form.thuRethour.value) && parseInt(document.form.thuminutes.value)>=parseInt(document.form.thuRetminutes.value)));break; case "friday":iFail+=(parseInt(document.form.frihour.value)>parseInt(document.form.friRethour.value) || (parseInt(document.form.frihour.value)==parseInt(document.form.friRethour.value) && parseInt(document.form.friminutes.value)>=parseInt(document.form.friRetminutes.value)));break; case "saturday":iFail+=(parseInt(document.form.sathour.value)>parseInt(document.form.satRethour.value) || (parseInt(document.form.sathour.value)==parseInt(document.form.satRethour.value) && parseInt(document.form.satminutes.value)>=parseInt(document.form.satRetminutes.value)));break; case "sunday":iFail+=(parseInt(document.form.sunhour.value)>parseInt(document.form.sunRethour.value) || (parseInt(document.form.sunhour.value)==parseInt(document.form.sunRethour.value) && parseInt(document.form.sunminutes.value)>=parseInt(document.form.sunRetminutes.value)));break; } //alert("checked " + strdayname + " - " + iFail) } } if (iFail!=0) { sFail = "Return journey times cannot be before, or the same as, outward journey times"; alert(sFail); return; } //check multi options match dates var arrdays = new Array("sunday","monday", "tuesday"); var arrdays = arrdays.concat("wednesday","thursday", "friday","saturday"); var objEvery = document.form.every; noofoptions = 0; for (i=0; i < objEvery.length; i++) { if (objEvery[i].checked) { noofoptions++; } } if (noofoptions == 0) { alert("You must select the days on which you want this journey to be repeated"); return; }else{ //check through days to check that they match range //get starting day var intstartdaynum = GetDay(strbkday,strbkmonth,strbkyear); var strstartdayname = arrdays[intstartdaynum]; iFail=1; for (i=0; i < objEvery.length; i++) { if (objEvery[i].checked) { strdayname = objEvery[i].value; if (strdayname == strstartdayname) { //ok iFail=0; } } } if (iFail==0){ //get ending day var intlastdaynum = GetDay(strlastday,strlastmonth,strlastyear); var strlastdayname = arrdays[intlastdaynum]; iFail=1; for (i=0; i < objEvery.length; i++) { if (objEvery[i].checked) { strdayname = objEvery[i].value; if (strdayname == strlastdayname) { //ok iFail=0; } } } } //Have these been selected? if (iFail!=0){ sFail = "The repeat days you have selected do not match your date range"; alert(sFail); return; } var intdatesdiff = GetDateRangeDiff(strbkday,strbkmonth,strbkyear,strlastday,strlastmonth,strlastyear); intdatesdiff = intdatesdiff/1000; intdatesdiff = intdatesdiff/60; intdatesdiff = intdatesdiff/60; intdatesdiff = intdatesdiff/24; if (intdatesdiff < 7 ) { //check that days selected are applicable for this date range var intdaynum; var valstartdate = new Date(strbkyear, (strbkmonth - 1), strbkday); var valstartminutes = valstartdate.getTime() var intaddtodate = 0; var valnextdate; var strnextdayname = ""; var stralldaynames = ""; for (i=0; i < objEvery.length; i++) { if (objEvery[i].checked) { strdayname = objEvery[i].value; iFail=1; //does a date within the date range match this day? for (j=0; j <= intdatesdiff; j++) { intaddtodate = parseInt(j * 1000 * 60 * 60 * 24); valnextdate = new Date((parseInt(valstartminutes) + parseInt(intaddtodate))); intdaynum = valnextdate.getDay(); strnextdayname = arrdays[intdaynum]; if (strdayname == strnextdayname) { //ok iFail=0; } } if (iFail==1){ if (stralldaynames.length>0){ stralldaynames = stralldaynames + "\n" + strdayname }else{ stralldaynames = stralldaynames + strdayname } } } } if (stralldaynames.length>0){ sFail = "The date range you have selected does not include:\n" + stralldaynames + "\nPlease check and resubmit."; alert(sFail); return; } }else{ //ok as any day can be selected } } document.form.action="ConfirmMultiBooking.asp?mode=submitted"; document.form.submit(); } function checkEditMultiBooking(){ iFail=0; var sFail = ""; if (testLength('Patron',1,-1)!=0){ sFail=sFail+"Passenger's name"; setFocus('Patron'); } if (iFail!=0){ sFail = "To update this booking you must enter following details:\n\n" + sFail alert(sFail); return; } document.form.action="ConfirmMultiBooking.asp?mode=edit"; document.form.submit(); } function confirmMultiBooking(intclientstatus){ document.form.action="ModifyMultiBooking.asp?clientstatus="+intclientstatus; document.form.submit(); } function checkBooking(bReturn) { iFail=0; var sFail = ""; bPKAirport = false; bDOAirport = false; //Check if pickup airport booking showing var oAirport=getObjByID("pkShowAirport"); //alert("oAirport.style.display = " + oAirport.style.display) if (oAirport.style.display == "inline") { bPKAirport = true; } if (bPKAirport == true) { document.form.PKCompany.value = document.form.PKAirport.value; document.form.PKBuilding.value = document.form.PKTerminal.value; } //Check if dropoff airport booking showing var oAirport=getObjByID("doShowAirport"); //alert("oAirport.style.display = " + oAirport.style.display) if (oAirport.style.display == "inline") { bDOAirport = true; } if (bDOAirport == true) { document.form.DOCompany.value = document.form.DOAirport.value; document.form.DOBuilding.value = document.form.DOTerminal.value; } //alert("PKFlightDate = " + document.form.PKFlightDate.value + ", PKFlightETA = " + document.form.PKFlightETA.value) if(document.form.radReturnType) { for (var i=0; i < document.form.radReturnType.length; i++) { if (document.form.radReturnType[i].checked) { var rad_val = document.form.radReturnType[i].value; } } } else { rad_val=0; } if (bPKAirport == true) { if(testLength('PKFlightDate',1,-1)!=0) { sFail=sFail+"Pick Up Flight Date\n"; setFocus('PKFlightDate'); } if (testLength('PKFlightETA',1,-1)!=0) { sFail=sFail+"Pick Up Flight Time\n"; setFocus('PKFlightETA'); } } if (bDOAirport == true) { if(testLength('DOFlightDate',1,-1)!=0) { sFail=sFail+"Drop Off Flight Date\n"; setFocus('DOFlightDate'); } if (testLength('DOFlightETA',1,-1)!=0) { sFail=sFail+"Drop Off Flight Time\n"; setFocus('DOFlightETA'); } } if (testLength('OurRef',1,-1)!=0){ sFail=sFail+"Your Reference\n"; setFocus('OurRef'); } if (testLength('Patron',1,-1)!=0){ sFail=sFail+"Passenger's name\n"; setFocus('Patron'); } if (!ValidEmail(document.form.Email.value)) { sFail=sFail+"Valid Email Address\n"; setFocus('Email'); } if (testLength('ContactNo',1,-1)!=0){ sFail=sFail+"Contact Telephone No."; setFocus('ContactNo'); } //check date var objTimeType = document.form.bktimetype; var bktimetype = ""; for (i=0; i < objTimeType.length; i++) { if (objTimeType[i].checked) { bktimetype = objTimeType[i].value; } } if (bktimetype == "asap") { //no need to check date/time var datasapdate = new Date(); var strbkday = datasapdate.getDate(); var strbkmonth = datasapdate.getMonth() + 1; var strbkyear = datasapdate.getYear(); var strbkhour = datasapdate.getHours(); var strbkminutes = datasapdate.getMinutes(); if (strbkhour > 11) { strbkampm = "PM" }else{ strbkampm = "AM" } }else{ var strbkday = document.form.bkday.value; var strbkmonth = document.form.bkmonth.value; var strbkyear = document.form.bkyear.value; var strbkhour = document.form.bkhour.value; var strbkminutes = document.form.bkminutes.value; var objAMPM = document.form.radbkAMPM; strbkampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strbkampm = objAMPM[i].value; } } if (CheckDate(strbkday,strbkmonth,strbkyear)!=0){ if (iFail==1){ sFail=sFail+"Valid booking date"; setFocus('bkday'); }else{ sFail=sFail+"\nValid booking date"; } } //check time if (CheckTime(strbkhour,strbkminutes)!=0){ if (iFail==1){ sFail=sFail+"Valid booking time"; setFocus('bkhour'); }else{ sFail=sFail+"\nValid booking time"; } } } //check return date if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ var strretday = document.form.retday.value; var strretmonth = document.form.retmonth.value; var strretyear = document.form.retyear.value; var strrethour = document.form.rethour.value; var strretminutes = document.form.retminutes.value; var objAMPM = document.form.radretAMPM; strretampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strretampm = objAMPM[i].value; } } if (CheckDate(strretday,strretmonth,strretyear)!=0){ if (iFail==1){ sFail=sFail+"Valid return date"; setFocus('retday'); }else{ sFail=sFail+"\nValid return date"; } } //check return time if (CheckTime(strrethour,strretminutes)!=0){ if (iFail==1){ sFail=sFail+"Valid return time"; setFocus('rethour'); }else{ sFail=sFail+"\nValid return time"; } } } obTrg=document.form.PickUpList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields pkbuilding = document.form.PKBuilding.value; pkstreetnum = document.form.PKStreetNum.value; pkstreet = document.form.PKStreet.value; pkarea = document.form.PKArea.value; pktown = document.form.PKTown.value; pkairport = document.form.PKAirport.value; pkcompany = document.form.PKCompany.value; var bnoaddress; //must have street name and either street no or building //must have street name and either street no or building if (pkstreet.length>0 || pkAirport.length > 0) { if (pkstreetnum.length>0||pkbuilding.length>0) { if (pkarea.length>0||pktown.length>0) { bnoaddress = false; } else { sAddress="Area name or town for pick up"; bnoaddress = true; } } else { if( pkairport.length == 0) { sAddress="Building name or number for pick up"; bnoaddress = true; } } } else { sAddress="Street name for pick up"; bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+sAddress; }else{ sFail=sFail+"\n" + sAddress; } } } } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } obTrg=document.form.DropOffList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields doarea = document.form.DOArea.value; docompany = document.form.DOCompany.value; if (doarea.length>0||docompany.length>0) { bnoaddress = false; }else{ bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+"Area name for drop off"; }else{ sFail=sFail+"\nArea name for drop off"; } } } } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } if (iFail!=0){ sFail = "To make a booking or receive a quotation you must enter following details:\n\n" + sFail alert(sFail); return; } //check number if (CheckNumber(document.form.VehiclesRequired.value)!=0){ sFail="You must enter a valid number of vehicles required"; alert(sFail); setFocus('VehiclesRequired'); iFail=0; return; } //check number if (CheckNumber(document.form.Passengers.value)!=0){ sFail="You must enter a valid number of passengers"; alert(sFail); setFocus('Passengers'); iFail=0; return; } //check passenger no var vehicletypeid = document.form.VehicleType.value; var noofpassengers = document.form.Passengers.value; var noofvehicles = document.form.VehiclesRequired.value; for (i=0;i<=document.form.noofvehicles.value;i++){ if (vehicletypeid == arrSelection[i][0]) { //compare no of passengers with allowed if (arrSelection[i][1] > 0) { var noofallowedpassengers = noofvehicles * arrSelection[i][1] if (arrSelection[i][1] > 0) { if (noofpassengers > noofallowedpassengers) { alert("You have selected too many passengers for this vehicle"); return; } } } } } if (CheckTime(strbkhour,strbkminutes)==0){ if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ var jsDD=doDateTimeDiff(strbkday,strbkmonth,strbkyear, strbkhour, strbkminutes, strbkampm, strretday ,strretmonth ,strretyear, strrethour, strretminutes, strretampm); if (jsDD>0){ alert("Please check your start and end dates as the date for your first journey is after your return journey"); return; } } } if (bktimetype == "asap") { //no need to check date/time }else{ if (document.form.bookingtype.value=="2") { //historical booking if (CheckPastDate(strbkday,strbkmonth,strbkyear,strbkhour,strbkminutes,strbkampm)!=0){ sFail="Journeys must be in the past"; alert(sFail); setFocus('bkday'); iFail=0; return; } if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn") { if (CheckPastDate(strretday ,strretmonth ,strretyear, strrethour, strretminutes, strretampm)!=0) { sFail="Return journey must be in the past"; alert(sFail); setFocus('bkday'); iFail=0; return; } } }else{ //check future date if (CheckFutureDate(strbkday,strbkmonth,strbkyear,strbkhour,strbkminutes,strbkampm)!=0){ sFail="Journeys must be in the future"; alert(sFail); setFocus('bkday'); iFail=0; return; } //check date is less than a year in the future if (CheckYearDate(strbkday,strbkmonth,strbkyear)!=0){ sFail="Journeys cannot be booked more than one year in advance"; alert(sFail); setFocus('bkday'); iFail=0; return; } } } if (bReturn != 1) { document.form.action="confirmbooking.asp"; document.form.submit(); } else { return true; } } function checkUpdateBooking(){ iFail=0; var sFail = ""; //check date var objTimeType = document.form.bktimetype; var bktimetype = ""; if(objTimeType) for (i=0; i < objTimeType.length; i++) { if (objTimeType[i].checked) { bktimetype = objTimeType[i].value; } } if (bktimetype == "asap") { //no need to check date/time var datasapdate = new Date(); var strbkday = datasapdate.getDate(); var strbkmonth = datasapdate.getMonth() + 1; var strbkyear = datasapdate.getYear(); var strbkhour = datasapdate.getHours(); var strbkminutes = datasapdate.getMinutes(); if (strbkhour > 11) { strbkampm = "PM" }else{ strbkampm = "AM" } }else{ var strbkday = document.form.journeyday.value; var strbkmonth = document.form.journeymonth.value; var strbkyear = document.form.journeyyear.value; var strbkhour = document.form.journeyhour.value; var strbkminutes = document.form.journeyminutes.value; var objAMPM = document.form.radbkAMPM; strbkampm = "AM"; for (i=0; i < objAMPM.length; i++) { if (objAMPM[i].checked) { strbkampm = objAMPM[i].value; } } if (CheckDate(strbkday,strbkmonth,strbkyear)!=0){ if (iFail==1){ sFail=sFail+"Valid booking date"; setFocus('bkday'); }else{ sFail=sFail+"\nValid booking date"; } } //check time if (CheckTime(strbkhour,strbkminutes)!=0){ if (iFail==1){ sFail=sFail+"Valid booking time"; setFocus('bkhour'); }else{ sFail=sFail+"\nValid booking time"; } } } obTrg=document.form.PickUpList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields pkbuilding = document.form.PKBuilding.value; pkstreetnum = document.form.PKStreetNum.value; pkstreet = document.form.PKStreet.value; pkarea = document.form.PKArea.value; pktown = document.form.PKTown.value; //must have street name and either street no or building if (pkstreet.length>0) { if (pkstreetnum.length>0 || pkbuilding.length>0) { if (pkarea.length>0 || pktown.length>0) { bnoaddress = false; }else{ sAddress="Area name or town for pick up"; bnoaddress = true; } }else{ sAddress="Building name or number for pick up IS3"; bnoaddress = true; } }else{ sAddress="Street Name for pick up"; bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+sAddress; }else{ sFail=sFail+"\n" + sAddress; } } } } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } obTrg=document.form.DropOffList; if (obTrg.length==1){ //check if = 'no location' if (obTrg[0].value == "null") { //check address fields doarea = document.form.DOArea.value; if (doarea.length>0) { bnoaddress = false; }else{ bnoaddress = true; } if (bnoaddress == true) { iFail++; if (iFail==1){ sFail=sFail+"Area name for drop off"; }else{ sFail=sFail+"\nArea name for drop off"; } } } } for (i=0;i < obTrg.length;i++){ obTrg[i].selected = true; } if (iFail!=0){ sFail = "To make a booking you must enter following details:\n\n" + sFail alert(sFail); return; } //check number //if (CheckNumber(document.form.VehiclesRequired.value)!=0){ // sFail="You must enter a valid number of vehicles required"; // alert(sFail); // setFocus('VehiclesRequired'); // iFail=0; // return; // } //check number if (CheckNumber(document.form.Passengers.value)!=0){ sFail="You must enter a valid number of passengers"; alert(sFail); setFocus('Passengers'); iFail=0; return; } //check passenger no var vehicletypeid = document.form.VehicleType.value; var noofpassengers = document.form.Passengers.value; //var noofvehicles = document.form.VehiclesRequired.value; /*for (i=0;i<=document.form.noofvehicles.value;i++){ if (vehicletypeid == arrSelection[i][0]) { //compare no of passengers with allowed if (arrSelection[i][1] > 0) { var noofallowedpassengers = noofvehicles * arrSelection[i][1] if (arrSelection[i][1] > 0) { if (noofpassengers > noofallowedpassengers) { alert("You have selected too many passengers for this vehicle"); return; } } } } }*/ /*if (CheckTime(strbkhour,strbkminutes)==0){ if (document.form.ReturnJourney.value=="1" && rad_val=="newreturn"){ var jsDD=doDateTimeDiff(strbkday,strbkmonth,strbkyear, strbkhour, strbkminutes, strbkampm, strretday ,strretmonth ,strretyear, strrethour, strretminutes, strretampm); if (jsDD>0){ alert("Please check your start and end dates as the date for your first journey is after your return journey"); return; } } }*/ if (bktimetype == "asap") { //no need to check date/time }else{ //check future date if (CheckFutureDate(strbkday,strbkmonth,strbkyear,strbkhour,strbkminutes,strbkampm)!=0){ sFail="Journeys must be in the future"; alert(sFail); setFocus('bkday'); iFail=0; return; } //check date is less than a year in the future if (CheckYearDate(strbkday,strbkmonth,strbkyear)!=0){ sFail="Journeys cannot be booked more than one year in advance"; alert(sFail); setFocus('bkday'); iFail=0; return; } } //document.form.action="confirmbooking.asp"; document.form.submit(); } function confirmBooking() { editmode = document.form.editmode.value; bookingtype = document.form.bookingtype.value; name = document.form.Patron.value; email = document.form.Email.value; ID = document.form.BookingId.value; alert("editmode = "+ editmode +"\nbookingtype = " + bookingtype + "\nID = " + ID); document.form.action="ModifyBooking.asp?mode="+editmode+"&bookingtype="+bookingtype+"&name="+escape(name)+"&email="+escape(email); document.form.submit(); } function confirmQuoteBooking() { var editmode = "quotesupplied"; var bookingtype = document.form.bookingtype.value; var priority = document.form.priority.value; ID = document.form.BookingId.value; //alert("editmode = "+ editmode +"\nbookingtype = " + bookingtype + "\nID = " + ID); if (priority ==1) { document.form.action="priority_details.asp?id="+ID + "&name=" + escape(document.form.Patron.value); } else { document.form.action="step4.asp?id="+ID+"&mode="+editmode+"&bookingtype="+bookingtype + "&priority=" + priority; } document.form.submit(); } function GetDay(strDay,strMonth,strYear) { //Pass day value, month value, year value if (strDay > 0 && strMonth > 0 && strYear > 0) { var valDay = parseInt(Math.abs(strDay)); var valMonth = parseInt(Math.abs(strMonth)) - 1; var valYear = parseInt(Math.abs(strYear)); var valDate = new Date(valYear, valMonth, valDay) var valWeekDay = valDate.getDay(); return valWeekDay; }else{ iFail++;return 1; } } function GetDateRangeDiff(strDay1,strMonth1,strYear1,strDay2,strMonth2,strYear2) { //Pass day value, month value, year value if (strDay1 > 0 && strMonth1 > 0 && strYear1 > 0) { var valDay1 = parseInt(Math.abs(strDay1)); var valMonth1 = parseInt(Math.abs(strMonth1)) - 1; var valYear1 = parseInt(Math.abs(strYear1)); var valDay2 = parseInt(Math.abs(strDay2)); var valMonth2 = parseInt(Math.abs(strMonth2)) - 1; var valYear2 = parseInt(Math.abs(strYear2)); var valDate1 = new Date(valYear1, valMonth1, valDay1) ; var valDate2 = new Date(valYear2, valMonth2, valDay2) ; var valdatediff = (valDate2 - valDate1); return valdatediff; }else{ iFail++;return 1; } } function CheckDate(strDay,strMonth,strYear) { //Pass day value, month value, year value if (strDay > 0 && strMonth > 0 && strYear > 0) { var valDay = parseInt(Math.abs(strDay)); var valMonth = parseInt(Math.abs(strMonth)); var valYear = parseInt(Math.abs(strYear)); if (valMonth <= 0 || valMonth > 12 || valDay <= 0) { iFail++; return 1; } //Is the date selected valid? var bleapyear = false; if (valYear % 4 == 0) { if (valYear % 100 == 0) { if (valYear % 400 == 0) { bleapyear = true; }else{ bleapyear = false; } }else{ bleapyear = true; } } if (bleapyear == true) { var arrmonthmax = new Array(31,31,29,31,30,31,30,31,31,30,31,30,31); }else{ var arrmonthmax = new Array(31,31,28,31,30,31,30,31,31,30,31,30,31); } var endday = arrmonthmax[valMonth]; //Check day does not exceed number of days in month if (valDay > endday) { iFail++; return 1; }else{ return 0; } }else{ iFail++;return 1; } } function CheckFutureDate(strDay,strMonth,strYear,strHour,strMinutes,strbkampm) { //Pass day value, month value, year value if (strDay > 0 && strMonth > 0 && strYear > 0) { var valDay = parseInt(Math.abs(strDay)); var valMonth = parseInt(Math.abs(strMonth)) - 1; var valYear = parseInt(Math.abs(strYear)); var valHour = parseInt(Math.abs(strHour)); var valMinutes = parseInt(Math.abs(strMinutes)); if (strbkampm == "PM") { if (valHour > 11) { }else{ valHour = valHour + 12; } }else{ if (valHour == 12) { valHour = 0; } } var now = new Date(); var valNowDay = now.getDate(); var valNowMonth = now.getMonth(); var valNowYear = now.getYear(); var valNowHour = now.getHours(); var valNowMinutes = now.getMinutes(); var valTodayDate = Date.UTC(valNowYear, valNowMonth, valNowDay,valNowHour,valNowMinutes) / 1000; var valDate = Date.UTC(valYear,valMonth,valDay,valHour,valMinutes) / 1000; if ((valDate-valTodayDate)<0){ iFail++; return 1; }else{ return 0; } }else{ iFail++;return 1; } } function CheckPastDate(strDay,strMonth,strYear,strHour,strMinutes,strbkampm) { //Pass day value, month value, year value if (strDay > 0 && strMonth > 0 && strYear > 0) { var valDay = parseInt(Math.abs(strDay)); var valMonth = parseInt(Math.abs(strMonth)) - 1; var valYear = parseInt(Math.abs(strYear)); var valHour = parseInt(Math.abs(strHour)); var valMinutes = parseInt(Math.abs(strMinutes)); if (strbkampm == "PM") { if (valHour > 11) { }else{ valHour = valHour + 12; } }else{ if (valHour == 12) { valHour = 0; } } var now = new Date(); var valNowDay = now.getDate(); var valNowMonth = now.getMonth(); var valNowYear = now.getYear(); var valNowHour = now.getHours(); var valNowMinutes = now.getMinutes(); var valTodayDate = Date.UTC(valNowYear, valNowMonth, valNowDay,valNowHour,valNowMinutes) / 1000; var valDate = Date.UTC(valYear,valMonth,valDay,valHour,valMinutes) / 1000; if ((valDate-valTodayDate)<0){ return 0; }else{ iFail++; return 1; } }else{ iFail++;return 1; } } function CheckTime(strHour,strMinutes) { //Pass time value and number of control //Checks time has been entered in 09:10 or 9:10 format var bValid; var intHours = parseInt(Math.abs(strHour)); var intMinutes = parseInt(Math.abs(strMinutes)); //Check hours & minutes if (intHours<24 && intHours>-1) { if (intMinutes < 60 && intHours>-1) { //Valid time bValid = true; }else{ bValid = false; } }else{ bValid = false; } if (bValid == true) { return 0; }else{ iFail++;return 1; } } function doRetJour(){ var oReturn=document.form.chkreturn; var oReturnJourney=document.form.ReturnJourney; var oReturnType1=getObjByID("ShowReturnType1"); var oReturnType2=getObjByID("ShowReturnType2"); var oSRJ=getObjByID("ShowReturnJourney"); var oSRJ2=getObjByID("ShowReturnJourney2"); var ObjMidnight=getObjByID("retmidnight"); var ObjMidday=getObjByID("retmidday"); if (oReturn.checked==true){ oReturnJourney.value=1; oReturnType1.style.display=""; oReturnType2.style.display=""; }else{ oReturnJourney.value=0; oReturnType1.style.display="none"; oReturnType2.style.display="none"; oSRJ.style.display="none"; oSRJ2.style.display="none"; ObjMidnight.style.display="none"; ObjMidday.style.display="none"; } } function doMRetJour(){ var oReturn=document.form.chkreturn; var oReturnJourney=document.form.ReturnJourney; var oReturnType1=getObjByID("ShowReturnType1"); var oReturnType2=getObjByID("ShowReturnType2"); var oSRJ=getObjByID("ShowReturnJourney"); //var oSRJM=getObjByID("ShowMultiReturn"); var ObjMidnight=getObjByID("retmidnight"); var ObjMidday=getObjByID("retmidday"); if (oReturn.checked==true){ oReturnJourney.value=1; oReturnType1.style.display=""; oReturnType2.style.display=""; }else{ oReturnJourney.value=0; oReturnType1.style.display="none"; oReturnType2.style.display="none"; oSRJ.style.display="none"; //oSRJM.style.display="none"; ObjMidnight.style.display="none"; ObjMidday.style.display="none"; } } function doRetType(nv){ var oSRJ=getObjByID("ShowReturnJourney"); var oSRJ2=getObjByID("ShowReturnJourney2"); var ObjMidnight=getObjByID("retmidnight"); var ObjMidday=getObjByID("retmidday"); if (nv==0){ oSRJ.style.display="none"; oSRJ2.style.display="none"; ObjMidnight.style.display="none"; ObjMidday.style.display="none"; }else{ oSRJ.style.display=""; oSRJ2.style.display=""; } } function doMRetType(nv){ var oSRJ=getObjByID("ShowReturnJourney"); var oSRJM=getObjByID("ShowMultiReturn"); var ObjMidnight=getObjByID("retmidnight"); var ObjMidday=getObjByID("retmidday"); if (nv==0){ oSRJ.style.display="none"; if(oSRJM){ oSRJM.style.display="none"; } ObjMidnight.style.display="none"; ObjMidday.style.display="none"; }else{ oSRJ.style.display=""; if(oSRJM){ oSRJM.style.display=""; } } } function doFreeInstruction() { var oShowFreeInstruction=getObjByID("ShowFreeInstruction"); var oFreeInstructionText=getObjByID("special"); var oInstructionChoice=document.form.specialtype; if (oInstructionChoice.value=="-1"){ oShowFreeInstruction.style.display=""; }else{ oShowFreeInstruction.style.display="none"; oFreeInstructionText.value=""; } } function testLength(sObjName,iMin,iMax){ var sText=eval("document.form."+sObjName+".value"); var iLen=sText.length; if (iMax==-1){ iMax=iLen+1; } if (iLen>=iMin&&iLen<=iMax){ return 0; }else{ iFail++;return 1; } } function setFocus(sObjName) { // alert(sObjName); var obj=eval("document.form."+sObjName);obj.focus(); } function doremove(obTrg){ var dodel=0; for (var i = 0; i < obTrg.length; i++) { if (obTrg[i].selected==true){dodel=1;} if (dodel==1) { x=i; y=i+1; if (i==obTrg.length-1) {obTrg[x].value="";obTrg[x].text="";} else {obTrg[x].value=obTrg[y].value;obTrg[x].text=obTrg[y].text;} } } if (dodel==1){ if (obTrg.length==1) { obTrg[0].value="null"; obTrg[0].text="No locations selected "; if (obTrg.name == "PickUpList") { var oRef=getObjByID("pickuptitle1"); oRef.style.display=""; var oRef=getObjByID("pickuptitle2"); oRef.style.display="none"; } }else{ obTrg.length=obTrg.length-1; } } } function listjourneys(bookingid,statusid,mode){ var viewFile="listjourneys.asp?bookingid="+bookingid+"&statusid="+statusid+"&mode="+mode; var winOpts="scrollbars=1,width=600,height=450"; var nWin=window.open(viewFile,"newWin",winOpts); nWin.focus(); } function editjourneys(bookingid,statusid,clientstatusid,mode){ var viewFile="linkedjourneys.asp?bookingid="+bookingid+"&statusid="+statusid+"&mode="+mode; document.location.href=viewFile; } function cancelBooking() { var BkId=document.form.BookingId.value; var bcontinue; //complete this later var cancelperiod=document.form.CancelPeriod.value; cancelperiod = parseInt(cancelperiod) //work out cancelperiod in millisecond cancelperiod = (cancelperiod * 60) * 1000 //work out journey date and time var valDate1 = new Date(); var valDate2 = new Date(document.form.hidBookingDate.value); var valdatediff = (valDate2 - valDate1); if (valdatediff < cancelperiod) { //cancelperiod if (confirm("Cancelling this booking may incur a call out charge.\nDo you want to continue?")){ bcontinue = true; }else{ var bcontinue=false; } }else{ if (document.form.OtherBookings.value==1){ if (confirm("Cancelling this booking will cancel all the journeys on it.\nDo you want to continue?")){ bcontinue = true; }else{ var bcontinue=false; } }else{ if (confirm("You have chosen to cancel this booking.\nDo you want to continue?")){ bcontinue = true; }else{ var bcontinue=false; } } } if (bcontinue == true) { document.form.action="cancelBooking.asp?id="+BkId; document.form.target="_self"; document.form.submit(); } } function doAddAddress(mode){ var rowval=0; var rowtext=""; var iFail = 0; var iValueFound = 0; bAirport = false; if (mode == 'pickup') { var oShowSelectedPickups=getObjByID("ShowSelectedPickups"); var oShowSelectedPickups2=getObjByID("ShowSelectedPickups2"); var oAirport=getObjByID("pkShowAirport"); if (oAirport.style.display == "inline") { bAirport = true; } //Add a new address is being shown if (testLength('PKStreet',1,-1)!==0 && testLength('PKTown',1,-1)!==0 && bAirport==false) { iFail=1; alert("You must enter at least a street name and town before adding another pickup."); } //Add a new airport is being shown if (bAirport==true && (testLength('PKAirport',1,-1)!==0 || testLength('PKFlightDate',1,-1)!==0 || testLength('PKFlightETA',1,-1)!==0 || testLength('PKFlightNo',1,-1)!==0) ) { iFail=1; alert("You must complete the following fields before choosing another pick-up location:\n\nAirport\nFlight Date\nFlight Time\nFlight No.\n"); } if (iFail == 0 ) { if (document.form.pkdefaultid.value > 0) { ipkdefaultid = document.form.pkdefaultid.value document.form.pkdefaultid.value = 0; } else { ipkdefaultid = 0 } var oAddress=getObjByID("pkShowAddress"); var oAirport=getObjByID("pkShowAirport"); oAddress.style.display="inline"; oAirport.style.display="none"; var PKCompany = document.form.PKCompany.value; var PKBuilding = document.form.PKBuilding.value.replace(",",""); var PKStreetNum = document.form.PKStreetNum.value.replace(",",""); var PKStreet = document.form.PKStreet.value.replace(",",""); var PKArea = document.form.PKArea.value.replace(",",""); var PKTown = document.form.PKTown.value.replace(",",""); var PKCompany = document.form.PKCompany.value.replace(",",""); var PKPostcode = document.form.PKPostcode.value.replace(",",""); var PKFlightNo = document.form.PKFlightNo.value.replace(",",""); var PKFlightDate = document.form.PKFlightDate.value.replace(",",""); var PKFlightETA = document.form.PKFlightETA.value.replace(",",""); var PKLuggageItems = document.form.PKLuggageItems.value.replace(",",""); if (bAirport == true) { var PKCompany = document.form.PKAirport.value.replace(",",""); var PKBuilding = document.form.PKTerminal.value.replace(",",""); } if (ipkdefaultid > 0) { rowval=ipkdefaultid; } else { rowval= "|" + PKCompany + "|" + PKBuilding + "|" + PKStreetNum + "|" + PKStreet + "|" + PKArea + "|" + PKTown + "|" + PKPostcode + "|" + DOAddrBook + "|" + PKFlightDate + "|" + PKFlightETA + "|" + PKLuggageItems + "|" + PKFlightNo; } if (PKCompany.length>0) { rowtext = PKCompany + ","; } if (PKBuilding.length>0) { rowtext = rowtext + PKBuilding + ","; } if (rowtext.length>35) { }else{ if (PKStreetNum.length>0) { rowtext = rowtext + PKStreetNum + ","; } if (PKStreet.length>0) { rowtext = rowtext + PKStreet + ","; } } if (rowtext.length>35) { }else{ if (PKArea.length>0) { rowtext = rowtext + PKArea + ","; } } if (rowtext.length>35) { }else{ if (PKTown.length>0) { rowtext = rowtext + PKTown + ","; } } if (rowtext.length>0) { //take off trailing "," var newlen = rowtext.length - 1; rowtext=rowtext.substring(0,newlen); } ClearPKAddress(); ClearDOAddress(); iValueFound = 1; var oRef=getObjByID("pickuptitle1"); oRef.style.display="none"; var oRef=getObjByID("pickuptitle2"); oRef.style.display=""; oShowSelectedPickups.style.display=""; oShowSelectedPickups2.style.display=""; } //ClearPKAirport(); //ClearPKAddress(); var objTarget=document.form.PickUpList; } else { var oShowSelectedDropoffs=getObjByID("ShowSelectedDropoffs"); var oShowSelectedDropoffs2=getObjByID("ShowSelectedDropoffs2"); var oAirport=getObjByID("doShowAirport"); if (oAirport.style.display == "inline") { bAirport = true; } //Add a new address is being shown if (testLength('DOArea',1,-1)!==0 && bAirport==false) { iFail=1; alert("You must enter at least an area name before adding another drop off."); } if (bAirport==true && (testLength('DOAirport',1,-1)!==0 || testLength('DOFlightDate',1,-1)!==0 || testLength('DOFlightETA',1,-1)!==0 || testLength('DOFlightNo',1,-1)!==0) ) { iFail=1; alert("You must complete the following fields before choosing another drop-off location:\n\nAirport Name\nFlight Date\nFlight Time\nFlight No.\n"); } if (iFail == 0 ) { if (document.form.dodefaultid.value > 0) { idodefaultid = document.form.dodefaultid.value document.form.dodefaultid.value = 0; }else{ idodefaultid = 0 } var oAddress=getObjByID("doShowAddress"); var oAirport=getObjByID("doShowAirport"); oAddress.style.display="inline"; oAirport.style.display="none"; var DOBuilding = document.form.DOBuilding.value.replace(",",""); var DOStreetNum = document.form.DOStreetNum.value.replace(",",""); var DOStreet = document.form.DOStreet.value.replace(",",""); var DOArea = document.form.DOArea.value.replace(",",""); var DOTown = document.form.DOTown.value.replace(",",""); var DOCompany = document.form.DOCompany.value.replace(",",""); var DOPostcode = document.form.DOPostcode.value.replace(",",""); var DOFlightDate = document.form.DOFlightDate.value.replace(",",""); var DOFlightETA = document.form.DOFlightETA.value.replace(",",""); var DOLuggageItems = document.form.DOLuggageItems.value.replace(",",""); var DOFlightNo = document.form.DOFlightNo.value.replace(",",""); var DOAddrBook = 0; if (bAirport == true) { var DOCompany = document.form.DOAirport.value.replace(",",""); var DOBuilding = document.form.DOTerminal.value.replace(",",""); } if (idodefaultid > 0) { rowval=idodefaultid; } else { rowval="|" + DOCompany + "|" + DOBuilding + "|" + DOStreetNum + "|" + DOStreet + "|" + DOArea + "|" + DOTown + "|" + DOPostcode + "|" + DOAddrBook + "|" + DOFlightDate + "|" + DOFlightETA + "|" + DOLuggageItems + "|" + DOFlightNo; } if (DOCompany.length>0) { rowtext = DOCompany + ","; } if (DOBuilding.length>0) { rowtext = rowtext + DOBuilding + ","; } if (rowtext.length>35) { }else{ if (DOStreetNum.length>0) { rowtext = rowtext + DOStreetNum + ","; } if (DOStreet.length>0) { rowtext = rowtext + DOStreet + ","; } } if (rowtext.length>35) { }else{ if (DOArea.length>0) { rowtext = rowtext + DOArea + ","; } } if (rowtext.length>35) { }else{ if (DOTown.length>0) { rowtext = rowtext + DOTown + ","; } } if (rowtext.length>37) { }else{ if (DOFlightNo.length>0) { rowtext = rowtext + DOFlightNo + ","; } } if (rowtext.length>0) { //take off trailing "," var newlen = rowtext.length - 1; rowtext=rowtext.substring(0,newlen); } ClearDOAddress(); ClearDOAirport(); iValueFound = 1; oShowSelectedDropoffs.style.display=""; oShowSelectedDropoffs2.style.display=""; } // ClearDOAirport(); // ClearDOAddress(); var objTarget=document.form.DropOffList; } if (iFail==0 ) { df=objTarget.length; if (iValueFound == 1) { //Remove no locations message //has this location already been added? var iExists = 0; for (i=0; i < objTarget.length; i++){ if (objTarget[i].value == rowval){ iExists = 1; } } if (iExists == 0) { if (objTarget[0].value == "null"){ objTarget.length=objTarget.length; df=df-1; }else{ objTarget.length=objTarget.length+1; } objTarget[df].value=rowval; objTarget[df].text=rowtext; objTarget[df].selected=true; objTarget.focus(); } }else{ objSrc[0].selected=true; objSrc.focus(); } if (mode == 'pickup') { document.form.PKCompany.focus(); }else{ document.form.DOCompany.focus(); } } } function padLength(sObjName){ var sText=eval("document.form."+sObjName+".value"); var iLen=sText.length; if (iLen>0){ return sText; }else{ return " "; } } function doClearDefault(objclear) { objclear.value = 0; } // This does some bollocks that does something else. I don't care anymore. function doFlightDropOffTime() { var hrsBefore = 3; // Number of hours before flight time that pickup time is set to var ftime = document.form.DOFlightETA.value; var fdate = document.form.DOFlightDate.value; if (ftime.length > 0) { var arrFdate = ftime.split(":"); var dHour = arrFdate[0]; var dMin = arrFdate[1]; if (fdate.length > 0) { var arrFdate = fdate.split(" "); fDay = arrFdate[0]; fMonth = arrFdate[1]; fYear = arrFdate[2]; var newDate = new Date(fYear, fMonth-1, fDay, dHour, dMin, 0); } else { var newDate = new Date(); } var tmpTime = newDate.getTime(); var tmpTime = tmpTime - (60*60*hrsBefore*1000); var newDate = new Date(tmpTime); fYear = newDate.getYear(); fMonth = newDate.getMonth() + 1; fDay = newDate.getDate(); dHour = newDate.getHours(); dMin = newDate.getMinutes(); if (fYear < 1900) fYear = fYear + 1900; //alert(fDay + "/" + fMonth + "/" + fYear + " " + dHour + ":" + dMin); // faff around with checkbox if (dHour > 12) { dHour = dHour - 12; document.form.radbkAMPM[1].checked = true; } else { document.form.radbkAMPM[0].checked = true; } // set pickup time values on form document.form.bkyear.value = fYear; document.form.bkmonth.value = fMonth; document.form.bkday.value = fDay; document.form.bkhour.value = dHour; document.form.bkminutes.value = dMin; } var alertString = "Please review the journey date and time to make sure you leave enough time before your flight for travelling to the airport and checking in.\nThe pick up time has automatically been changed to " + hrsBefore + " hours before your flight time; please change this if you require a different pick up time."; if (fdate.length < 1) alertString += "\n\nAlso, don't forget to enter your Flight DEP Date!"; alert(alertString); } function doFlightPickUpTime() { alert("Please review the Pick Up Date and Time to make sure that you leave enough time between the Flight Arrival and the Pick Up to allow for Baggage Reclaim, Customs and anything else you will need to do."); } function doFlightPickUp() { var oAddress=getObjByID("pkShowAddress"); var oAirport=getObjByID("pkShowAirport"); oAddress.style.display="none"; oAirport.style.display="inline"; ShowPKAddressButton(); } function doFlightDropOff() { var oAddress=getObjByID("doShowAddress"); var oAirport=getObjByID("doShowAirport"); var oDefineDate = getObjByID("bkdefinedate"); var oDefineTime = getObjByID("bkdefinetime"); document.form.bktimetype[1].checked = true; oAddress.style.display="none"; oAirport.style.display="inline"; oDefineDate.style.display=""; oDefineTime.style.display=""; ShowDOAddressButton(); } function ShowPKAirportButton() { var oButton=getObjByID("pkAddressButton"); oButton.style.display="none"; oButton=getObjByID("pkAirportButton"); oButton.style.display="inline"; var oAddress=getObjByID("pkShowAddress"); var oAirport=getObjByID("pkShowAirport"); oAddress.style.display="inline"; oAirport.style.display="none"; ClearPKAddress(); } function ShowPKAddressButton() { var oButton=getObjByID("pkAddressButton"); oButton.style.display="inline"; oButton=getObjByID("pkAirportButton"); oButton.style.display="none"; ClearPKAirport(); } function ShowDOAirportButton() { var oButton=getObjByID("doAddressButton"); oButton.style.display="none"; oButton=getObjByID("doAirportButton"); oButton.style.display="inline"; var oAddress=getObjByID("doShowAddress"); var oAirport=getObjByID("doShowAirport"); oAddress.style.display="inline"; oAirport.style.display="none"; ClearDOAddress(); } function ShowDOAddressButton() { var oButton=getObjByID("doAddressButton"); oButton.style.display="inline"; oButton=getObjByID("doAirportButton"); oButton.style.display="none"; ClearDOAirport(); } function ClearPKAddress() { document.form.PKBuilding.value = ""; document.form.PKStreetNum.value = ""; document.form.PKStreet.value = ""; document.form.PKArea.value = ""; document.form.PKTown.value = ""; document.form.PKCompany.value = ""; document.form.PKPostcode.value = ""; } function ClearPKAirport() { //alert(document.form.PKFlightNo.value); document.form.PKAirport.value=""; document.form.PKTerminal.value=""; document.form.PKFlightNo.value=""; document.form.PKFlightDate.value=""; document.form.PKFlightETA.value=""; document.form.PKLuggageItems.value=""; //alert(document.form.PKFlightNo.value); } function ClearDOAddress() { document.form.DOBuilding.value = ""; document.form.DOStreetNum.value = ""; document.form.DOStreet.value = ""; document.form.DOArea.value = ""; document.form.DOTown.value = ""; document.form.DOCompany.value = ""; document.form.DOPostcode.value = ""; } function ClearDOAirport() { document.form.DOAirport.value=""; document.form.DOTerminal.value=""; document.form.DOFlightNo.value=""; document.form.DOFlightDate.value=""; document.form.DOFlightETA.value=""; document.form.DOLuggageItems.value=""; } function ValidEmail(str) { var at="@" var dot="." var lat=str.indexOf(at) var lstr=str.length var ldot=str.indexOf(dot) if (str.indexOf(at)==-1){ return false } if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){ return false } if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){ return false } if (str.indexOf(at,(lat+1))!=-1){ return false } if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){ return false } if (str.indexOf(dot,(lat+2))==-1){ return false } if (str.indexOf(" ")!=-1){ return false } return true } function getQuote() { if (checkBooking(1) == true) { document.form.QuoteRequired.value = 1; var quotemode = document.form.QuoteRequired.value; // alert("Quotation Required = " + quotemode + " : mode="+document.form.editmode.value + " : priority = " + document.form.priority.value); var priority = document.form.priority.value; var editmode = document.form.editmode.value; //alert("mode="+document.form.editmode.value); var bookingtype = document.form.bookingtype.value; ID = document.form.BookingId.value; checkBooking(); //alert("ID = " + document.form.BookingId.value); document.form.action="/ModifyBooking.asp?mode="+editmode+"&bookingtype="+bookingtype + ""e=true" + "&prioriy=" + priority; document.form.submit(); } }