/** Date and time code adapted from dateTime.js */
var mainJourneyRequestDetails_timeSelect = null ;
var mainJourneyRequestDetails_dateSelect = null ;
var currentTime = new Date();
function UpdatemainJourneyRequestDetails_timeSelect(formWithTime)
{
var h = new String( mainJourneyRequestDetails_timeSelect.getSelHour() );
var m = padZero( mainJourneyRequestDetails_timeSelect.getSelMins() );
formWithTime.form.time.value = h + ':' + m + ':00';
}
function CreatemainJourneyRequestDetails_timeSelect()
{
var htmloutput = '';
var now = currentTime.getHours() + ':' + currentTime.getMinutes();
htmloutput += '';
htmloutput += '';
htmloutput += '';
return htmloutput;
}
function UpdatemainJourneyRequestDetails_dateSelect(selectElm)
{
var y = new String( mainJourneyRequestDetails_dateSelect.getSelYear() );
var m = padZero( mainJourneyRequestDetails_dateSelect.getSelMonth() );
var d = padZero( mainJourneyRequestDetails_dateSelect.getSelDay() );
mainJourneyRequestDetails_dateSelect.setDateParts(y,m,d);
var y2 = new String( mainJourneyRequestDetails_dateSelect.getSelYear() );
var m2 = padZero( mainJourneyRequestDetails_dateSelect.getSelMonth() );
var d2 = padZero( mainJourneyRequestDetails_dateSelect.getSelDay() );
selectElm.form.date.value = d2 + '/' + m2 + '/' + y2;
}
function CreatemainJourneyRequestDetails_dateSelect()
{
var htmloutput = '';
var today = currentTime.getDate() + "/" + (currentTime.getMonth() + 1) + "/" + currentTime.getFullYear();
htmloutput += '';
htmloutput += '';
htmloutput += '';
return htmloutput;
}
function PageLanderSetupDateTimeInputs(customFormName) {
var formName = 'journeyPlannerForm';
if (typeof customFormName !== 'undefined') {
formName = customFormName;
}
// setup time input
mainJourneyRequestDetails_timeSelect = new tmInput( 'time', formName );
// setup date input
mainJourneyRequestDetails_dateSelect = new dsInput( 'date', formName );
mainJourneyRequestDetails_dateSelect.monthNames = new Array( '','January','February','March','April','May','June','July','August','September','October','November','December' );
mainJourneyRequestDetails_dateSelect._initOptions();
var start = new Date();
var end = new Date();
end.setDate(start.getDate()+80);
var startMonth = start.getUTCMonth()+1;
var endMonth = end.getUTCMonth()+1;
var startDay = start.getUTCDate();
var endDay = end.getUTCDate();
if(startMonth < 10)
{
startMonth = "0"+startMonth;
}
if(endMonth < 10)
{
endMonth = "0"+endMonth;
}
if(startDay < 10)
{
startDay = "0"+startDay;
}
if(endDay < 10)
{
endDay = "0"+endDay;
}
start = start.getUTCFullYear()+"-"+startMonth+"-"+startDay;
end = end.getUTCFullYear()+"-"+endMonth+"-"+endDay;
mainJourneyRequestDetails_dateSelect.setDateRange(start.toString(), end.toString());
//mainJourneyRequestDetails_dateSelect.setDateRange("2009-02-01", "2009-07-10");
}
/* create a string replace all function */
if ( typeof String.prototype.replaceAll == 'undefined' ) {
String.prototype.replaceAll = function(regex, replace) {
var a = this;
while (a.search(regex) >= 0) {
a = a.replace(regex, replace);
}
return a;
}
}
/** Function to construct a page lander template object */
function PageLanderTemplate() {
this.type = 1;
this.locationName = "";
this.locationEasting = 0;
this.locationNorthing = 0;
this.isLocality = false;
this.locationTitle = "";
this.serverPath = "";
this.skinPath = "";
}
PageLanderTemplate.prototype.matchTemplateValue = function(valueIndex) {
var value = null;
switch(valueIndex) {
case 0:
value = this.locationName;
break;
case 1:
value = new String(this.locationEasting);
break;
case 2:
value = new String(this.locationNorthing);
break;
case 3:
value = this.serverPath;
break;
case 4:
value = this.skinPath;
break;
case 5:
value = this.locationTitle;
break;
case 6:
value = new String(this.isLocality);
break;
}
return value;
}
PageLanderTemplate.prototype.getRawSource = function() {
var templateCode = "";
// select the raw template code
switch (this.type) {
case 1:
templateCode = new String('
');
break;
case 2:
templateCode = new String('
');
break;
case 3:
templateCode = new String('
');
break;
case 4:
templateCode = new String('
');
break;
case 5:
templateCode = new String('
');
break;
case 6:
templateCode = new String('
');
break;
}
return templateCode;
}
PageLanderTemplate.prototype.getReplacedSource = function() {
var templateCode = this.getRawSource();
// replace the properties in the template code
for (var i = 0; i < 7; ++i) {
var replacementText = this.matchTemplateValue(i);
if (replacementText !== null) {
templateCode = templateCode.replaceAll(new RegExp("\\{"+i+"\\}"), replacementText);
}
}
// replace time input placeholder
var timeinput = CreatemainJourneyRequestDetails_timeSelect()
templateCode = templateCode.replaceAll(new RegExp("\\{TimeInput\\}"), timeinput);
// replace date input placeholder
var dateinput = CreatemainJourneyRequestDetails_dateSelect()
templateCode = templateCode.replaceAll(new RegExp("\\{DateInput\\}"), dateinput);
return templateCode;
}
PageLanderTemplate.prototype.renderTemplate = function() {
// get the template code with all values inserted
var templateCode = this.getReplacedSource();
// write the output to the page
document.write(templateCode);
}
/**
* EVERYTHING BELOW THIS IS AN OLD WAY OF GENERATING THE TEMPLATES, KEPT FOR BACKWARDS
* COMPATABILITY. IT WAS LIMITED BY THE FUNCTION PROTOTYPES AND COULD NOT BE EXPANDED.
*
* Used by code generated by page lander wizard
* versions < 6.02.000
* versions < 7.01.000
* versions < 8.01.000
*/
/** Code to generate the forms */
function PageLanderFormTemplate(type, locationName, easting, northing, serverPath, skinPath, locationTitle) {
/* check type */
switch(type) {
case 1:
PageLanderPostcodeOnlyTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
case 2:
PageLanderPostcodePlusToFromTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
case 3:
PageLanderPostcodePlusDateTimeTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
case 4:
PageLanderFixedFullTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
case 5:
PageLanderNonFixedNowTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
case 6:
PageLanderNonFixedFullTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle);
break;
}
}
function PageLanderFormTemplateReplacements(number, raw, locationName, easting, northing, serverPath, skinPath, locationTitle) {
var output = raw;
// replace locationName
output = output.replaceAll(new RegExp("\\{0\\}"), locationName);
// replace easting
output = output.replaceAll(new RegExp("\\{1\\}"), easting);
// replace northing
output = output.replaceAll(new RegExp("\\{2\\}"), northing);
// replace serverPath
output = output.replaceAll(new RegExp("\\{3\\}"), serverPath);
// replace serverPath
output = output.replaceAll(new RegExp("\\{4\\}"), skinPath);
// replace serverPath
if (typeof(locationTitle) != 'undefined' && locationTitle != null)
{
output = output.replaceAll(new RegExp("\\{5\\}"), locationTitle);
}
// replace time input placeholder
var timeinput = CreatemainJourneyRequestDetails_timeSelect()
output = output.replaceAll(new RegExp("\\{TimeInput\\}"), timeinput);
// replace date input placeholder
var dateinput = CreatemainJourneyRequestDetails_dateSelect()
output = output.replaceAll(new RegExp("\\{DateInput\\}"), dateinput);
return output;
}
/** Template 1 */
function PageLanderPostcodeOnlyTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(1, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}
/** Template 2 */
function PageLanderPostcodePlusToFromTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(2, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}
/** Template 3 */
function PageLanderPostcodePlusDateTimeTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(3, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}
/** Template 4 */
function PageLanderFixedFullTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(4, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}
/** Template 5 */
function PageLanderNonFixedNowTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(5, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}
/** Template 6 */
function PageLanderNonFixedFullTemplate(locationName, easting, northing, serverPath, skinPath, locationTitle) {
// raw form format
var raw = new String('
');
// replace special text
var output = PageLanderFormTemplateReplacements(6, raw, locationName, easting, northing, serverPath, skinPath, locationTitle);
// write the output to the page
document.write(output);
}