<!-- $Header: /Projects/Taxi/WebBooker/WJBasp.NV/includes/OneForm.js.inc 32 18/12/08 12:03 David.g $ -->
<SCRIPT type="text/javascript">
//<![CDATA[
var serverTimeLead = 0;
var PUtimeChanged = false;
var PUtimeValid = false;
var validityMask = <% = ((vehAttr.length > 0) ? 0 : 8) + ((mandRefMask ^ 0x00F) << 8) %>;
var vehAttribIndex = <% = hasQuote ? Session("VAindex") : -2 %>;
var DDPaddrTypeIndex = <% = hasQuote ? Session("PTindex") : 0 %> ;
var DDDaddrTypeIndex = <% = hasQuote ? Session("DTindex") : 0 %> ;
var PickupDateTime = "0";
var shadowOptions = { distance: 5, angle: 135, opacity: 0.5, nestedShadows: 3 };
var HandlePickup = null;
var HandleDropoff = null;
var nationwideSearch = <% = Session("NationwideSearch") ? 'true' : 'false' %> ;
var defPickupIndex = -1;
var defDropoffIndex = -1;
var HelpT = [];
var noJob = 0;
/*
LOG = function() { };
if (typeof console == 'object') LOG = console.log;
*/
function OnLoad()
{
var mbs = $$(".Tick");
for (i=0; i < mbs.length; i++)
{
mbs[i].style.visibility = "hidden";
}
<% if (Session("AddressShortcuts") || Session("NationwideSearch")) { %>
if (nationwideSearch)
{
var option = "<option>Any Address</option>";
$("DDPaddrType").insert(option);
$("DDDaddrType").insert(option);
}
<% if (Session("AddressShortcuts")) { %>
if (typeof <% = Session("AddressShortcuts") %> == 'object')
{
for (var i=0; i < <% = Session("AddressShortcuts") %>.length; i++)
{
var option = "<option>" + <% = Session("AddressShortcuts") %>[i].group + "</option>";
$("DDPaddrType").insert(option);
$("DDDaddrType").insert(option);
}
}
<% } %>
$("DDPaddrType").selectedIndex = DDPaddrTypeIndex;
$("DDPaddrType").show();
$("DDDaddrType").selectedIndex = DDDaddrTypeIndex;
$("DDDaddrType").show();
<% } else { %>
DDPaddrTypeIndex = 1;
DDDaddrTypeIndex = 1;
SetPaddrType(<% = hasQuote ? "false" : "true" %>);
SetDaddrType(<% = hasQuote ? "false" : "true" %>);
<% } %>
<% if (vehAttr.length > 0) { %>
document.getElementById("DDvehAttr").selectedIndex = vehAttribIndex + 2;
<% } %>
var now = new Date();
serverTimeLead = (now.getTimezoneOffset()) - (<% = d.getTimezoneOffset() %>);
serverTimeLead *= 60000.0;
if (serverTimeLead) $("PickupTimeLegend").innerHTML = "UK Local: ";
<% if (hasQuote) { %>
now.setTime(<% = Session("Job").NominalPickupTime %> + (serverTimeLead));
<% } else { %>
now.setTime(now.getTime() + <% = (leadTimeTicks > 0) ? leadTimeTicks : 0 %> + (serverTimeLead));
<% } %>
formDateTime(now, document.mainForm.PickupTime, document.mainForm.PickupDate);
if (!ie)
{
initCal();
}
document.notifyCalendarChange();
<% if ((Session("PAlist"))
&& (Session("PAindex") >= 0)) { %>
SetPaddrType(false);
defPickupIndex = <% = Session("PAindex") %>;
if (HandlePickup ) HandlePickup.serverIndex = defPickupIndex;
document.getElementById('PAshow').innerHTML = "<% = Session("PPremise") + Session("PAlist").Address(Session("PAindex")) + ' ' + Session("PAlist").Postcode(Session("PAindex")) %>";
Validate(1, true);
<% } %>
<% if ((Session("DAlist"))
&& (Session("DAindex") >= 0)) { %>
SetDaddrType(false);
defDropoffIndex = <% = Session("DAindex") %>;
if (HandleDropoff) HandleDropoff.serverIndex = defDropoffIndex;
document.getElementById('DAshow').innerHTML = "<% = Session("DAlist").Address(Session("DAindex")) + ' ' + Session("DAlist").Postcode(Session("DAindex")) %>";
Validate(2, true);
<% } %>
<% if (hasQuote) { %>
Validate(3, true);
<% } %>
<% if (!Session("User").IsNewUser) { %>
new CUserHandler("PassengerName", function(t) { Validate(5,t) });
new CUserHandler("PaxTelephoneNum", function(t) { Validate(6,t) });
<% if (Application("WJB").UseEmail && Session("EmailIsMandatory")) { %>
new CUserHandler("CustomerEmail", function(t) { Validate(7,t) });
<% } else { %>
Validate(7,true);
<% } %>
for (var i=0; i < 4; i++)
{
var t = $("Ref" + i);
if (t && (t.tagName.toLowerCase() == 'input'))
{
new CRefTextHandler(i);
}
}
<% } %>
<% if (Session("User").IsNewUser && (!hasQuote)) { %>
new Ajax.Request('MAjax.asp',{ parameters: {A: "P", S: "mi"} });
<% } %>
HelpT.R0 = "Enter the required Pickup Date and Time.";
<% if (leadTimeTicks > 0) { %>
HelpT.R0 += " You must book at least <% = Session('User').LeadTimeFormatted %> in advance.";
<% } %>
HelpT.R1 = "Enter the Pickup Address. First select the type of address you want, then search for the exact place.";
HelpT.R2 = "Enter the Dropoff Address. First select the type of address you want, then search for the exact place.";
HelpT.R3 = "For your convenience, we offer a choice of vehicles. Choose the most appropriate type of Vehicle for your needs.";
HelpT.R4 =
<% if (!!Session("SuppressChargesBeforeBooked")) { %>
"Indicates whether we have enough information to book a trip.";
<% } else { %>
"Indicates the cost of the trip.";
<% } %>
HelpT.R5 = "Enter the Passenger Name. This is a mandatory field.";
HelpT.R6 = "Enter a contact Telephone Number. This is a mandatory field.";
HelpT.R7 = "Enter a contact Email address. This is a<% = Session("EmailIsMandatory") ? " mandatory" : "n optional" %> field.";
<% for (var r=0; r < 4; r++)
{
var job = Session("Job"); %>
HelpT.R<% = 8+r %> = "Enter an appropriate value for the '<% = Literal(job.GetReferenceName(r)) %>' reference.";
<% } %>
}
function OnLoadMove(elementID)
{
var c = document.getElementById(elementID);
var x = c.offsetLeft;
x += 60;
c.style.left = x + "px";
}
var delayHelp = null;
var unDelayHelp = null;
function Help(tr)
{
if (delayHelp)
{
clearTimeout(delayHelp);
}
if (unDelayHelp)
{
clearTimeout(unDelayHelp);
unDelayHelp = null;
}
$("HD").innerHTML = HelpT[$(tr).id];
delayHelp = setTimeout(HelpDelayed, 800);
}
function HelpDelayed()
{
delayHelp = null;
$("HB").show();
}
function UnHelp(tr)
{
if (delayHelp)
{
clearTimeout(delayHelp);
delayHelp = null;
}
if (unDelayHelp)
{
clearTimeout(unDelayHelp);
}
unDelayHelp = setTimeout(UnHelpDelayed, 800);
}
function UnHelpDelayed()
{
unDelayHelp = null;
$("HB").hide();
}
var dhFirst = true;
function DetailedHelp(tr)
{
if (dhFirst)
{
$("helpLayer").style.width = "350px";
$("helpLayer").style.left = "20px";
$("helpLayer").style.top = "20px";
dhFirst = false;
}
var elements = $(tr).ancestors();
for (var i=0; i < elements.length; i++)
{
if ((elements[i].tagName == "TR")
&& (String(elements[i].id).substr(0,1) == "R"))
{
var AS = "";
<% if (Session("AddressShortcuts")) { %>
if (typeof <% = Session("AddressShortcuts") %> == 'object')
{
for (var j=0; j < <% = Session("AddressShortcuts") %>.length; j++)
{
AS = AS + ((j > 0) ? ", " : "") + <% = Session("AddressShortcuts") %>[j].group;
}
}
<% } %>
new Ajax.Request(
'MAhelp.asp',
{
onSuccess: ProcessHelp,
parameters: { H: String(elements[i].id), L: serverTimeLead, A: AS }
});
break;
}
}
}
function ProcessHelp(transport)
{
$("fullHelpText").innerHTML = transport.responseText;
showHelp();
}
[b]
var AS_Airport =
{
group :
"Heathrow Airport",
premise:
"Flight Number (eg VS401 Dubai)",
shortcuts :
[
["HEATHROW TERMINAL 1", "Heathrow Airport - Terminal 1"],
["HEATHROW TERMINAL 3", "Heathrow Airport - Terminal 3"],
["HEATHROW TERMINAL 4", "Heathrow Airport - Terminal 4"],
["HEATHROW TERMINAL 5", "Heathrow Airport - Terminal 5"]
],
dd2options : //Add your heathrow specific options to your heathrow object, or to another object
[
["Standard Saloon", [ "01. Saloon [SAL]", "30. Meet & Greet [M&G]" ]],
["Executive Saloon", [ "07. Executive Saloon [EXEC-SAL]", "30. Meet & Greet [M&G]" ]],
["Estate Vehicle", [ "02. Estate [EST]", "30. Meet & Greet [M&G]" ]],
["People Carrier", [ "03. 5 Seater [5ST]", "30. Meet & Greet [M&G]" ]],
["8 Seater Vehicle", [ "06. 8 Seater [8ST]", "30. Meet & Greet [M&G]" ]]
]
};
var AH_Hotel =
{
group :
"Heathrow Hotel",
premise:
"Room Number (if known)",
shortcuts :
[
["ARORA LHR", "Arora Park Hotel Heathrow, Old Bath Road, Poyle, SL3 0NZ"],
["CROWNE PLAZA LHR", "Crowne Plaza Heathrow Hotel, Stockley Road, West Drayton, UB7 9BW"],
["MARRIOTT WINDSOR LHR", "Heathrow & Windsor Marriott, Ditton Road Langley, SL3 8PT"],
["COMFORT INN LHR", "Heathrow Comfort Inn Hotel, Shepiston Lane, Hayes, UB3 1LP"],
["COPTHORNE SLOUGH LHR", "Heathrow Copthorne Slough Windsor, 400 Cippenham Lane, Slough, SL1 2YE"],
["SHERATON LHR", "Heathrow Sheraton Hotel, Colnbrook By Pass, West Drayton, UB7 0HJ"],
["THISTLE LHR", "Heathrow Thistle Hotel, Bath Road, Longford, West Drayton, UB7 0EQ"],
["HILTON LHR", "Hilton Hotel Heathrow, Terminal 4, Scylla Road, TW6 3AF"],
["HOLIDAY INN LHR", "Holiday Inn London Heathrow, Bath Road, Corner Sipson Way, West Drayton, UB7 0DP"],
["HOLIDAY INN AERIAL", "Holiday Inn Aerial Hotel, 118 Bath Road, Hayes, UB3 5AJ"],
["HOLIDAY INN M4", "Holiday Inn M4 Heathrow Hotel, M4 Jnct 4, Sipson Road, UB7 9DJ"],
["IBIS LHR", "Ibis London Heathrow Hotel, 112 Bath Road, Hayes, UB3 5AL"],
["JURYS INN LHR", "Jurys Inn Hotel, Eastern Perimeter Road, Hatton Cross, TW6 2SR"],
["MARRIOTT LHR", "Marriott Heathrow Hotel, Bath Road, Harlington, Hayes, UB3 5AN"],
["NOVOTEL LHR", "Novotel Heathrow Hotel, Cherry Lane, West Drayton, UB7 9HD"],
["PARK INN LHR", "Park Inn Heathrow Hotel, Bath Road, West Drayton, UB7 0DU"],
["RADISSON LHR", "Radisson Edwardian Hotel, 140 Bath Road, Hayes, UB3 5AW"],
["RENAISSANCE LHR", "Renaissance London Heathrow Hotel, Bath Road, Hounslow, TW6 2AQ"],
["SHERATON SKYLINE LHR", "Sheraton Skyline Hotel, Bath Road, Hayes, UB3 5BP"],
["SOFITEL LHR", "Sofitel Heathrow Hotel, Terminal 5, Heathrow Airport, TW6 2GD"]
],
dd2options : //Add your heathrow specific options to your heathrow object, or to another object
[
["Standard Saloon", ["01. Saloon [SAL]"]],
["Executive Saloon", ["07. Executive Saloon [EXEC-SAL]"]],
["Estate Vehicle", ["02. Estate [EST]"]],
["People Carrier", ["03. 5 Seater [5ST]"]],
["8 Seater Vehicle", ["06. 8 Seater [8ST]"]]
]
};
var AddressShortcuts = [AS_Airport,AH_Hotel];
function Repopulate_DD2(){
var dd2=document.getElementById('DDvehAttr');
dd2.options.length=0;
//run a loop to populate drop down
for(var i=0; i<=AS_Airport.dd2options.length-1;i++){
var optn = document.createElement("OPTION");
optn.text = AS_Airport.dd2options[i];
optn.value = i;
dd2.options.add(optn);
}
}
function DDPaddrTypeChanged(control)
{
DDPaddrTypeIndex = control.selectedIndex;
if (HandlePickup) HandlePickup.destruct();
HandlePickup = null;
Validate(1, false);
$("PAinput").hide();
$("PAshow").innerHTML = "";
defPickupIndex = -1;
SetPaddrType(true);
if(control.value=="0"){ //I'm assuming the value is 0, based on what you have
alert('Repopulating');
Repopulate_DD2(); // Call your function to populate your dropdown.
}
}
function SetPaddrType(p)
{
var v = function(t) { Validate(1, t) };
if (DDPaddrTypeIndex == 1)
{
HandlePickup = new CAddressHandlerSearch("PAinput", "PAshow", "P", v, false);
}
else if ((nationwideSearch) && (DDPaddrTypeIndex == 2))
{
HandlePickup = new CAddressHandlerSearch("PAinput", "PAshow", "P", v, true);
}
else if (DDPaddrTypeIndex > 1)
{
HandlePickup = new CAddressHandlerShortcuts("PAinput", "PAshow", "P", v, <% = Session("AddressShortcuts") %>[DDPaddrTypeIndex - (nationwideSearch ? 3 : 2)]);
}
if (p && HandlePickup) HandlePickup.Prompt();
}
[/b]
function DDDaddrTypeChanged(control)
{
DDDaddrTypeIndex = control.selectedIndex;
if (HandleDropoff) HandleDropoff.destruct();
HandleDropoff = null;
Validate(2, false);
$("DAinput").hide();
$("DAshow").innerHTML = "";
defDropoffIndex = -1;
SetDaddrType(true);
}
function SetDaddrType(p)
{
var v = function(t) { Validate(2, t) };
if (DDDaddrTypeIndex == 1)
{
HandleDropoff = new CAddressHandlerSearch("DAinput", "DAshow", "D", v, false);
}
else if ((nationwideSearch) && (DDDaddrTypeIndex == 2))
{
HandleDropoff = new CAddressHandlerSearch("DAinput", "DAshow", "D", v, true);
}
else if (DDDaddrTypeIndex > 1)
{
HandleDropoff = new CAddressHandlerShortcuts("DAinput", "DAshow", "D", v, <% = Session("AddressShortcuts") %>[DDDaddrTypeIndex - (nationwideSearch ? 3 : 2)]);
}
if (p && HandleDropoff) HandleDropoff.Prompt();
}
function DDvehAttrChanged(control)
{
vehAttribIndex = Number(control.options[control.selectedIndex].value);
Validate(3, vehAttribIndex >= -1);
}
function CheckPUtime(f)
{
if (!PUtimeChanged)
{
return;
}
var puTime = new Date();
var now = new Date();
var e = makeDateTime(f.PickupTime, f.PickupDate, puTime);
PUtimeValid = false;
PUtimeChanged = false;
PickupDateTime = "0";
now.setTime(now.getTime() + serverTimeLead);
if (e == 1)
{
alert("Pickup Time is invalid\n\nCorrect value should be like 12:30 or 23:59");
f.PickupTime.focus();
}
else if (e == 2)
{
alert("Pickup Date is invalid");
}
else if ((now.getTime() - puTime.getTime()) > (5 * 60 * 1000))
{
alert("Pickup time can't be in the past");
}
else if ((now.getTime() - puTime.getTime()) > ((5 * 60 * 1000) - <% = leadTimeTicks %>))
{
alert("You must book at least <% = Session('User').LeadTimeFormatted %> in advance");
}
else
{
PUtimeValid = true;
PickupDateTime = String(puTime.getTime() - serverTimeLead);
}
Validate(0, PUtimeValid);
}
function Validate(flag, isValid)
{
if (flag < 4)
{
document.getElementById("Tick4").style.visibility = "hidden";
document.getElementById("BookNow").style.visibility = "hidden";
document.getElementById("Quote").innerHTML = "";
}
var m = (1 << flag);
if (isValid)
{
validityMask |= m;
}
else
{
validityMask &= (~m);
}
var e = document.getElementById("Tick" + flag);
if (e) e.style.visibility = isValid ? "visible" : "hidden";
if ((isValid)
&& ((validityMask & 15) == 15)
&& (flag < 4))
{
// Do ajax quotation here
var post = {
T : PickupDateTime,
PT : DDPaddrTypeIndex,
DT : DDDaddrTypeIndex,
P : HandlePickup ? HandlePickup.serverIndex : defPickupIndex,
D : HandleDropoff ? HandleDropoff.serverIndex : defDropoffIndex,
V : vehAttribIndex
};
new Ajax.Request(
'MAjax.asp',
{
onSuccess: ProcessQuotation,
parameters: post
});
}
if ($("NextButton"))
{
if ((isValid)
&& ((validityMask & 4095) == 4095))
{
$("NextButton").show();
}
else
{
$("NextButton").hide();
}
}
}
var ProcessQuotation = function(transport)
{
noJob = 0;
//set noJob flag back to zero
var response = transport.responseText;
if (response.indexOf("Invalid Job Charge") > 0)
{
response = "To receive a custom quote for this journey please call our office on: +44 (0)20 8814 2727" ;
Validate(4, false);
noJob = 1;
}
else
{
Validate(4, true);
<% if (!!Session("SuppressChargesBeforeBooked")) { %>
if (response.indexOf("Error") < 0) response = "Ready to Book";
<% } %>
}
document.getElementById("Quote").innerHTML = response;
<% if (Session("User").IsNewUser) { %>
//If isNewUSer and noJob = 1
if(noJob == 1 )
{
document.getElementById("BookNow").style.visibility = "hidden";
}
else
{
document.getElementById("BookNow").style.visibility = "visible";
}
<% } %>
}
document.notifyCalendarChange = function()
{
PUtimeChanged = true;
CheckPUtime(document.getElementById("mainForm"));
}
var CUserHandler = Class.create(
{
initialize:
function(inputElement, validate)
{
this.inputElement = $(inputElement);
this.Validate = validate;
this.valid = false;
this.inputElement.observe('keyup', this.OnChange.bindAsEventListener(this));
this.OnChange();
}
,
OnChange:
function(e)
{
var wasValid = this.valid;
this.valid = this.inputElement.value != "";
if (wasValid != this.valid)
{
this.Validate(this.valid);
}
}
}
);
function Check(i, t)
{
if (i.value == "")
{
alert(t + " can't be empty");
i.focus();
return false;
}
return true;
}
function PassPax(wizard)
{
var post = {
P : $("PassengerName").value,
T : $("PaxTelephoneNum").value,
<% if (Application("WJB").UseEmail) { %>
E : $("CustomerEmail").value,
<% } else { %>
E : "",
<% } %>
W : wizard ? "Y" : "N",
PI : HandlePickup ? HandlePickup.serverIndex : defPickupIndex,
DI : HandleDropoff ? HandleDropoff.serverIndex : defDropoffIndex
};
new Ajax.Request(
'MAjax.asp',
{
onSuccess: function() { location = wizard ? "<% = nextWizardStep %>" : "<% = nextStep %>"; },
parameters: post
});
}
function CheckForm()
{
var ok = Check($("PassengerName"), "Passenger Name");
ok = ok && Check($("PaxTelephoneNum"), "Telephone Number");
<% if (Application("WJB").UseEmail && Session("EmailIsMandatory")) { %>
ok = ok && Check($("CustomerEmail"), "E-Mail field");
<% } %>
if (ok) PassPax(false);
}
function GoWizard()
{
PassPax(true);
}
function RefChoiceChanged(control, refIndex)
{
var sel = control.selectedIndex;
var ref = control.options[sel].innerHTML;
Validate(refIndex + 8, control.options[sel].value);
new Ajax.Request(
'MAjax.asp',
{
parameters:
{ R: refIndex, V: ref }
});
}
function Login()
{
location = ((validityMask & 31) == 31) ? "OneFormLogin.asp" : "default.asp?L=1";
}
var CRefTextHandler = Class.create(
{
initialize:
function(refIndex)
{
this.refIndex = refIndex;
this.inputElement = $("Ref" + refIndex);
this.inputValue = "";
this.requestPending = false;
this.timer = null;
this.fOnBlur = this.OnBlur.bindAsEventListener(this);
this.fOnKeyUp = this.OnKeyUp.bindAsEventListener(this);
this.fAddressChange = this.AddressChange.bind(this);
this.inputElement.observe('blur', this.fOnBlur );
this.inputElement.observe('keyup', this.fOnKeyUp );
}
,
OnBlur:
function(e)
{
if (this.inputElement.value != this.inputValue)
{
if (this.timer)
{
clearTimeout(this.timer);
this.timer = null;
}
Validate(this.refIndex + 8, false);
this.AddressChange();
}
}
,
OnKeyUp:
function(e)
{
if (this.inputElement.value != this.inputValue)
{
if (this.timer)
{
clearTimeout(this.timer);
}
Validate(this.refIndex + 8, false);
this.inputValue = this.inputElement.value;
this.timer = setTimeout(this.fAddressChange, 400);
}
}
,
AddressChange:
function()
{
this.timer = null;
if (this.requestPending)
{
this.timer = setTimeout(this.fAddressChange, 300);
}
else
{
this.inputValue = this.inputElement.value;
this.requestPending = true;
Validate(this.refIndex + 8, false);
new Ajax.Request(
'MAjax.asp',
{
onSuccess:
this.OnSuccess.bind(this),
onComplete:
this.OnComplete.bind(this),
parameters:
{ R: this.refIndex, V: this.inputValue }
}
);
}
}
,
OnComplete:
function(transport)
{
this.requestPending = false;
}
,
OnSuccess:
function(transport)
{
var response = transport.responseText;
Validate(this.refIndex + 8, !!parseInt(response));
}
}
);
//]]>
</SCRIPT>