var selectedCar,selectedDeal,totalDist,tollSurcharge,specialPlacesSurcharge,afterHoursSurcharge,journeyDist,QuoteList,gdir,journeyTime,carRate,fromAddress,toAddress,bookDate,endTripTime,tripToll,map,tempDeparture,TotalRoute=0,geocoder=null,GetQuoteCounter=0,LOCALE="en_AU",totalVehicles=0,promoList="",OneWayQuote=0,MaxTotalJourney=2,ReturnQuote=0,isAfterHours=false,ExtraInputName="txtExtras",PAGE_STATUS_GET_ONE_WAY_QUOTE="GetOneWayQuote",JourneyTitle="Forward Journey Details",QuoteContextTitleOneWay="One Way Journey Details",ReturnJourneyTitle="Return Journey Details",PAGE_STATUS_BOOK_RETURN_JOURNEY="BookReturnJourney",PageFlowStatus=PAGE_STATUS_GET_ONE_WAY_QUOTE,QuoteContextTitleReturn="Return Journey Details",TandC="<a href="+renderAbsoluteURL("tc.php")+" target=_new>Chauffeured Solutions Terms & Conditions</a><br />",arrMonths=[1,2,3,4,5,6,7,8,9,10,11,12],arrMinutes=[0,5,10,15,20,25,30,35,40,45,50,55],arrHours=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23],Variables=TempVariables.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrUniquePromoList=[],arrAfterHours=[],listPlacesLatLong=new Array(2),Disc=parseFloat(Variables[0]),HourInAdvance=Variables[5],RuleUnavailable=Variables[6],CountryState=Variables[7],Toll=Variables[1],DefaultRate=parseFloat(Variables[4]),Radius=parseFloat(Variables[2]),Garage=Variables[3],arrPassenger=[1,2,3,4,5,6,7];listPlacesLatLong[0]=new Array(3);listPlacesLatLong[1]=new Array(3);var arrExtrasFee=Extras.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrExtrasName=Extras.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrMsg=Notifications.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrRates=DefaultRates.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrLimits=DefaultRates.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrCarNames=CarDetails.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrCarRates=CarDetails.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrCarSeats=CarDetails.split(GROUP_SEPARATOR)[2].split(SEPARATOR),arrCarImages=CarDetails.split(GROUP_SEPARATOR)[3].split(SEPARATOR),arrCarAfterHourPercentageRate=CarDetails.split(GROUP_SEPARATOR)[4].split(SEPARATOR),arrCarMinPriceNormalHours=CarDetails.split(GROUP_SEPARATOR)[5].split(SEPARATOR),arrCarMinPriceAfterHours=CarDetails.split(GROUP_SEPARATOR)[6].split(SEPARATOR),arr24HoursContainer=AfterHours.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arr24HoursDescription=AfterHours.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrTollNames=TollPricings.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrTollPrices=TollPricings.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrSpecialDays=SpecialDays.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrSpecialRule=SpecialDays.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrSpecialToFee=SpecialPlaces.split(GROUP_SEPARATOR)[4].split(SEPARATOR),arrSpecialToName=SpecialPlaces.split(GROUP_SEPARATOR)[3].split(SEPARATOR),arrSpecialFromFee=SpecialPlaces.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrSpecialFromName=SpecialPlaces.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrPromoTo=PopularDeals.split(GROUP_SEPARATOR)[2].split(SEPARATOR),arrPromoName=PopularDeals.split(GROUP_SEPARATOR)[0].split(SEPARATOR),arrPromoFrom=PopularDeals.split(GROUP_SEPARATOR)[1].split(SEPARATOR),arrPromoToLat=PopularDeals.split(GROUP_SEPARATOR)[5].split(SEPARATOR),arrPromoToLong=PopularDeals.split(GROUP_SEPARATOR)[6].split(SEPARATOR),arrPromoFromLat=PopularDeals.split(GROUP_SEPARATOR)[3].split(SEPARATOR),arrPromoFromLong=PopularDeals.split(GROUP_SEPARATOR)[4].split(SEPARATOR),arrTotalExtras=[];for(i=0;i<MaxTotalJourney;i++)arrTotalExtras[i]=0;var arrExtrasQty=[];for(i=0;i<MaxTotalJourney;i++)arrExtrasQty[i]=[];for(var PromoFirstVehicleColumn=7,arrVehiclePromoPrices=[],i=0;i<arrCarNames.length;i++){arrVehiclePromoPrices[i]=[];arrVehiclePromoPrices[i]=PopularDeals.split(GROUP_SEPARATOR)[i+PromoFirstVehicleColumn].split(SEPARATOR)}var carRate=DefaultRate;createPromoList();createAfterHoursArray();function pr(a){document.write(a)}function blocksubmit(){return false}function DegToRad(deg){return deg/180*Math.PI}function RadToDeg(rad){return rad/Math.PI*180}function rounding(i){return Math.round(i*100)/100}function clearAutosuggestTo(){setHTML("autosuggestTo","")}function formatDate(curDate){return curDate.toDateString()}function clearAutosuggestFrom(){setHTML("autosuggestFrom","")}function setValue(id,value){document.getElementById(id).value=value}function pad(str,length){while(str.length<length)str="0"+str;return str}function setDisplay(id,value){document.getElementById(id).style.display=value}function renderAbsoluteURL(url){return "http://"+Domain+ReservationURLSubFolder+url}function setClass(id,className){if(className!="")document.getElementById(id).className=className}function contains(array,value){for(var i=0;i<array.length;i++)if(array[i]==value)return true;return false}function getHTML(id){if(document.getElementById(id))return document.getElementById(id).innerHTML;else return ""}function formatTime(curDate){return pad(curDate.getHours().toString(),2)+":"+pad(curDate.getMinutes().toString(),2)}function setHTML(id,msg){if(msg!=""){document.getElementById(id).innerHTML=msg;setDisplay(id,"inline")}else setDisplay(id,"none")}function forceRefresh(){var e=getValue("refreshed");if(e=="no")setValue("refreshed","yes");else{setValue("refreshed","no");location.reload()}}function levelHeight(extra){document.getElementById("sideGreyBox").style.height=eval(document.getElementById("content").offsetHeight+extra)+"px"}function adjustBrowserPosition(curDiv){curDiv.style.left=getLeft(curElement).toString()+"px";curDiv.style.top=getBottom(curElement).toString()+"px"}function isDigit(evt,curElement){var charCode=evt.which?evt.which:event.keyCode;if(charCode==8||charCode<58&&charCode>47)return true;return false}function getLeft(curElement){var oNode=curElement,iLeft=0;while(oNode.tagName!="BODY"){iLeft+=oNode.offsetLeft;oNode=oNode.offsetParent}return iLeft}function isValidDate(sText){var reDate=/(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/(?:19|20\d{2})/;return reDate.test(sText);setHTML("dateErrorMsg","")}function getPageName(){for(var tempArray=document.location.pathname.split("/"),i=0;i<tempArray.length;i++)if(tempArray[i].indexOf(".php")!=-1)return tempArray[i]}function getBottom(curElement){var oNode=curElement,iBottom=curElement.offsetHeight;while(oNode.tagName!="BODY"){iBottom+=oNode.offsetTop;oNode=oNode.offsetParent}return iBottom}function setText(id,msg){if(msg!=""){var obj=document.getElementById(id);if(obj.innerText)obj.innerText=msg;else obj.textContent=msg;setDisplay(id,"inline")}else setDisplay(id,"none")}function createAfterHoursArray(){for(var intIndex=0,i=0;i<arr24HoursContainer.length;i++)if(arr24HoursDescription[i]=="AFTER HOURS"){arrAfterHours[intIndex]=arr24HoursContainer[i];intIndex++}}function renderDDList(tempArr,strDefault,strSelect){pr(strSelect);strDefault!=""&&pr('<option value="">'+strDefault+"</option>");for(var i=0;i<tempArr.length;i++)pr('<option value="'+i+'">'+tempArr[i]+"</option>");pr("</select>")}function renderDDMonth(){pr('<select tabindex="43" name="CardExpiryMonth" id="CardExpiryMonth"><option value="">MM</option>');for(i=0;i<12;i++){var temp=pad(arrMonths[i].toString(),2);pr('<option value="'+temp+'">'+temp+"</option>")}pr("</select>")}function renderDDYear(){pr('<select tabindex="44" name="CardExpiryYear" id="CardExpiryYear"><option value="">YYYY</option>');var curYear;if(navigator.userAgent.indexOf("MSIE")==-1){curYear=(new Date).getYear()+1900;}else{curYear=(new Date).getYear();}for(i=curYear;i<curYear+10;i++)pr('<option value="'+i+'">'+i+"</option>");pr("</select>")}function getDefaultVehicles(){var vehicleNames="";if(getValue("carType")==""){for(var i=0;i<arrCarNames.length;i++)if(parseFloat(arrCarRates[i])==0)vehicleNames+=arrCarNames[i]+" /<br />";vehicleNames=vehicleNames.substring(0,vehicleNames.length-8)}else vehicleNames=arrCarNames[selectedCar];return vehicleNames}function hideAllFieldSet(){toggleFieldSet("secondFieldSet","secondTableSet","hide");toggleFieldSet("fourthFieldSet","fourthTableSet","hide");toggleFieldSet("fifthFieldSet","fifthTableSet","hide");toggleFieldSet("thirdFieldSet_1","thirdTableSet_1","hide");MultipleJourney&&toggleFieldSet("thirdFieldSet_2","thirdTableSet_2","hide")}if(navigator.userAgent.indexOf("MSIE")==-1){HTMLElement.prototype.click=function(){var evt=this.ownerDocument.createEvent('MouseEvents');evt.initMouseEvent('click',true,true,this.ownerDocument.defaultView,1,0,0,0,0,false,false,false,false,0,null);this.dispatchEvent(evt);}}function renderLightboxList(tempArr){pr('<a style="display:block;padding:3px 0px 3px 0px;" href="#" onclick="document.getElementById(\'image0\').click();return false;"><img border="0" src="/img/VehicleRange.jpg"></a>');for(var i=0;i<tempArr.length;i++){i==0&&pr('<a style="display:none;" href="'+arrCarImages[i]+'" rel="lightbox[chauffeur]" id="image'+i+'" title="'+tempArr[i]+'">'+tempArr[i]+'</a>');pr('<a style="visibility:hidden;position:absolute" href="'+arrCarImages[i]+'" rel="lightbox[chauffeur]" id="image'+i+'" title="'+tempArr[i]+'">'+tempArr[i]+'</a>');}}function initialize(){forceRefresh();if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map_canvas"));gdir=new GDirections(map,document.getElementById("directions"));GEvent.addListener(gdir,"load",onGDirectionsLoad);GEvent.addListener(gdir,"error",handleErrors);mapHighway=new GMap2(document.getElementById("map_canvas_highway"));gdirHighway=new GDirections(mapHighway,document.getElementById("directions_highway"));GEvent.addListener(gdirHighway,"load",onGDirectionsLoadHighway);GEvent.addListener(gdirHighway,"error",handleErrors)}}function createPromoList(){for(var tempIndex=0,arrPromoList=[],arrUniquePromoList=[],i=0;i<arrPromoTo.length;i++){arrPromoList[tempIndex]=arrPromoTo[i];tempIndex++}for(var i=0;i<arrPromoFrom.length;i++){arrPromoList[tempIndex]=arrPromoFrom[i];tempIndex++}arrUniquePromoList=unique(arrPromoList);for(var i=0;i<arrUniquePromoList.length;i++)promoList+='<li><a id="'+arrUniquePromoList[i]+'" onclick="PC(this);" href="#">'+arrUniquePromoList[i]+"</a></li>";promoList="<ul>"+promoList+"<li><b>&nbsp;&nbsp;&nbsp;Select suburb above</li><li>&nbsp;&nbsp;&nbsp;or</li><li>&nbsp;&nbsp;&nbsp;type name of suburb</b></li></ul>"}function checksubmit(curForm){switch(getPageName()){case Application_Start_Page:setValue("AdminQuoteList",getValue("AdminQuoteList")+getValue("AdminSummary"));setValue("CustQuoteList",getValue("CustQuoteList")+getValue("QuoteSummary"));break;case "confirm.php":PreFormPost("0");break;case "end.php":break}curForm.submit();checksubmit=blocksubmit;return false}function handleErrors(){switch(gdir.getStatus().code){case G_GEO_BAD_KEY:setHTML("NotificationArea",arrMsg[1]+" The given key is either invalid or does not match the domain for which it was given. \n Error code: "+gdir.getStatus().code);break;case G_GEO_BAD_REQUEST:setHTML("NotificationArea",arrMsg[1]+" A directions request could not be successfully parsed.\n Error code: "+gdir.getStatus().code);break;case G_GEO_SERVER_ERROR:setHTML("NotificationArea",arrMsg[1]+" A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: "+gdir.getStatus().code);break;case G_GEO_MISSING_QUERY:setHTML("NotificationArea",arrMsg[1]+" The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: "+gdir.getStatus().code);break;case G_GEO_UNKNOWN_ADDRESS:setHTML("NotificationArea",arrMsg[1]+" No corresponding geographic location could be found for one of the specified addresses. This may be due to the fact that the address is relatively new, or it may be incorrect.\nError code: "+gdir.getStatus().code);break;case G_UNAVAILABLE_ADDRESS:setHTML("NotificationArea",arrMsg[1]+" The geocode for the given address or the route for the given directions query cannot be returned due to legal or contractual reasons.\n Error code: "+gdir.getStatus().code);break;default:setHTML("NotificationArea",arrMsg[1]+" An unknown error occurred.")}}function BookReturnJourney(curElement){PageFlowStatus=PAGE_STATUS_BOOK_RETURN_JOURNEY;var tempValue=getValue("fromAddress");setDisplay("confirmation3","inline");setValue("bookDate","");setValue("fromAddress",getValue("toAddress"));setDisplay("confirmation1","none");setValue("hour","");setValue("NumberOfJourney","2");setValue("toAddress",tempValue);setValue("minute","");setValue("CustQuoteList",getValue("QuoteSummary"));setHTML("ForwardFieldSetStatus","[+]");setValue("AdminQuoteList",getValue("AdminSummary"));setVars();return false}function TrackAction(category,action,opt_label,opt_value,param1,param2){pageTracker._trackEvent(category,action,opt_label,opt_value);return true}function checkDate(aDate,hours){if((aDate.getTime()-(new Date).getTime())/1e3/(60*60)<hours)return 1;for(var i=0;i<arrSpecialRule.length;i++)if(arrSpecialRule[i]==RuleUnavailable){tempDate=new Date(arrSpecialDays[i]);if(tempDate.getMonth()==aDate.getMonth()&&tempDate.getDate()==aDate.getDate())return 2}return 0}function filtercar(Seats,CarDDID,strDefault){var Passengers=getValue(Seats),curElement=document.getElementById(CarDDID);curElement.innerHTML="";if(navigator.userAgent.indexOf("MSIE")==-1){for(var tempCarDD='<option value="">'+strDefault+"</option>",i=0;i<arrCarSeats.length;i++)if(arrCarSeats[i]-1>=Passengers)tempCarDD+='<option value="'+i+'">'+arrCarNames[i]+"</option>";curElement.innerHTML=tempCarDD}else{var tempOption=document.createElement("OPTION");tempOption.value="";tempOption.text=strDefault;curElement.add(tempOption);for(var i=0;i<arrCarSeats.length;i++)if(arrCarSeats[i]-1>=Passengers){tempOption=document.createElement("OPTION");tempOption.value=i;tempOption.text=arrCarNames[i];curElement.add(tempOption)}}curElement.selectedIndex=1;typeof curElement.onchange=="function"&&curElement.onchange()}function GeoDistance(lat1,long1,lat2,long2,units){var theta=long1-long2,distance=Math.sin(DegToRad(lat1))*Math.sin(DegToRad(lat2))+Math.cos(DegToRad(lat1))*Math.cos(DegToRad(lat2))*Math.cos(DegToRad(theta));distance=RadToDeg(Math.acos(distance))*60*1.1515;if(units.toUpperCase()=="K")distance*=1.609344;else if(units.toUpperCase()=="N")distance*=.8684;return distance}function scanToll(gdir){tripToll="";tollSurcharge=0;journeyTime=0;for(var i=0;i<gdir.getNumRoutes();i++){curRoute=gdir.getRoute(i);journeyTime=journeyTime+parseFloat(curRoute.getDuration().seconds);for(j=0;j<curRoute.getNumSteps();j++){curStep=curRoute.getStep(j).getDescriptionHtml();if(i==1)if(curStep.toLowerCase().indexOf(Toll.toLowerCase())!=-1)for(var k=0;k<arrTollNames.length;k++)if(typeof curStep!="undefined"&&curStep.toLowerCase().indexOf(arrTollNames[k].toLowerCase())!=-1){tollSurcharge=tollSurcharge+parseFloat(arrTollPrices[k]);tripToll=tripToll+arrTollNames[k]+" : $"+arrTollPrices[k]+"<br />"}}}}function processQuote(){scanPossiblePromo();if(selectedDeal!=-1)bruto=parseFloat(arrVehiclePromoPrices[selectedCar][selectedDeal]);else bruto=calcRate(totalDist);calcQuote();selectedDeal==-1&&checkMinPrice();var customerQuote=showCustomerQuote(bookDate,totalDist,less,netto,bruto);renderPageDynamics(customerQuote)}function processSpecialDeal(){bruto=parseFloat(arrVehiclePromoPrices[selectedCar][selectedDeal]);calcQuote();netto=bruto;var customerQuote=showCustomerQuote(bookDate,0,0,netto,bruto);renderPageDynamics(customerQuote)}function calcQuote(){if(isAfterHours)afterHoursSurcharge=rounding(parseFloat(arrCarAfterHourPercentageRate[selectedCar])*bruto/100);else afterHoursSurcharge=0;specialPlacesSurcharge=processSpecialPlaces();bruto=rounding(bruto+afterHoursSurcharge+specialPlacesSurcharge);less=rounding(bruto*Disc/100);netto=rounding(bruto-less+tollSurcharge)}function calcRate(distance){var tempBruto=0;if(selectedDeal==-1){for(var i=0;i<arrCarNames.length;i++)if(i==selectedCar)carRate=parseFloat(arrCarRates[i]);for(var i=0;i<arrSpecialRule.length;i++){curRule=arrSpecialRule[i];if(curRule!=RuleUnavailable){tempDate=new Date(arrSpecialDays[i]);if(tempDate.getMonth()==bookDate.getMonth()&&tempDate.getDate()==bookDate.getDate())carRate=carRate+carRate*parseFloat(curRule)}}for(var i=arrLimits.length-1;i>=0;i--)if(distance>arrLimits[i]){tempBruto=tempBruto+(distance-parseFloat(arrLimits[i]))*(parseFloat(arrRates[i])+carRate);distance=distance-(distance-parseFloat(arrLimits[i]))}}else tempBruto=0;return tempBruto}function scanPossiblePromo(){for(var bestMatchPromoIndex=-1,bestMatchPromoValue=Radius,i=0;i<arrPromoName.length;i++){pickUpArea=GeoDistance(arrPromoFromLat[i],arrPromoFromLong[i],listPlacesLatLong[0][1],listPlacesLatLong[0][2],"K");dropOffArea=GeoDistance(arrPromoToLat[i],arrPromoToLong[i],listPlacesLatLong[1][1],listPlacesLatLong[1][2],"K");if(pickUpArea<=Radius&&dropOffArea<=Radius)if(bestMatchPromoValue>pickUpArea+dropOffArea){bestMatchPromoValue=pickUpArea+dropOffArea;bestMatchPromoIndex=i}}if(bestMatchPromoIndex!=-1){setHTML("NotificationArea",arrMsg[4]);selectedDeal=bestMatchPromoIndex}}function checkMinPrice(){if(isAfterHours&&netto<arrCarMinPriceAfterHours[selectedCar])netto=arrCarMinPriceAfterHours[selectedCar];else if(netto<arrCarMinPriceNormalHours[selectedCar])netto=arrCarMinPriceNormalHours[selectedCar]}function processSpecialPlaces(){var tempSurcharges=0,tempIndex=arrSpecialFromName.indexOf(fromAddress.toLowerCase());if(tempIndex!=-1)tempSurcharges=tempSurcharges+parseFloat(arrSpecialFromFee[tempIndex]);tempIndex=arrSpecialToName.indexOf(toAddress.toLowerCase());if(tempIndex!=-1)tempSurcharges=tempSurcharges+parseFloat(arrSpecialToFee[tempIndex]);return tempSurcharges}function setVars(){selectedDeal=-1;isAfterHours=false;setHTML("NotificationArea","");bruto=0;netto=0;fromAddress=getValue("fromAddress");toAddress=getValue("toAddress");selectedCar=0;if(getValue("carType")!="")selectedCar=getValue("carType");if(getValue("bookDate")==""){setHTML("NotificationArea",arrMsg[0]);return false}if(getValue("hour")==""){setHTML("NotificationArea",arrMsg[0]);return false}if(getValue("minute")==""){setHTML("NotificationArea",arrMsg[0]);return false}if(fromAddress==""||toAddress==""){setHTML("NotificationArea",arrMsg[20]);return false}tempDate=getValue("bookDate").split("/")[1]+"/"+getValue("bookDate").split("/")[0]+"/"+getValue("bookDate").split("/")[2]+" "+getValue("hour")+":"+getValue("minute")*5;bookDate=new Date(tempDate);var validDate=checkDate(bookDate,HourInAdvance);isAfterHours=contains(arrAfterHours,bookDate.getHours());if(validDate==1){setHTML("NotificationArea",arrMsg[2]);return false}if(validDate==2){setHTML("NotificationArea",arrMsg[1]);return false}if(validDate==0){for(var i=0;i<arrPromoName.length;i++)if(arrPromoTo[i].toLowerCase()==toAddress.toLowerCase()&&arrPromoFrom[i].toLowerCase()==fromAddress.toLowerCase())selectedDeal=i;gdir.loadFromWaypoints([Garage+" "+CountryState,fromAddress+" "+CountryState,toAddress+" "+CountryState,Garage+" "+CountryState],{locale:LOCALE,avoidHighways:true})}setDisplay("homeQuoteText","none")}function onGDirectionsLoad(){listPlacesLatLong[0][0]=fromAddress;listPlacesLatLong[0][1]=gdir.getGeocode(1).Point.coordinates[0];listPlacesLatLong[0][2]=gdir.getGeocode(1).Point.coordinates[1];listPlacesLatLong[1][0]=toAddress;listPlacesLatLong[1][1]=gdir.getGeocode(2).Point.coordinates[0];listPlacesLatLong[1][2]=gdir.getGeocode(2).Point.coordinates[1];totalDist=rounding(parseFloat(gdir.getSummaryHtml().split("&nbsp;")[0]));gdirHighway.loadFromWaypoints([Garage+" "+CountryState,fromAddress+" "+CountryState,toAddress+" "+CountryState,Garage+" "+CountryState],{locale:LOCALE,avoidHighways:false})}function onGDirectionsLoadHighway(){var tempTotalDist=rounding(parseFloat(gdirHighway.getSummaryHtml().split("&nbsp;")[0]));if(tempTotalDist>totalDist)scanToll(gdir);else{totalDist=tempTotalDist;scanToll(gdirHighway)}if(selectedDeal==-1)processQuote();else processSpecialDeal()}function renderExtras(index){for(var tempResult="",i=0;i<arrExtrasFee.length;i++)tempResult+='<tr><td class="formlabel"><nobr>'+arrExtrasName[i]+" @$"+arrExtrasFee[i]+'</nobr></td><td class="FormInput"><input onblur="updateQuote(this,'+index+');" onkeypress="if(isDigit(event,this)==false){return false;}" type="text" maxlength="2" id='+ExtraInputName+i+"_"+index+" name="+ExtraInputName+i+"_"+index+"></td></tr>";pr("<table>"+tempResult+"</table>")}function getValue(id){var control=document.getElementById(id);if(typeof control.value=="string")return control.value;return getValueRecursive(control)}function getValueRecursive(control){if(typeof control.value=="string"&&(control.type!="radio"||control.checked==true))return control.value;for(var i=0;i<control.childNodes.length;i++){val=ValidatorGetValueRecursive(control.childNodes[i]);if(val!="")return val}return ""}if(!Array.prototype.indexOf)Array.prototype.indexOf=function(elt){var len=this.length>>>0,from=Number(arguments[1])||0;from=from<0?Math.ceil(from):Math.floor(from);if(from<0)from+=len;for(;from<len;from++)if(from in this&&this[from]===elt)return from;return -1};function unique(a){var r=[];o:for(var i=0,n=a.length;i<n;i++){for(var x=i+1;x<n;x++)if(a[x]==a[i])continue o;r[r.length]=a[i]}return r}function processQuoteDetails(CustomerQuote,bookDate,dist,less,netto,bruto){CustomerQuote+="<p>Selected Promo: <nobr>"+arrPromoName[parseFloat(selectedDeal)]+"</nobr></p>";CustomerQuote+="<p>Total Distance: "+totalDist+" km</p>";CustomerQuote+="<p>Total Journey Time: "+rounding(journeyTime/60)+" minutes</p>";CustomerQuote+="<p>Selected Vehicle Rate: "+carRate+" $/km</p>";CustomerQuote+="<p>Grand Total: $"+bruto+"</p>";CustomerQuote+="<p>Discounts: $"+less+"</p>";CustomerQuote+="<p>Toll Details: "+tripToll+"</p>";CustomerQuote+="<p>Toll Surcharges Total: $"+tollSurcharge+"</p>";CustomerQuote+="<p>Special Place Surcharge: </nobr>$"+specialPlacesSurcharge+"</p>";CustomerQuote+="<p>After Hours Surcharge: $"+afterHoursSurcharge+"</p>";setValue("AdminSummary",CustomerQuote)}function showCustomerQuote(bookDate,dist,less,netto,bruto){var CustomerQuote="<p class=title><strong>";if(PageFlowStatus==PAGE_STATUS_GET_ONE_WAY_QUOTE)CustomerQuote+=JourneyTitle;if(PageFlowStatus==PAGE_STATUS_BOOK_RETURN_JOURNEY)CustomerQuote+=ReturnJourneyTitle;CustomerQuote+="</strong></p>";CustomerQuote+="<p>Pick up: "+fromAddress+"</p>";CustomerQuote+="<p>Destination: "+toAddress+"</p>";CustomerQuote+="<p>Reservation Date & Time: "+formatDate(bookDate)+" "+formatTime(bookDate)+"</p>";CustomerQuote+="<p>Vehicle Type: "+getDefaultVehicles()+"</p>";CustomerQuote+="<p>Passenger: "+arrCarSeats[selectedCar]+"</p>";CustomerQuote+=ExtrasContainerStart+ExtrasContainerEnd;CustomerQuote+="<p>Quote Price: <b>$"+TotalContainerStart+netto+TotalContainerEnd+"</b></p>";processQuoteDetails(CustomerQuote,bookDate,dist,less,netto,bruto);setValue("netto",netto);return CustomerQuote}function modifyQuote(curQuote,index){for(var totalExtras=0,tempExtras="",oldString="",newString="",i=0;i<arrExtrasName.length;i++)if(!(arrExtrasQty[index][i]==undefined||arrExtrasQty[index][i]==null||arrExtrasQty[index][i]==0)){temp=parseFloat(arrExtrasQty[index][i])*parseFloat(arrExtrasFee[i]);tempExtras+="<p>"+arrExtrasQty[index][i]+" "+arrExtrasName[i]+" @$"+parseFloat(arrExtrasFee[i])+" : $"+temp+"</p>";totalExtras+=temp}var ExtrasIndexStart=curQuote.indexOf(ExtrasContainerStart,0);if(index!=0)ExtrasIndexStart=curQuote.indexOf(ExtrasContainerStart,ExtrasIndexStart+1);var ExtrasIndexEnd=curQuote.indexOf(ExtrasContainerEnd,ExtrasIndexStart);oldString=curQuote.substring(ExtrasIndexStart,ExtrasIndexEnd);newString=ExtrasContainerStart+tempExtras;var modifiedQuote=curQuote.substring(0,ExtrasIndexStart)+newString+curQuote.substring(ExtrasIndexEnd,curQuote.length),TotalIndexStart=modifiedQuote.indexOf(TotalContainerStart,0);if(index!=0)TotalIndexStart=modifiedQuote.indexOf(TotalContainerStart,TotalIndexStart+1);var TotalIndexEnd=modifiedQuote.indexOf(TotalContainerEnd,TotalIndexStart);oldString=modifiedQuote.substring(TotalIndexStart,TotalIndexEnd);arrTotalExtras[index]=totalExtras;var newNetto;if(index==0)newNetto=DepartureQuotePrice+totalExtras;else newNetto=ReturnQuotePrice+totalExtras;newString=TotalContainerStart+newNetto;var modifiedQuote=modifiedQuote.replace(oldString,newString);return modifiedQuote}function updateQuote(curElement,index){tempTotalExtras=0;var curValue=curElement.value;if(curValue!=""&&!isNaN(curValue)){for(var i=0;i<arrExtrasName.length;i++){var tempInputName=ExtraInputName+i+"_"+index;if(curElement.id==tempInputName)arrExtrasQty[index][i]=parseFloat(curValue)}setHTML("quotePanel",modifyQuote(getValue("QuoteSummary"),index));setValue("QuoteSummary",modifyQuote(getValue("QuoteSummary"),index));setValue("AdminSummary",modifyQuote(getValue("AdminSummary"),index));for(var j=0;j<MaxTotalJourney;j++)tempTotalExtras+=arrTotalExtras[j];setHTML("TotalQuoteContainer",netto+tempTotalExtras)}}function renderPageDynamics(strInput){switch(getPageName()){case Application_Start_Page:if(PageFlowStatus==PAGE_STATUS_GET_ONE_WAY_QUOTE){OneWayQuote=netto;setText("ForwardJourneyLegend","Total One Way Quote: $"+OneWayQuote);setValue("ForwardFrom",fromAddress);setValue("ForwardTo",toAddress);setDisplay("ForwardJourneyFieldSet","inline");setHTML("quoteDisplay",strInput);tempDeparture=strInput}if(PageFlowStatus==PAGE_STATUS_BOOK_RETURN_JOURNEY){ReturnQuote=netto;setValue("ReturnFrom",fromAddress);setValue("ReturnTo",toAddress);setText("ReturnJourneyLegend","\tTotal Round Trip Quote: $"+(OneWayQuote+netto));setDisplay("ReturnJourneyFieldSet","inline");setHTML("ReturnQuoteDisplay",tempDeparture+strInput)}setDisplay("confirmation2","inline");setValue("QuoteSummary",strInput);getValue("AdminQuoteList")==""&&setDisplay("confirmation1","inline");break;case "confirm.php":setHTML("quotePanel",strInput);break;case "end.php":break}}function PreFormPost(strFlag){switch(getPageName()){case Application_Start_Page:switch(strFlag){case "1":setValue("netto",OneWayQuote);setValue("DepartureQuotePrice",OneWayQuote);break;case "2":setValue("netto",OneWayQuote+ReturnQuote);setValue("DepartureQuotePrice",OneWayQuote);setValue("ReturnQuotePrice",ReturnQuote);break}break;case "confirm.php":temp=EmailLogoStart+EmailLogoEnd+"<br />"+getHTML("quoteHeader")+getHTML("quotePanel")+getHTML("quoteFooter");setValue("QuoteSummary",temp);setValue("AdminSummary",temp);break}return true}function ToggleForwardFieldSet(){if(toggleFieldSet("ForwardJourneyFieldSet","ForwardJourneyTableSet")=="open"){toggleFieldSet("ReturnJourneyFieldSet","ReturnJourneyTableSet","hide");setHTML("ReturnFieldSetStatus","[+]");setHTML("ForwardFieldSetStatus","[-]")}else{toggleFieldSet("ReturnJourneyFieldSet","ReturnJourneyTableSet","open");setHTML("ReturnFieldSetStatus","[-]");setHTML("ForwardFieldSetStatus","[+]")}return false}function ToggleReturnFieldSet(){if(toggleFieldSet("ReturnJourneyFieldSet","ReturnJourneyTableSet")=="open"){toggleFieldSet("ForwardJourneyFieldSet","ForwardJourneyTableSet","hide");setHTML("ReturnFieldSetStatus","[-]");setHTML("ForwardFieldSetStatus","[+]")}else{toggleFieldSet("ForwardJourneyFieldSet","ForwardJourneyTableSet","open");setHTML("ReturnFieldSetStatus","[+]");setHTML("ForwardFieldSetStatus","[-]")}return false}function toggleFieldSet(setID,tableID,overwrite){if(overwrite=="open"){document.getElementById(setID).className="open";tableID!=""&&setDisplay(tableID,"inline")}else if(overwrite=="hide"){document.getElementById(setID).className="collapsed";tableID!=""&&setDisplay(tableID,"none")}else if(document.getElementById(setID).className=="collapsed"){document.getElementById(setID).className="open";tableID!=""&&setDisplay(tableID,"inline");return "open"}else if(document.getElementById(setID).className=="open"){document.getElementById(setID).className="collapsed";tableID!=""&&setDisplay(tableID,"none")}return "hide"}function initAutoSuggest(){var optionsFrom={script:"suburb.php?state="+CountryState+"&json=true&",varname:"input",json:true,shownoresults:false,callback:function(obj){document.getElementById("chosenID").value=obj.id}},optionsTo={script:"suburb.php?state="+CountryState+"&json=true&",varname:"input",json:true,shownoresults:false,callback:function(obj){document.getElementById("chosenID").value=obj.id}},as_json=new bsn.AutoSuggest("fromAddress","autosuggestFrom",optionsFrom),as_json=new bsn.AutoSuggest("fromAddress","autosuggestFrom",optionsFrom),as_json=new bsn.AutoSuggest("toAddress","autosuggestTo",optionsTo)}
