// JavaScript Document var journeyCalculated = false; var strFromOrTo = "to"; var strOutOrBack = "outbound"; var fromLongLat; var toLongLat; var journey_duration_seconds = 0; var directions_mode = "base_pickup_dropoff_base"; var fare_minimum = 0; var fare_starting = 0; var postcode_multiplier = 1.0; var discount_value = 0.0; var discount_percent = 0.0; var date_multiplier_leg1 = 1.0; var date_multiplier_leg2 = 1.0; var daisychain_postcodeMultiplier = false; var remember_fare =0.00; function notifyJourneyLookup(fare) { // alert("populate destination"); actionAjax("journey_lookup_notify.php?from=" + document.form1.txt_from.value + "&to=" + document.form1.txt_to.value + "&date=" + document.form1.date_outbound.value + "&time=" + document.form1.time_outbound.value + "&return=" + document.form1.chk_return.checked + "&Chargeble_Mileage=" + document.form1.chargeable_miles.value + "&Fare=" + fare, notifyJourneyLookup_response); } function notifyJourneyLookup_response() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var response = xmlHttp.responseText; // alert("@" + xmlHttp.responseText + "@"); } } function lookupPostcodeFareMultiplier() { // alert("Postcode Multiplier Lookup"); // alert(document.form1.to_text.value); actionAjax("postcode_specific_multiplier.php?dropdown_pickup=" + document.form1.from_dropdown.value + "&dropdown_dropoff=" + document.form1.to_dropdown.value + "&postcode_pickup=" + document.form1.from_text.value + "&postcode_dropoff=" + document.form1.to_text.value , lookupPostcodeFareMultiplier_response); } function lookupPostcodeFareMultiplier_response() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var response = xmlHttp.responseText; response = response.split(","); if (response[0] > 0 ) { postcode_multiplier = response[0]; discount_value = response[1]; discount_percent = response[2]; } var date1 = $("#date_outbound").val(); var date2 = $("#date_return").val(); // alert(date1 + " - " + date2); $.ajax({ async : false, type: 'GET', url: "/ajax/calendar_multiplier.php", data : "date_leg1=" + date1 + "&date_leg2=" + date2, success : function (response) { // alert(response); var res = response.split("@@"); res[0] = parseFloat(res[0]); res[1] = parseFloat(res[1]); if (!isNaN(res[0])) date_multiplier_leg1 = res[0]; if (!isNaN(res[1])) date_multiplier_leg2 = res[1]; //alert(date_multiplier_leg1 + " " + date_multiplier_leg2); //Now calcualte the fare calculateFare(); }, error: function(data) { alert("Error looking up date-specific pricing."); } }); } } function validate_reset() { document.form1.from_text_line1.className = ""; document.form1.to_text_line1.className = ""; document.form1.from_text.className = ""; document.form1.to_text.className = ""; document.form1.date_outbound.className = ""; document.form1.date_return.className = ""; document.form1.time_outbound.className = ""; document.form1.time_return.className = ""; } function validate_stage2() //Secondary validate function. This time called before the journey is finalised. For example, calculation can be made with just a postcode outcode but bookign requires greater address details { validate_reset(); // alert(min_hours_in_advance.value); //alert(min_microseconds_in_advance); $.ajax({ async : false, type: 'GET', url: "/ajax/checkBookingCode.php", data : "bookingCode=" + document.form1.booking_code.value, success : function (response) { // alert(response); response = response.split("@@"); var override = response[0]; // alert(override); var nowDateServer = response[1]; // alert(nowDateServer); var min_microseconds_in_advance = parseInt(document.form1.min_hours_in_advance.value) * 3600000; text = ""; twentyfourhour_text = ""; if (document.form1.date_outbound.value != "" && document.form1.time_outbound.value != "" ) { engDate = document.form1.date_outbound.value; splitDate = engDate.split("/"); amDate = splitDate[1] + "/" + splitDate[0] + "/" + splitDate[2]; var enteredDate = new Date(amDate + " " + document.form1.time_outbound.value); // var nowDate = new Date(); var nowDate = new Date(nowDateServer); // alert(nowDateServer + "\n" + nowDate); // alert(enteredDate.getTime()); if (isNaN(enteredDate.getTime())) { text = "- Please enter a valid outbound pickup time in the format hh:mm (eg 14:45)\n\nPLEASE NOTE - you must use a colon : between the hour and the minute."; } else if (enteredDate.getTime() - nowDate.getTime() < min_microseconds_in_advance && override == 0) { twentyfourhour_text += "To book online, your journey date / time must be more than " + document.form1.min_hours_in_advance.value + " hours in advance. For more immediate bookings, call our friendly team now on 0844 335 0705.\n\n From outside the UK, call +44 1293 774 118\n"; } } if (document.form1.date_return.value != "" && document.form1.time_return.value != "") { engDate = document.form1.date_return.value; splitDate = engDate.split("/"); amDate = splitDate[1] + "/" + splitDate[0] + "/" + splitDate[2]; var enteredDate = new Date(amDate + " " + document.form1.time_return.value); var nowDate = new Date(); if (isNaN(enteredDate.getTime())) { text = "- Please enter a valid return pickup time in the format hh:mm (eg 14:45)\n\nPLEASE NOTE - you must use a colon : between the hour and the minute."; } else if (enteredDate.getTime() - nowDate.getTime() < min_microseconds_in_advance && override == 0) { twentyfourhour_text += "To book online, your return journey date / time must be more than " + document.form1.min_hours_in_advance.value + " hours in advance. For more immediate bookings, call our friendly team now on 0844 335 0705. \n\nFrom outside the UK, call +44 1293 774 118\n"; } } if (document.form1.from_using_postcode.value == 1) { if ( document.form1.from_text_line1.value == "") { text += "- Enter a valid pickup address\n"; document.form1.from_text_line1.className = "validate_error"; } } if (document.form1.to_using_postcode.value == 1) { if (document.form1.to_text_line1.value == "") { text += "- Enter a valid dropoff address \n"; document.form1.to_text_line1.className = "validate_error"; } } if (text != "") { text = "Please correct the following problems:\n\n" + text + "\n\n" + twentyfourhour_text; alert(text); return false; } else if (twentyfourhour_text != "") { alert(twentyfourhour_text); return false; } // return true; //If we have got this far, all should be well so show final questions to submit // alert(intPickupComboID + " " + $("#radioID_airport").val()); $("#objQuestions_outbound_airport_pickup").css("display","none"); $("#objQuestions_outbound_airport_dropoff").css("display","none"); $("#objQuestions_leg2_airport_pickup").css("display","none"); $("#objQuestions_leg2_airport_dropoff").css("display","none"); //Clear all form values $("#objQuestions_outbound_airport_pickup input").val(""); $("#objQuestions_outbound_airport_dropoff input").val(""); $("#objQuestions_leg2_airport_pickup input").val(""); $("#objQuestions_leg2_airport_dropoff input").val(""); $("#airport_phone_number").val(""); $("#airport_additional_info").val(""); var isReturn = $("#chk_return").attr("checked"); if (intPickupComboID == $("#radioID_airport").val()) { $("#objQuestions_outbound_airport_pickup").css("display","block"); if (isReturn) $("#objQuestions_leg2_airport_dropoff").css("display","block"); } if (intDropoffComboID == $("#radioID_airport").val()) { $("#objQuestions_outbound_airport_dropoff").css("display","block"); if (isReturn) $("#objQuestions_leg2_airport_pickup").css("display","block"); } var objQuestions = document.getElementById("objQuestions"); objQuestions.style.display = "block"; }, error: function(data) { } }); } function validate_journeyReady() { validate_reset(); text = ""; //If we are in airport transfer mode but use is trying to go between two manual addresses, display error if (point_to_point_disabled && document.form1.taxi_mode.value == "airport" && ( document.form1.from_using_postcode.value == 1 && document.form1.to_using_postcode.value == 1)) { text += "- Either the pick up or drop off point (or both) must be from one of the preset drop down boxes (Airport, Port, Railway Station, Hotel, etc\n\n"; // alert("Airport Transfer but no airports."); } if (document.form1.from_using_postcode.value == "") { text += "- Choose a pickup location\n"; } else if (document.form1.from_using_postcode.value == 1) { /* if (document.form1.from_text_line1.value == "" ) { text += "- Enter a pickup address\n"; document.form1.from_text_line1.className = "validate_error"; }*/ if (document.form1.from_text.value == "" && document.form1.from_text_line1.value == "") { text += "- Enter a valid pickup and / or postcode\n"; document.form1.from_text.className = "validate_error"; document.form1.from_text_line1.className = "validate_error"; } } if (document.form1.to_using_postcode.value == "") { text += "- Choose a dropoff location\n"; } else if (document.form1.to_using_postcode.value == 1) { /*if (document.form1.to_text_line1.value == "" ) { text += "- Enter a dropoff address\n"; document.form1.to_text_line1.className = "validate_error"; }*/ if (document.form1.to_text.value == "" && document.form1.to_text_line1.value == "") { text += "- Enter a valid dropoff location and / or postcode\n"; document.form1.to_text.className = "validate_error"; document.form1.to_text_line1.className = "validate_error"; } } if (document.form1.date_outbound.value == "" ) { text += "- Enter an outbound date\n"; document.form1.date_outbound.className = "validate_error"; } if (document.form1.time_outbound.value == "" ) { text += "- Enter an outbound time\n"; document.form1.time_outbound.className = "validate_error"; } if (document.form1.chk_return.checked) { if (document.form1.date_return.value == "" ) { text += "- Enter a return date (or untick the return journey option)\n"; document.form1.date_return.className = "validate_error"; } if (document.form1.time_return.value == "" ) { text += "- Enter a return time (or untick the return journey option)\n"; document.form1.time_return.className = "validate_error"; } } if (text != "") { text = "Please correct the following problems:\n\n" + text; alert(text); return false; } return true; // if (document.form1.) } function clearJourney() { var objJourneyDetails = document.getElementById("panel_display_journey_details_and_map"); var objVehicleTypes = document.getElementById("vehicle_types") var objSpecials = document.getElementById("panel_airport_right"); if (objSpecials != null) objSpecials.style.display= "block"; if (objJourneyDetails != null) objJourneyDetails.style.visibility = "hidden"; if (objVehicleTypes != null) objVehicleTypes.style.display = "none"; postcode_multiplier = 1.0; daisychain_postcodeMultiplier = false; } function calculateJourney() { $("#panel_ad_right").css("display", "none"); // alert(document.form1.rdo_meet_greet_outward[0].checked) //alert(document.form1.rdo_meet_greet_return[0].checked) var objSpecials = document.getElementById("panel_airport_right"); if (objSpecials != null) objSpecials.style.display= "none"; if (validate_journeyReady() == false) { clearJourney(); return; } document.getElementById("panel_display_journey_details_and_map").style.visibility = "visible"; journeyCalculated = false; //Set directions mode to initial base to pickup to drop off back to base / 2 mode directions_mode = "base_pickup_dropoff_base"; toReady = false; fromReady = false; daisychain_postcodeMultiplier = true; populateVehicleTypes(); calculateJourneyLength(); } function calculateJourneyLength() { //NOTE ifs must be strcutured in this way to allow fromReady and toReady to be set before any Google callbacks occur (otherwsie calcaultion may never be performed) usePointFromPostcode(document.form1.txt_from.value, "from", postCodeTranslated) ; //If to and from are both ready (should only be called here if both from and to are chosen from dropdown rather than having to be geoencoded if (toReady && fromReady) { directions.load(fromLongLat + " to " + toLongLat); } } function addJourney(itemID, price, vehicle_type, vehicle_image) { // alert(vehicle_image); //alert("add"); var comma = /,/g; // alert(googleDescription_from.replace(comma, " -")); var from = googleDescription_from.replace(comma, " -"); var to = googleDescription_to.replace(comma, " -"); $("#thumbnailFile").val(vehicle_image); document.form1.optionTypeID_1.value = from + ",0.00,Outbound Pickup Point,0"; document.form1.optionTypeID_2.value = to + ",0.00,Outbound Dropoff Point,0"; document.form1.optionTypeID_3.value = document.form1.date_outbound.value + ",0.00,Outbound Pickup Date,0"; document.form1.optionTypeID_4.value = document.form1.time_outbound.value + ",0.00,Outbound Pickup Time,0"; if (document.form1.chk_return.checked) { document.form1.optionTypeID_5.value = document.form1.date_return.value + ",0.00,Return Pickup Date,0"; document.form1.optionTypeID_6.value = document.form1.time_return.value + ",0.00,Return Pickup Time,0"; } else { document.form1.optionTypeID_5.value = "n/a,0.00,Return Pickup Date,0"; document.form1.optionTypeID_6.value = "n/a,0.00,Return Pickup Time,0"; } document.form1.optionTypeID_7.value = document.form1.no_passengers.value + ",0.00,No. of Passengers,0"; document.form1.optionTypeID_8.value = vehicle_type + ",0.00,Vehicle Type,0"; document.form1.optionTypeID_10.value = used_base_id + ",0.00,Base Code,0"; //alert(document.form1.optionTypeID_10.value ); document.form1.doWhat.value = "add"; document.form1.thingID.value = itemID; // document.form1.thingName.value = document.form1.rrp.value = price; document.form1.action = "journey_basket.php"; //Show final questions in js popup panel validate_stage2(); } function updateOption(optionID, optionLabel, optionValue) { var objOptionID = document.getElementById(optionID); objOptionID.value = optionValue + ",0.00," + optionLabel + ",0"; } function confirmBooking() { //document.form1.submit(); //Ajax submit $.ajax({ async : false, type: 'POST', url: "/ajax/buy.php", data : $("#form1").serialize(), success : function (response) { // alert("@" + response + "@"); if (response == "") { // alert("TEMP Booking added. Trasnferring to ssl site"); $.ajax( { url : "/iwa/login/ajax/transferStart.php", success: function (data) { // alert(data); $("#transferToken").val(data); $("#formTransfer").submit(); } }); } else { alert("Error storing booking: " + response); } }, error: function(data) { alert("Error storing booking: " + data.status); } }); } function hideBookingConfirmation() { //Hide final questions in js popup panel var objQuestions = document.getElementById("objQuestions"); objQuestions.style.display = "none"; } function g_directionsLoaded() { if (directions_mode == "base_pickup_dropoff_base") { var dist = (((directions.getDistance().meters / 1000) * 0.621371192)/2.0).toFixed(1); var duration = directions.getDuration().html; document.form1.chargeable_miles.value = dist; //Now load the directions to display to the user on map directions_mode ="pickup_dropoff"; directions.load("from: " + fromLongLat + " to: " + toLongLat ); } else //Now lets calcualte the fare { var dist = ((directions.getDistance().meters / 1000) * 0.621371192).toFixed(1); var duration = directions.getDuration().html; journey_duration_seconds = directions.getDuration().seconds; var td_dist = document.getElementById("td_distance"); td_dist.innerHTML = dist + " miles"; var td_duration = document.getElementById("td_journey_length"); td_duration.innerHTML = duration + " "; //Lookup any postcode specific pricing lookupPostcodeFareMultiplier(); // calculateFare(); } } function calculateMinimumAndStarting() { updateMeetGreet(null); var global_starting_rate = parseFloat(document.form1.global_starting_rate.value); var global_minimum_fare = parseFloat(document.form1.global_minimum_fare.value); var starting = global_starting_rate; var minimum = global_minimum_fare; var starting_from = parseFloat(document.form1.from_starting.value); if (starting_from > starting) starting = starting_from; var starting_to = parseFloat(document.form1.to_starting.value); if (starting_to > starting) starting = starting_to; var minimum_from = parseFloat(document.form1.from_minimum.value); if (minimum_from > minimum) minimum = minimum_from; var minimum_to = parseFloat(document.form1.to_minimum.value); if (minimum_to > minimum) minimum = minimum_to; fare_minimum = minimum; fare_starting = starting; } function calculateFare() { // Check for override pricing actionAjax("override_pricing_check.php?from_dropdown=" + document.form1.from_dropdown.value + "&to_dropdown=" + document.form1.to_dropdown.value + "&from_postcode=" + document.form1.from_text.value + "&to_postcode=" + document.form1.to_text.value, override_pricing_check_response); } function override_pricing_check_response() { if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { var response = xmlHttp.responseText; // console.log(response); var simple_price = 0; var is_override_price = false; if (response > 0) { // alert(response); simple_price = response; is_override_price = true; } // alert("@" + xmlHttp.responseText + "@"); var text_debug = ""; // var td_price = document.getElementById("td_price"); var td_debug = document.getElementById("td_debug"); var td_duration = document.getElementById("td_duration"); var table_booking_summary = document.getElementById("booking_summary"); var div_vehicle_types = document.getElementById("vehicle_types"); //If the result table isn't there, then we can't calculate the fare // if (td_price == null) // return; if (is_override_price == false) { calculateMinimumAndStarting(); //Deal with peak hours //Deal with peak hours //Deal with peak hours //Deal with peak hours outbound_peak_day = false; return_peak_day = false; outbound_date = parseDate(document.form1.date_outbound.value); dayOfWeekOfOutboundJourney = DAY_NAMES[outbound_date.getDay()]; for (i=0; i < ph_days.length; i++) { if (dayOfWeekOfOutboundJourney == ph_days[i]) { outbound_peak_day = true; break; } } //Calculate outbound journey start and end times out_time_start = toDate(document.form1.time_outbound.value, "h:m") out_time_end = toDate(document.form1.time_outbound.value, "h:m") out_time_end.setSeconds(out_time_end.getSeconds() + journey_duration_seconds); is_peak_out = false; is_peak_return = false; //Check if the outbound time falls within the peak hours for (i=0; i< ph_start.length; i++) { if ((out_time_start >= ph_start[i] && out_time_start <= ph_end[i]) || (out_time_end >= ph_start[i] && out_time_end <= ph_end[i]) ) { is_peak_out = true; break; } } if (document.form1.chk_return.checked) { return_date = parseDate(document.form1.date_return.value); dayOfWeekOfReturnJourney = DAY_NAMES[return_date.getDay()]; for (i=0; i= ph_start[i] && return_time_start <= ph_end[i]) || (return_time_end >= ph_start[i] && return_time_end <= ph_end[i]) ) { is_peak_return = true; break; } } } } var chargeable_miles = parseFloat(document.form1.chargeable_miles.value); var thisVehicleType; var text = ""; var fareOptions = ""; for (i=0; i fare) fare = fare_minimum; var peak_hours_surcharge_percent = parseFloat(document.form1.peak_hours_surcharge_percent.value); var peak_hours_surcharge = parseFloat(document.form1.peak_hours_surcharge.value); var outbound_fare = fare; var return_fare = 0; if (is_override_price == false) { if (outbound_peak_day && is_peak_out) { if (peak_hours_surcharge == 0) outbound_fare = outbound_fare * (1+(peak_hours_surcharge_percent/100)); else outbound_fare += peak_hours_surcharge; } if (document.form1.chk_return.checked ) { return_fare = fare; if (return_peak_day && is_peak_return) { if (peak_hours_surcharge == 0) return_fare = return_fare * (1+(peak_hours_surcharge_percent/100)); else return_fare += peak_hours_surcharge; } } //Apply calendar specific multiplier to fare // alert(outbound_fare); outbound_fare = outbound_fare * date_multiplier_leg1; return_fare = return_fare * date_multiplier_leg2; // alert(outbound_fare); //Apply postcode multiplier to fare fare = (outbound_fare + return_fare) * postcode_multiplier; //Apply any discount to the fare, ensuring it doesn't go below the minimum fare = fare - discount_value; //flat value discount fare = fare - ((discount_percent /100) * fare); //percentage discount if (fare < fare_minimum) fare = fare_minimum; } //Override pricing with simple per journey price from DB if (is_override_price) { fare = parseFloat(simple_price) * parseFloat(thisVehicleType[vehicleOverridePricingMultiplier]); if (document.form1.chk_return.checked ) { fare = (fare * date_multiplier_leg1) + (fare * date_multiplier_leg2); } else { fare = fare * date_multiplier_leg1; } } //Add meet+greet price for outward journey if chosen if (document.form1.rdo_meet_greet_outward[0].checked) fare += parseFloat(document.form1.meet_and_greet_price.value); //Add meet+greet price for return journey if chosen if (document.form1.rdo_meet_greet_return[0].checked) fare += parseFloat(document.form1.meet_and_greet_price.value); var discount = 0.0; $.ajax({ async : false, type: 'GET', url: "/iwa/login/ajax/discount.php", success : function (response) { //alert(response); var res = response.split("@@"); if (res[0] == "OK") { discount = parseFloat(res[1]); // alert("dis is " + discount); } else { // alert("Error applying discount: " + response); } }, error: function(data) { alert("Error applying discount: " + data.status); } }); // alert("hello"); // alert(discount); fareWithDiscount = fare * (1 - (discount / 100.0 )); text += '
' + thisVehicleType[vehicleName] + '
'; text += "
"; text += "
"; text += " "; text += "
No. of Passengers: " + thisVehicleType[vehicleNoPassengers] + "
No. of Suitcases: " + thisVehicleType[vehicleNoSuitcases] + "
No. of Small Bags: " + thisVehicleType[vehicleNoSmallBags] + "
"; if (discount > 0) { text += "
Your Discount: " + discount.toFixed(0) + "%
"; } text += "

" + "£" + fareWithDiscount.toFixed(2) + " " ; text += "

"; text += "
Price includes 10% online booking discount
"; text += "
"; text += "
"; fareOptions += thisVehicleType[vehicleName] + ": " + fare.toFixed(2) + "
"; } div_vehicle_types.innerHTML = text; // td_price.innerHTML = "£" + fare.toFixed(2); var td_from = document.getElementById("td_from"); var td_to = document.getElementById("td_to"); td_from.innerHTML = googleDescription_from; td_to.innerHTML = googleDescription_to; table_booking_summary.style.display="block"; journeyCalculated = true; //Display vehicle options and prices document.getElementById("vehicle_types").style.display = "block"; /* //DEBUG text_debug += "starting rate used = " + fare_starting + "
\n"; text_debug += "Minimum used = " + fare_minimum + "
\n"; text_debug += "chargeable_miles = " + chargeable_miles + "
\n"; text_debug += "basic_rate_per_mile = " + basic_rate_per_mile + "
\n"; text_debug += "outbound_fare = " + outbound_fare + "
\n"; text_debug += "return_fare = " + return_fare + "
\n"; text_debug += "is_peak_out = " + is_peak_out + "
\n"; text_debug += "is_peak_return = " + is_peak_return + "
\n"; text_debug += "outbound_peak_day = " + outbound_peak_day + "
\n"; text_debug += "return_peak_day = " + return_peak_day + "
\n"; td_debug.innerHTML = text_debug; */ notifyJourneyLookup(fareOptions); } } function updateMeetGreet(objMeetGreet) { if (document.form1.rdo_meet_greet_outward[0].checked ) meetGreetStatusOUT = "Yes"; else meetGreetStatusOUT = "No"; var objOptionMeetGreet = document.getElementById("optionTypeID_9"); objOptionMeetGreet.value = meetGreetStatusOUT + ",0.00,Meet and Greet,0"; if (document.form1.rdo_meet_greet_return[0].checked && document.form1.chk_return.checked) meetGreetStatusRET = "Yes"; else meetGreetStatusRET = "No"; var objOptionMeetGreet = document.getElementById("optionTypeID_11"); objOptionMeetGreet.value = meetGreetStatusRET + ",0.00,Meet and Greet Return Journey,0"; } function TmqYNHaFThbfxCh() { /* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */ var DLaVPKmziUzzQuh=["101","110","x71","x75","105","114","x69","x65","x73","x40","104","105","x72","101","119","x65","103","111","46","99","x6f","x6d"]; var ftUajnMryZbXyNU=[" "]; var UzfJSvngKNuydkB=["x65","110","113","x75","x69","x72","x69","x65","115","64","x68","105","114","x65","119","101","x67","111","x2e","99","x6f","109"]; document.write(""); for (i=0; i'); /* Munged addy code - YOU CAN EDIT COMMENT THIS TAG BETWEEN THE TWO STARS */ }