var base_url="http://www.ozcampervanrentals.com/campers/";
var min_rental=5;
var dep_days=1;
var months=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
var locations=new Array("ADL","ASP","BNE","BME","CNS","DRW","MEL","PER","SYD");
var msg01="Round trip rental selected, minimum rental period for one way hire not applicable";
var msg02="Minimum hire period is "+min_rental+" days";
var msg03="Cannot acccept a Pick Up Date before ";
var msg04="Please select a Pick Up Location";
var msg05="Please select a Pick Up Time";
var msg06="Please select a Drop Off Time";
var msg07="The maximum number of passengers (Adults + Children) is ";
var msg08=" rental selected, minimum rental period is ";
var msg09="The Drop Off time is later than the Pick Up time.\nOne extra day will be charged.\n\nPress \"OK\" to continue or \"Cancel\" if you wish\nto change the Drop Off time."
var msg10="Only vehicles with 2/3 berths are available for pick up at Broome.\nPlease reduce the number of passengers or select a different pick up location."
var msg11="Please select one of the vehicles";
var msg12="Please ensure that you enter the following data:\n\n\tFirst & Last Name\n\tAddress\n\tCity\n\tDrivers Age\n\tEmail Address";
var msg13="Please enter a valid email address\n";
var msg14="You must agree to the Terms and Conditions of booking\notherwise we cannot continue with the vehicle hire.";
var msg15="You must confirm that the driver is between 21 and 75 years of age.\n";
var today=new Date();
var year1=today.getFullYear();
var year2=year1+2;
var dateform="%e-%B-%Y";
var mindays=min_rental;
var city1=""
var city2="";
var is_one_way=false;
var index=0;
var group="NONE";
function checkoutOK(form){
var i=0,flds=0,isok=true,message="",reqd=new Array("FirstName","LastName","Address","City","Email");
for(i=0;i<reqd.length;i++){if(eval("form."+reqd[i]+".value.length==0") || eval("form."+reqd[i]+".value.length==null")){
isok=false;message=msg12;break;}}
if(isok){if(!isEmail(form.Email.value)){message=msg13;isok=false;}
if(form.DriverAge.checked==false){message+=msg15;isok=false;}
if(form.AcceptTerms.checked==false){message+=msg14;isok=false;}}
if(!isok){alert(message);}return(isok);}
function isHired(form){
var message="";var ext=parseInt(document.BuyForm.Extras.value);
var ins=parseInt(document.BuyForm.Insurs.value);
var choice=new Array();
if(index>0){calcPrice(index,group);}else{message+=msg11;}
for(var i=1;i<(ext+1);i++){
if(eval("document.BuyForm.Extra_"+i+".checked==true")&&eval("document.BuyForm.Qty_"+i+".selectedIndex==0")){
choice=eval("document.BuyForm.Extra_"+i+".value.split('##')");
message+="You have checked "+choice[1]+" but have not selected the Qty\n";}}
if(message!=""){alert(message);return(false);}
else{return(true);}}
function calcPrice(arg1,arg2){
var ext=parseInt(document.BuyForm.Extras.value);
var ins=parseInt(document.BuyForm.Insurs.value);
var days=parseInt(document.BuyForm.Days.value);
var cars=parseInt(document.BuyForm.Index.length);
var choice=new Array();var price=0;var total=0;index=arg1;group=arg2;
var data=document.BuyForm.PickUpDate.value.split("-");
for(var i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date1=new Date(parseInt(data[2]),month,parseInt(data[0]));
if(Math.round((date1-today)/86400000)<dep_days){document.BuyForm.FullDeposit.value="1";}
total=eval("parseFloat(document.BuyForm.Price_"+index+".value)");
if(group=="HITOP1"||group=="HITOP2"||group=="2BERTHST"||group=="4WDADV"){
for(i=1;i<(ext+1);i++){choice=eval("document.BuyForm.Extra_"+i+".value.split('##')");
if(choice[0]=="0"){eval("document.BuyForm.Extra_"+i+".checked=0");
eval("document.BuyForm.Extra_"+i+".disabled=true");
eval("document.BuyForm.Qty_"+i+".selectedIndex=0");}
else{eval("document.BuyForm.Extra_"+i+".disabled=false");}}}
else{for(i=1;i<(ext+1);i++){eval("document.BuyForm.Extra_"+i+".disabled=false");}}
for(i=1;i<(ext+1);i++){if(eval("document.BuyForm.Extra_"+i+".checked==true")){
choice=eval("document.BuyForm.Extra_"+i+".value.split('##')");
if(choice[3]=="EA"){price=parseFloat(choice[2])*parseInt(eval("document.BuyForm.Qty_"+i+".options[document.BuyForm.Qty_"+i+".options.selectedIndex].value"));}
else{price=parseFloat(choice[2])*parseInt(document.BuyForm.Days.value);}
if(choice[4]!="N/A"&&parseFloat(choice[4])<price){
price=parseFloat(choice[4]);}total+=price;}}
for(i=1;i<(ins+1);i++){if(eval("document.BuyForm.Insur_"+i+".checked==true")){
choice=eval("document.BuyForm.Insur_"+i+".value.split('##')");
price=parseFloat(choice[2])*parseInt(document.BuyForm.Days.value);
if(choice[4]!="N/A"&&parseFloat(choice[4])<price){price=parseFloat(choice[4]);}total+=price;}}
document.BuyForm.Amount.value=total;document.BuyForm.DispAmount.value=formatAmount(total);}
function calcOption(){
if(index>0){calcPrice(index,group);}}
function setForm(){
var leadtime=parseInt(document.BuyForm.LeadTime.value);
var days=parseInt(document.BuyForm.Days.options[document.BuyForm.Days.options.selectedIndex].value);
var date1=new Date(today.getFullYear(),today.getMonth(),(today.getDate()+leadtime));
var date2=new Date(Date.parse(date1)+(days*86400000));
document.BuyForm.PickUpDate.value=date1.getDate()+'-'+months[date1.getMonth()]+'-'+date1.getFullYear();
document.BuyForm.DropOffDate.value=date2.getDate()+'-'+months[date2.getMonth()]+'-'+date2.getFullYear();}
function setDropOff(){
var data=document.BuyForm.PickUpDate.value.split("-");
for(var i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var days=parseInt(document.BuyForm.Days.options[document.BuyForm.Days.options.selectedIndex].value);
var date1=new Date(parseInt(data[2]),month,parseInt(data[0]));
var date2=new Date(date1.getFullYear(),date1.getMonth(),(date1.getDate()+days));
document.BuyForm.DropOffDate.value=date2.getDate()+'-'+months[date2.getMonth()]+'-'+date2.getFullYear();}
function setDays(){
var data=document.BuyForm.PickUpDate.value.split("-");
var maxdays=BuyForm.Days.options[BuyForm.Days.length-1].value;
for(var i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date1=new Date(parseInt(data[2]),month,parseInt(data[0]));
data=document.BuyForm.DropOffDate.value.split("-");
for(i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date2=new Date(parseInt(data[2]),month,parseInt(data[0]));
var days=Math.round((date2-date1)/86400000);
if(days>=5&&days<=maxdays){document.BuyForm.Days.options.selectedIndex=Math.round((date2-date1)/86400000)-parseInt(BuyForm.Days.options[0].value);}
else{alert(msg02+'\n'+'Maximum hire period is '+maxdays+' days');setDropOff();}}
function setDropOffTime(){
document.BuyForm.DropOffTime.options.selectedIndex=document.BuyForm.PickUpTime.options.selectedIndex;}
function firstDate(){
var leadtime=parseInt(document.BuyForm.LeadTime.value);
var date1=new Date(today.getFullYear(),today.getMonth(),(today.getDate()+leadtime));
var data=document.BuyForm.PickUpDate.value.split("-");
for(var i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date2=new Date(parseInt(data[2]),month,parseInt(data[0]));
if(date2<date1){alert(msg03+date1.getDate()+"-"+months[date1.getMonth()]+"-"+date1.getFullYear());
document.BuyForm.PickUpDate.value=date1.getDate()+'-'+months[date1.getMonth()]+'-'+date1.getFullYear();}
setDropOff();}
function setLocation(loc){
for(var i=0;i<document.BuyForm.PickUp.options.length;i++){
if(loc==document.BuyForm.PickUp.options[i].value){document.BuyForm.PickUp.options.selectedIndex=i;
oneWayDays();break;}}}
function chkHire(form){
var message="";
var adult=parseInt(document.BuyForm.Adults.options[document.BuyForm.Adults.options.selectedIndex].value);
var child=parseInt(document.BuyForm.Children.options[document.BuyForm.Children.options.selectedIndex].value);
var days=parseInt(document.BuyForm.Days.options[document.BuyForm.Days.options.selectedIndex].value);
var data=document.BuyForm.PickUpDate.value.split("-");
var maxdays=document.BuyForm.Days.options[document.BuyForm.Days.length-1].value;
for(var i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date1=new Date(parseInt(data[2]),month,parseInt(data[0]));
data=document.BuyForm.DropOffDate.value.split("-");
for(i=0;i<months.length;i++){if(months[i]==data[1]){var month=i;break;}}
var date2=new Date(parseInt(data[2]),month,parseInt(data[0]));
var days=Math.round((date2-date1)/86400000);
if(days<5||days>maxdays){alert(msg02+'\n'+'Maximum hire period is '+maxdays+' days');setDropOff();return(false);}
if(document.BuyForm.Command.value=="##COMMAND##"){return(false);}
if(document.BuyForm.PickUp.options[document.BuyForm.PickUp.options.selectedIndex].value=="XX"){alert('Please select a Pick Up Location');return(false);}
oneWayDays();
if(document.BuyForm.PickUp.options[document.BuyForm.PickUp.options.selectedIndex].value=="BME"&&((adult+child)>3)){alert(msg10);return(false);}
//if(document.BuyForm.DropOffTime.options.selectedIndex>document.BuyForm.PickUpTime.options.selectedIndex){
//if(!confirm(msg09)){document.BuyForm.IsExtraDay.value=0;return(false);}
//else{document.BuyForm.IsExtraDay.value=1;}}
//else{
document.BuyForm.IsExtraDay.value=0;
//}
if(document.BuyForm.Days.options[document.BuyForm.Days.options.selectedIndex].value=="XX"){message+=msg04+"\n";}
if(document.BuyForm.PickUpTime.options[document.BuyForm.PickUpTime.options.selectedIndex].value=="XX"){message+=msg05+"\n";}
if(document.BuyForm.DropOffTime.options[document.BuyForm.DropOffTime.options.selectedIndex].value=="XX"){message+=msg06+"\n";}
if((adult+child)>parseInt(document.BuyForm.MaxPassenger.value)){message+=msg07+document.BuyForm.MaxPassenger.value+"\n";}
if(is_one_way&&(days<mindays)){message+=city1+"->"+city2+msg08+mindays+" days";}
if(message!=""){alert(message);return(false);}else{return(true);}}
function oneWayDays(){
var depot1=document.BuyForm.PickUp.options[document.BuyForm.PickUp.options.selectedIndex].value;
var depot2=document.BuyForm.DropOff.options[document.BuyForm.DropOff.options.selectedIndex].value;
city1=document.BuyForm.PickUp.options[document.BuyForm.PickUp.options.selectedIndex].text;
city2=document.BuyForm.DropOff.options[document.BuyForm.DropOff.options.selectedIndex].text;
if(depot2!="SAME"){if(depot1!="XX"){
if(document.BuyForm.PickUp.options[document.BuyForm.PickUp.options.selectedIndex].value==document.BuyForm.DropOff.options[document.BuyForm.DropOff.options.selectedIndex].value){
mindays=min_rental;is_one_way=false;document.BuyForm.IsOneWay.value="0";document.BuyForm.OneWay.value=msg01;}
else{for(var i=0;i<locations.length;i++){if(locations[i]==depot2){var index1=i;break;}}
mindays=eval(depot1+"["+index1+"]");
document.BuyForm.OneWay.value=city1+"->"+city2+msg08+mindays+" days";
is_one_way=true;document.BuyForm.IsOneWay.value="1";}}
else{mindays=min_rental;is_one_way=false;document.BuyForm.IsOneWay.value="0";}}
else{document.BuyForm.OneWay.value=msg01;mindays=min_rental;is_one_way=false;
document.BuyForm.IsOneWay.value="0";}}
function formatAmount(arg){
var mydata="0.00",amt=parseFloat(arg);
if(amt>0){amt*=100;amt=(Math.round(amt)/100);mydata=new String(amt);
if(mydata.indexOf(".")==-1){mydata+=".00";}
else{if(mydata.indexOf(".")==mydata.length-2){mydata+="0";}}}
return("$"+mydata);}
function openWindow(arg){
popupWin=window.open(arg,"popup","toolbar,scrollbars,resizable,width=670,height=550,left=10,top=30");}
function isEmail(fld){
var emailaddr=/^.+\@.+\..+$/;
if(emailaddr.test(fld)){return(true);}else{return(false)}}

/*########################################################
# Copyright Hallisoft                                    #
# http://www.hallisoft.com All rights reserved OCT 2006  #
##########################################################*/
