var SOURCE_URL = "/cms/global/json/sep07woffers/sep07woffersdata.json";
var SOURCE_TYPE = "json";
var DOCUMENT_ELEMENT_ID = "table1"
var ONEWAY_PRICE_POSTPIN_DISCOUNT = 0;
var RETURN_PRICE_POSTPIN_DISCOUNT = 10;
var HOTEL_PRICE_POSTPIN_DISCOUNT = 15;
var ONEWAY_PRICE_TYPE = "ow";
var RETURN_PRICE_TYPE = "rt";
var TABLE_HEADERS = [["Destination", "1"],
["Prices from", "4"],
["Upgrade your trip", "1"],
["Hotel", "1"],
["Hotel prices from pppn", "1"],
["Hotel star rating", "1"]];
var LOCATIONS = [["ABZ", "Aberdeen", "ABZ", "Aberdeen", "EUR"],
["BRS", "Bristol", "", "", "EUR"],
["ORK", "Cork", "", "", "EUR"],
["DUB", "Dublin", "", "", "EUR"],
["EMA", "East Midlands", "", "", "EUR"],
["EDI", "Edinburgh", "", "", "EUR"],
["GLA", "Glasgow", "", "", "EUR"],
["INV", "Inverness", "", "", "EUR"],
["IOM", "Isle of Man", "", "", "EUR"],
["JER", "Jersey", "", "", "EUR"],
["LCY", "London City", "LON", "London", "EUR"],
["LGW", "London Gatwick", "LON", "London", "EUR"],
["LHR", "London Heathrow", "LON", "London", "EUR"],
["MAN", "Manchester", "", "", "EUR"],
["NCL", "Newcastle", "", "", "EUR"],
["NAM", "North America", "", "North America", "NAM"],
["AFR", "Africa", "", "Africa", "AFR"],
["SASIA", "Central Asia", "", "Central Asia", "SASIA"],
["FEA", "Far East and Australia", "", "Far East and Australia", "FEA"],
["LAC", "Latin America and Caribbean", "", "Latin America and Caribbean", "LAC"],
["ME", "Middle East", "", "Middle East", "ME"],
["NAF", "North Africa", "", "North Africa", "NAF"],
["SNN", "Shannon", "", "", "EUR"],
["EUR", "Europe", "", "Europe", "EUR"],
["UKI", "UK and Ireland", "", "UK and Ireland", "UKI"],
["A_W", "All locations", "A_W", "All locations", "EUR"]
];
var gWoffersData = new WoffersData(SOURCE_URL, SOURCE_TYPE);
var gWofferTable = null;
var gPageType = "";
var gFromCode = "";
var gToCode = "";
var gButtonType = "";
$(pageSetup);
function pageSetup() {
try {
initLocations();
gFromCode = $("#originDropDown option[@selected]")[0].value;
gToCode = $("#destDropDown option[@selected]")[0].value;
initPageType();
gWofferTable = new WofferTable(DOCUMENT_ELEMENT_ID, gWoffersData, gFromCode, gToCode);
gWoffersData.build();
$("#originDropDown").keyup(function() {gWofferTable.processFromChange(this);});
$("#originDropDown").change(function() {gWofferTable.processFromChange(this);});
$("#destDropDown").keyup(function() {gWofferTable.processToChange(this);});
$("#destDropDown").change(function() {gWofferTable.processToChange(this);});
$("#bottomOriginDropDown").keyup(function() {gWofferTable.processFromChange(this);});
$("#bottomOriginDropDown").change(function() {gWofferTable.processFromChange(this);});
$("#bottomDestDropDown").keyup(function() {gWofferTable.processToChange(this);});
$("#bottomDestDropDown").change(function() {gWofferTable.processToChange(this);});
$(".imageNav a").click(function() {gWofferTable.processImageToChange(this);});
var dirLogin = "";
if(gButtonType == "BOOK") {
dirLogin = "/main/september-sale?campaign=DROP";
}
else {
dirLogin = "/main/september-sale?campaign=PODS";
}
$("#directionalLogin")[0].setAttribute("value", dirLogin);
}
catch(e) {
}
}
function WoffersData(sourceURL, sourceType) {
if(sourceType != "json") {
throw new Error("Invalid source type (" + sourceType + ") supplied to Woffers constructor.");
}
this.sourceURL = sourceURL;
this.sourceType = sourceType;
}
WoffersData.prototype.build = function() {
var instance = this;
var ajaxXmlhttp = null;
this.woffers = new Array();
if(window.XMLHttpRequest && !(window.ActiveXObject)) {
try {
ajaxXmlhttp = new XMLHttpRequest();
}
catch(e) {
ajaxXmlhttp = null;
}
}
else if(window.ActiveXObject) {
try {
ajaxXmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try {
ajaxXmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
ajaxXmlhttp = null;
}
}
}
if(ajaxXmlhttp) {
ajaxXmlhttp.onreadystatechange = function() {
if(ajaxXmlhttp.readyState == '4') {
var response = ajaxXmlhttp.responseText;
response = response.replace(/\r\n/g, '');
response = eval('(' + response + ')');
instance.parseJson(response);
}
};
ajaxXmlhttp.open("GET", this.sourceURL, true);
ajaxXmlhttp.send(null);
}
}
WoffersData.prototype.parseJson = function(json) {
for(var index = 0; index < json.routes.length; ++index) {
this.woffers.push(new Woffer(json.routes[index]));
}
gWofferTable.buildOutput();
}
WoffersData.prototype.getWoffersForRegion = function(region) {
var matchingWoffers = new Array();
for(var index = 0; index < this.woffers.length; ++index) {
if(this.woffers[index].regionCode == region) {
matchingWoffers.push(this.woffers[index]);
}
}
return(matchingWoffers);
}
WoffersData.prototype.getWoffersForLocations = function(fromCode, toCode) {
var matchingWoffers = new Array();
var currentWoffer = null;
for(var index = 0; index < this.woffers.length; ++index) {
currentWoffer = this.woffers[index];
if(((fromCode == "A_W") || (currentWoffer.matchesDepartureCode(fromCode))) &&
((toCode == "A_W") || (currentWoffer.matchesDestinationCode(toCode)))) {
matchingWoffers.push(currentWoffer);
}
}
return(matchingWoffers);
}
WoffersData.prototype.processError = function(ajaxResponse, text, exception) {
throw new Error("Encountered a problem retreiving the JSON file." +
" Reported status is: " + text + ".\n\n" +
" Exception details are: " + exception.toString());
}
function Woffer(wofferData) {
this.originAirport = "";
this.destinationAirport = "";
this.destinationName = "";
this.regionCode = "";
this.priceType = "";
this.footnote = "";
this.prices = null;
this.wofferOptions = new Array();
if(wofferData.from) {
this.originAirport = wofferData.from;
}
if(wofferData.to) {
this.destinationAirport = wofferData.to;
}
if(wofferData.to_name) {
this.destinationName = wofferData.to_name;
}
if(wofferData.region) {
this.regionCode = wofferData.region;
}
if(wofferData.price_type) {
this.priceType = wofferData.price_type;
}
if(wofferData.footnote) {
this.footnote = wofferData.footnote;
}
if(wofferData.datesprices) {
this.prices = new Prices(wofferData.datesprices);
}
var tempOptionTitle = "";
var tempOptionValue = "";
if(wofferData.non_flight) {
tempOptionTitle = "nonFlight";
tempOptionValue = wofferData.non_flight;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
if(wofferData.non_flight_price) {
tempOptionTitle = "nonFlightPrice";
tempOptionValue = wofferData.non_flight_price;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
if(wofferData.optional1) {
tempOptionTitle = "optional1";
tempOptionValue = wofferData.optional1;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
if(wofferData.optional2) {
tempOptionTitle = "optional2";
tempOptionValue = wofferData.optional2;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
if(wofferData.optional3) {
tempOptionTitle = "optional3";
tempOptionValue = wofferData.optional3;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
if(wofferData.optional4) {
tempOptionTitle = "optional4";
tempOptionValue = wofferData.optional4;
this.wofferOptions.push(new WofferOption(tempOptionTitle, tempOptionValue));
}
}
Woffer.prototype.getLowestPrice = function() {
var lowestPrice = null;
var currentPrice = null;
for(var index = 0; index < this.prices.prices.length; ++index) {
currentPrice = this.prices.prices[index];
if((lowestPrice == null) || (currentPrice.price < lowestPrice.price)) {
lowestPrice = currentPrice;
}
}
return(lowestPrice);
}
Woffer.prototype.matchesDepartureCode = function(fromCode) {
var matched = false;
var currentPrice = null;
if(this.originAirport == fromCode) {
matched = true;
}
else {
for(var priceIndex = 0; priceIndex < this.prices.prices.length; ++priceIndex) {
currentPrice = this.prices.prices[priceIndex];
if(currentPrice.hasAddonLocation(fromCode)) {
matched = true;
break;
}
}
}
return(matched);
}
Woffer.prototype.matchesDestinationCode = function(toCode) {
var matched = false;
if(this.regionCode == toCode) {
matched = true;
}
return(matched);
}
Woffer.prototype.getOption = function(optionKey) {
var returnOption = null;
var currentOption = null;
for(var index = 0; index < this.wofferOptions.length; ++index) {
currentOption = this.wofferOptions[index];
if(currentOption.title == optionKey) {
returnOption = currentOption;
break;
}
}
return(returnOption);
}
function Prices(priceData) {
this.prices = new Array();
var newPrice = null;
for(var index = 0; index < priceData.length; ++index) {
newPrice = new Price(priceData[index]);
if(newPrice.price && (newPrice.price != "")) {
this.prices.push(new Price(priceData[index]));
}
}
}
function Price(priceData) {
this.price = null;
var tempPrice = 0;
this.outboundFromDate = "";
this.outboundToDate = "";
this.addonPrices = new Array();
if(priceData.price) {
tempPrice = priceData.price.replace(/\,/g, '');
this.price = Math.round(tempPrice);
}
if(priceData.out_from) {
this.outboundFromDate = priceData.out_from;
}
if(priceData.out_to) {
this.outboundToDate = priceData.out_to;
}
var tempDepartureCode = "";
if(priceData.abz_add_on) {
tempDepartureCode = "ABZ";
tempPrice = priceData.abz_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
if(priceData.man_add_on) {
tempDepartureCode = "MAN";
tempPrice = priceData.man_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
if(priceData.edi_add_on) {
tempDepartureCode = "EDI";
tempPrice = priceData.edi_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
if(priceData.ncl_add_on) {
tempDepartureCode = "NCL";
tempPrice = priceData.ncl_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
if(priceData.gla_add_on) {
tempDepartureCode = "GLA";
tempPrice = priceData.gla_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
if(priceData.jer_add_on) {
tempDepartureCode = "JER";
tempPrice = priceData.jer_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
}
Price.prototype.hasAddonLocation = function(locationCode) {
var matched = false;
var currentAddon = null;
for(var index = 0; index < this.addonPrices.length; ++index) {
currentAddon = this.addonPrices[index];
if(currentAddon.location == locationCode) {
matched = true;
break;
}
}
return(matched);
}
Price.prototype.getAddonPrice = function(locationCode) {
var returnPrice = null;
var currentAddon = null;
for(var index = 0; index < this.addonPrices.length; ++index) {
currentAddon = this.addonPrices[index];
if(currentAddon.location == locationCode) {
returnPrice = currentAddon;
break;
}
}
return(returnPrice);
}
function AddonPrice(location, price) {
this.location = location;
this.price = price;
}
function WofferOption(title, value) {
this.title = title;
this.value = value;
}
function WofferTable(elementId, wofferData, fromCode, toCode) {
this.elementId = elementId;
this.wofferData = wofferData;
this.fromCode = fromCode;
this.toCode = toCode;
this.footnotes = new Array();
}
WofferTable.prototype.processFromChange = function(element) {
var selectedIndex = 0;
for(var index = 0; index < element.options.length; ++index) {
if(element.options[index].selected) {
this.fromCode = element.options[index].value;
selectedIndex = index;
break;
}
}
var originSelectors = $("select.originSelection");
for(var selectorIndex = 0; selectorIndex < originSelectors.length; ++selectorIndex) {
originSelectors[selectorIndex].options[selectedIndex].selected = true;
}
this.buildOutput();
this.trackChanges();
}
WofferTable.prototype.processToChange = function(element) {
var selectedIndex = 0;
for(var index = 0; index < element.options.length; ++index) {
if(element.options[index].selected) {
this.toCode = element.options[index].value;
selectedIndex = index;
break;
}
}
var destinationSelectors = $("select.destinationSelection");
for(var selectorIndex = 0; selectorIndex < destinationSelectors.length; ++selectorIndex) {
destinationSelectors[selectorIndex].options[selectedIndex].selected = true;
}
this.buildOutput();
this.trackChanges();
}
WofferTable.prototype.processImageToChange = function(element) {
var clickedRegionCode = element.getAttribute("regionCode");
this.toCode = clickedRegionCode
this.buildOutput();
var imageNavItems = $(".imageNav li a");
imageNavItems.removeClass("selected");
clickedRegionCode = clickedRegionCode.toLowerCase();
$(".imageNav li." + clickedRegionCode + " a").addClass("selected");
this.trackChanges();
}
WofferTable.prototype.trackChanges = function()
{
trackingInfo["WOFFERS"] = gButtonType;
trackingInfo["LKDeparturePoint"] = this.fromCode;
trackingInfo["LKDestinationPoint"] = this.toCode;
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
}
WofferTable.prototype.buildOutput = function() {
var priceHTML = "";
var datesHTML = "";
var prices = null;
var currentPrice = null;
var priceType = "";
var tempPrice = 0;
var tempHTML = "";
var rowID;
var foundFootnote = false;
var nonFlightTokens;
this.footnotes.length = 0;
tempHTML = "<table id=\"table1\" cellspacing=\"0\" border=\"1\" summary=\"World offers fares\" style=\"width: 100%;\">\n";
tempHTML += "<thead>\n";
tempHTML += "<tr id=\"table1head\" valign=\"top\" >\n";
for(var index = 0; index < TABLE_HEADERS.length; ++index) {
tempHTML +="<th colspan=\"" + TABLE_HEADERS[index][1] + "\">" + TABLE_HEADERS[index][0] + "</th>\n";
}
tempHTML += "</tr>\n";
tempHTML += "</thead>";
tempHTML += "<tbody id=\"table1body\">";
var matchingWoffers = gWoffersData.getWoffersForLocations(this.fromCode, this.toCode);
var currentWoffer = null;
var tempOption = null;
if(matchingWoffers.length <= 0) {
tempHTML += "<tr><td class=\"noMatchResult\" colspan=\"9\">Sorry, no fares available from ";
tempHTML += getAirportName(this.fromCode) + " to " + getAirportName(this.toCode);
tempHTML += ".</td></tr>\n";
}
else {
matchingWoffers.sort(function(first, second) {
var result = 0;
if((first.originAirport == this.gWofferTable.fromCode) && (second.originAirport != this.gWofferTable.fromCode)) {
result = -1;
}
else if((first.originAirport != this.gWofferTable.fromCode) && (second.originAirport == this.gWofferTable.fromCode)) {
result = 1;
}
else if(first.destinationName < second.destinationName) {
result = -1;
}
else if(first.destinationName > second.destinationName) {
result = 1;
}
return(result);
});
}
for(var index = 0; index < matchingWoffers.length; ++index) {
currentWoffer = matchingWoffers[index];
rowID = "wofferRow" + index;
tempHTML += "<tr id=\"" +rowID + "\">\n";
tempHTML +="<td>";
if(currentWoffer.getOption("optional4")) {
tempHTML += "<img class=\"keyImage\" src=\"/cms/global/assets/images/promotion/uk/sep07woffers/early_deals_icon.gif\" alt=\"E\" title=\"Early deals avaliable for April, May and June travel.\" width=\"12\" height=\"12\" />";
}
tempHTML += currentWoffer.destinationName;
if(currentWoffer.originAirport != this.fromCode) {
tempHTML += "<br /><br />(Via " + getAirportName(currentWoffer.originAirport) + ")";
}
tempHTML += "</td>\n";
currentPrice = currentWoffer.getLowestPrice();
if(currentWoffer.originAirport != this.fromCode) {
tempPrice = parseInt(currentPrice.getAddonPrice(this.fromCode).price);
}
else {
tempPrice = parseInt(currentPrice.price);
}
priceHTML = "<div class=\"leadPrice\">&pound;" + getAdjustedPrice(tempPrice, currentWoffer.priceType);
if(currentWoffer.priceType == RETURN_PRICE_TYPE) {
priceType = " Return"
}
else {
priceType = " one-way";
}
priceHTML += priceType;
priceHTML += "</div>";
datesHTML = "<div class=\"leadDates\">" + currentPrice.outboundFromDate + " - " + currentPrice.outboundToDate + "</div>";
priceHTML += "<div class=\"allPrices\" style=\"display: block;\">";
datesHTML += "<div class=\"allDates\" style=\"display: block;\">";
prices = currentWoffer.prices.prices;
for(var pricesIndex = 0; pricesIndex < prices.length; ++pricesIndex) {
currentPrice = prices[pricesIndex];
if(currentWoffer.originAirport != this.fromCode) {
tempPrice = parseInt(currentPrice.getAddonPrice(this.fromCode).price);
}
else {
tempPrice = parseInt(currentPrice.price);
}
priceHTML += "&pound;" + getAdjustedPrice(tempPrice, currentWoffer.priceType) + priceType + "<br />";
datesHTML += currentPrice.outboundFromDate + " - " + currentPrice.outboundToDate + "<br />";
}
priceHTML += "</div>";
datesHTML += "</div>";
tempHTML += "<td class=\"priceCell\">" + priceHTML + "</td>\n";
tempHTML += "<td class=\"dateCell\">" + datesHTML + "</td>\n";
tempHTML += "<td class=\"twistyCell\">";
if(currentWoffer.prices.prices.length > 1) {
tempHTML += "<a class=\"twistyLink tertiaryLink\" href=\"javascript:WofferTable.openTwisty('" +	rowID +	"');\">" +
"More dates</a>";
}
else {
tempHTML += "&nbsp;";
}
tempHTML += "</td>\n";
tempHTML += "<td class=\"actionCell\">";
tempHTML += "<div class=\"button primary\"><a class=\"arrow\"";
if(isPostPin()) {
tempHTML += "href=\"/main/FX/cugAlias-mc042?source=CUG_mc042&amp;eId=111042&amp;BAHPromo_Code=woffsep07&amp;to=";
}
else {
tempHTML += "href=\"/main/FX?to=";
}
if (gButtonType == "QUOTE"){
tempHTML += currentWoffer.destinationAirport + "&amp;from=" + this.fromCode;
tempHTML += "\">Quote&nbsp;and&nbsp;book</a></div>";
tempHTML += "</td>\n";
}
else {
tempHTML += currentWoffer.destinationAirport + "&amp;from=" + this.fromCode;
tempHTML += "\">Book&nbsp;now</a></div>";
tempHTML += "</td>\n";
}
tempOption = currentWoffer.getOption("optional2");
tempHTML += "<td class=\"option2Cell\">" + tempOption.value + "</td>\n";
tempHTML += "<td class=\"nonFlight\">";
tempOption = currentWoffer.getOption("nonFlight");
nonFlightTokens = tempOption.value.split(":");
if((nonFlightTokens.length > 0) && (nonFlightTokens[0] != "")) {
tempHTML += "<a class=\"tertiaryLink\"  href=\"/main/SEPTEMBER-SALE-MAPS?route=";
if(currentWoffer.originAirport != this.fromCode) {
tempHTML += this.fromCode;
}
else {
tempHTML += currentWoffer.originAirport;
}
tempHTML +=	currentWoffer.regionCode +
"&amp;viapoint=" +
currentWoffer.originAirport +
"&amp;destination=" +
currentWoffer.destinationAirport +
"&amp;source=SEPTEMBER-SALE-LANDING-TABLE" +
"\">" + nonFlightTokens[0] + "</a>";
}
else {
tempHTML += "&nbsp;";
}
tempHTML += "</td>\n";
tempOption = currentWoffer.getOption("nonFlightPrice");
if(tempOption) {
tempHTML += "<td class=\"option1Cell\">";
tempHTML += "&pound;" + getAdjustedHotelPrice(tempOption.value);
}
else {
tempHTML += "<td class=\"option1Cell dissabled\">";
tempHTML += "No hotels available for this destination";
}
tempHTML += "</td>\n";
tempOption = currentWoffer.getOption("optional1");
tempHTML += "<td class=\"option1Cell\">";
if(tempOption) {
tempHTML += tempOption.value.replace(/\s/g,"") + "*";
}
else {
tempHTML += "&nbsp;";
}
tempHTML += "</td>\n";
tempHTML += "</tr>\n";
if(currentWoffer.footnote) {
foundFootnote = false;
for(var footnoteIndex = 0; footnoteIndex < this.footnotes.length; ++footnoteIndex) {
if(this.footnotes[footnoteIndex] == currentWoffer.footnote) {
foundFootnote = true;
}
}
if(!foundFootnote) {
this.footnotes.push(currentWoffer.footnote);
}
}
}
tempHTML += "</tbody>";
tempHTML += "</tbody>\n</table>";
var tempTableId = this.elementId;
document.getElementById("div" + tempTableId).innerHTML = tempHTML;
WofferTable.closeAllTwistys();
document.getElementById("tableSelectionHeading").innerHTML = "Flights from " + getAirportName(this.fromCode) + " to " + getAirportName(this.toCode);
var tempFootnoteHTML = "<p>";
for(var footnoteIndex = 0; footnoteIndex < this.footnotes.length; ++footnoteIndex) {
tempFootnoteHTML += this.footnotes[footnoteIndex] + "<br />";
}
tempFootnoteHTML += "</p>";
$('#footnotes').empty().append(tempFootnoteHTML);
if(this.toCode == "EUR") {
$("#07WoffUpgradeLink").attr({"href":"javascript:popUpScrolling('/main/ba6.jsp/ceexp?source=sep07-woffers-landing', 630, 550);"});
$("#footerUpgradeImg")[0].setAttribute("src", "/cms/global/assets/images/promotion/uk/sep07woffers/save-postpin.gif");
$("#footerUpgradeImg")[0].setAttribute("alt", "Upgrade to Club Europe on flights to Europe, from 59UKP one-way. Experience the benefits.");
}
else {
$("#07WoffUpgradeLink").attr({"href":"javascript:popUpScrolling('/main/ba6.jsp/wtpexp?source=sep07-woffers-landing', 630, 550);"});
$("#footerUpgradeImg")[0].setAttribute("src", "/cms/global/assets/images/promotion/uk/sep07woffers/upgrade.gif");
$("#footerUpgradeImg")[0].setAttribute("alt", "Upgrade to World Traveller Plus from 99UKP one-way on longhaul flights.");
}
}
WofferTable.closeAllTwistys = function() {
var rows = $("#" + DOCUMENT_ELEMENT_ID + " #table1body tr");
for(var rowCount = 0; rowCount < rows.length; ++rowCount) {
WofferTable.closeTwisty(rows[rowCount].id);
}
}
WofferTable.openTwisty = function(wofferRow) {
$("#" + wofferRow + " .leadPrice")[0].style.display="none";
$("#" + wofferRow + " .leadDates")[0].style.display="none";
$("#" + wofferRow + " .allPrices")[0].style.display="block";
$("#" + wofferRow + " .allDates")[0].style.display="block";
var tempTarget = "javascript:WofferTable.closeTwisty('" + wofferRow + "');";
$("#" + wofferRow + " .twistyLink").attr({"href":tempTarget});
$("#" + wofferRow + " .twistyLink").text("Best price");
}
WofferTable.closeTwisty = function(wofferRow) {
if($("#" + wofferRow + " .allPrices").length > 0) {
$("#" + wofferRow + " .allPrices")[0].style.display="none";
}
if($("#" + wofferRow + " .allDates").length > 0) {
$("#" + wofferRow + " .allDates")[0].style.display="none";
}
if($("#" + wofferRow + " .leadPrice").length > 0) {
$("#" + wofferRow + " .leadPrice")[0].style.display="block";
}
if($("#" + wofferRow + " .leadDates").length > 0) {
$("#" + wofferRow + " .leadDates")[0].style.display="block";
}
var tempTarget = "javascript:WofferTable.openTwisty('" + wofferRow + "');";
$("#" + wofferRow + " .twistyLink").attr({"href":tempTarget});
$("#" + wofferRow + " .twistyLink").text("More dates");
}
function getAirportName(airportCode) {
var airportName = "";
for(var locationIndex = 0; locationIndex < LOCATIONS.length; ++locationIndex) {
if(LOCATIONS[locationIndex][0] == airportCode) {
airportName = LOCATIONS[locationIndex][1];
break;
}
}
return(airportName);
}
function isPostPin() {
var isPostpin = false;
if(document.nav_form.logintype.value != 'public') {
isPostpin = true;
}
return(isPostpin);
}
function getAdjustedPrice(originalPrice, priceType) {
var tempPrice = originalPrice;
if(isPostPin()) {
switch(priceType) {
case ONEWAY_PRICE_TYPE: {
tempPrice = parseInt(tempPrice) - parseInt(ONEWAY_PRICE_POSTPIN_DISCOUNT);
break;
}
case RETURN_PRICE_TYPE: {
tempPrice = parseInt(tempPrice) - parseInt(RETURN_PRICE_POSTPIN_DISCOUNT);
break;
}
}
}
return(tempPrice);;
}
function getAdjustedHotelPrice(price) {
var tempPrice = parseFloat(price);
if(isPostPin()) {
var discount = HOTEL_PRICE_POSTPIN_DISCOUNT;
if(discount) {
discount = tempPrice * (parseFloat(discount) / 100);
tempPrice -= discount;
}
}
return Math.ceil(tempPrice);
}
function initLocations() {
var currentSelection = null;
var currentOption = null;
var suppliedFrom = getQueryValue("from").toUpperCase();
var suppliedTo = getQueryValue("to").toUpperCase();
if(suppliedFrom != "NOT FOUND") {
var originSelectors = $("select.originSelection");
for(var selectorIndex = 0; selectorIndex < originSelectors.length; ++selectorIndex) {
currentSelection = originSelectors[selectorIndex];
for(var originOptionsIndex = 0; originOptionsIndex < currentSelection.options.length; ++originOptionsIndex) {
currentOption = currentSelection.options[originOptionsIndex];
if(currentOption.value.toUpperCase() == suppliedFrom) {
currentOption.selected = true;
break;
}
}
}
}
if(suppliedTo != "NOT FOUND") {
var destinationSelectors = $("select.destinationSelection");
for(var selectorIndex = 0; selectorIndex < destinationSelectors.length; ++selectorIndex) {
currentSelection = destinationSelectors[selectorIndex];
for(var destinationOptionsIndex = 0; destinationOptionsIndex < currentSelection.options.length; ++destinationOptionsIndex) {
currentOption = currentSelection.options[destinationOptionsIndex];
if(currentOption.value.toUpperCase() == suppliedTo) {
currentOption.selected = true;
break;
}
}
}
}
}
function initPageType() {
gPageType = "PODS";
gButtonType = getCookie("woffersButtonType");
if(gButtonType == "")
{
gButtonType = getQueryValue("campaign").toUpperCase();
if(gButtonType == "DROP") {
gButtonType = "BOOK"
}
if(gButtonType == "PODS") {
gButtonType = "QUOTE"
}
}
if(gButtonType != "BOOK" && gButtonType != "QUOTE")
{
gButtonType = "QUOTE";
}
setCookie("woffersButtonType", gButtonType);
$(".destinationSelectDiv").hide();
$(".drop").hide();
if(gButtonType == "BOOK") {
$("#quoteHeader").hide();
}
if(gButtonType == "QUOTE") {
$("#bookHeader").hide();
}
trackingInfo["WOFFERS"] = gButtonType;
trackingInfo["LKDeparturePoint"] = gFromCode;
trackingInfo["LKDestinationPoint"] = gToCode;
}
function getCookie(cName)
{
if (document.cookie.length>0)
{
cStart=document.cookie.indexOf(cName + "=");
if(cStart!=-1)
{
cStart = cStart + cName.length + 1;
cEnd = document.cookie.indexOf(";",cStart);
if(cEnd==-1)
{
cEnd = document.cookie.length;
}
return unescape(document.cookie.substring(cStart,cEnd));
}
}
return "";
}
function setCookie(cName,cValue)
{
document.cookie = cName + "=" + escape(cValue);
}
