
var SOURCE_TYPE = "json";
var DOCUMENT_ELEMENT_ID = "tableDiv"
var ONEWAY_PRICE_POSTPIN_DISCOUNT = 0;
var RETURN_PRICE_POSTPIN_DISCOUNT = 10;
var HOTEL_PRICE_POSTPIN_DISCOUNT = 0;
var ONEWAY_PRICE_TYPE = "ow";
var RETURN_PRICE_TYPE = "rt";
var TABLE_HEADERS = [["Destination", "1"],
["Price", "1"],
["Travel dates <span class=\"normalText\"><br />Click <img src=\"/cms/global/assets/images/promotion/uk/jan08woffers/twisty-closed.gif\" width=\"9\" height=\"9\" alt=\"Plus sign.\" /> to show more dates</span>", "2"],
["Stops", "1"],
["Upgrades <span class=\"normalText\"><span class=\"noWrap\">one-way</span> from</span>", "1"],
["Hotels <span class=\"normalText\">pppn from</span>", "1"],
["Car rental  <span class=\"normalText\">per&nbsp;day from</span>", "1"]];
var LOCATIONS = [["CITY", "City destinations", "", "", "CITY"],
["FLYDRIVE", "Fly-Drive destinations", "", "", "FLYDRIVE"],
["SUN", "Sunny destinations", "", "", "SUN"]
];
var VALID_TYPES = ["CITY",
"SUN",
"FLYDRIVE"];
var gWofferTable = null;
var gPageType = "";
var gFromCode = "";
var gToCode = "";
$(pageSetup);
function pageSetup() {
try {
setPageType("TYPES");
gWofferTable = new WofferTable(DOCUMENT_ELEMENT_ID, gFromCode, gToCode);
switch(gToCode) {
case "SUN": {
$(".cityTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".sunTable").show();
break;
}
case "CITY": {
$(".sunTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".cityTable").show();
break;
}
case "FLYDRIVE": {
$(".cityTable:visible").hide();
$(".sunTable:visible").hide();
$(".flydriveTable").show();
break;
}
default: {
$(".cityTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".sunTable").show();
break;
}
}
$(".typeNavigation a").click(function() {gWofferTable.processTypeChangeEvent(this);});
}
catch(e) {
alert(e.toString());
}
}
function setPageParameters() {
gPageType = getCookie("bahjan08");
var sourceType = getQueryValue("source").toUpperCase();
if((gPageType == "") || (sourceType == "ED")) {
gPageType = getQueryValue("campaign").toUpperCase();
}
if((gPageType != "REGIONS") && (gPageType != "TYPES") && (gPageType != "POPULAR") && (gPageType != "PRICES"))
{
var pageType = "TYPES";
gPageType = "TYPES";
}
setCookie("bahjan08", gPageType);
gToCode = getQueryValue("to").toUpperCase();
var foundType = false;
if(gToCode) {
for(var typeIndex = 0; typeIndex < VALID_TYPES.length; ++typeIndex) {
if(VALID_TYPES[typeIndex] == gToCode) {
foundType = true;
break;
}
}
}
if(!foundType) {
gToCode = "SUN";
}
trackingInfo["JANSALE1"] = gPageType;
trackingInfo["LKDeparturePoint"] = gFromCode;
trackingInfo["JANSALE2"] = gToCode;
trackingInfo["pageidextra"] = gPageType + "-" + gToCode;
}
function setPageType(pageType) {
gPageType = "TYPES";
var imageNavItems = $(".typeNavigation li a");
imageNavItems.removeClass("selected");
$(".typeNavigation li." + gToCode.toLowerCase() + " a").addClass("selected");
}
function initLocations() {
var suppliedFrom = getQueryValue("from").toUpperCase();
var suppliedTo = getQueryValue("to").toUpperCase();
if(suppliedFrom != "NOT FOUND") {
var matchedDepartureLocations = $("select.departureSelection  option[@value='" + suppliedFrom + "']");
if(matchedDepartureLocations) {
matchedDepartureLocations[0].selected = true;
}
}
gFromCode = $("#departureSelection option[@selected]")[0].value;
gToCode = $(".typeNavigation li a.selected")[0].getAttribute("regionCode");
}
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;
}
else if(wofferData.destinations) {
this.destinationName = wofferData.destinations;
}
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));
}
}
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.valueFare = false;
this.outboundFromDate = "";
this.outboundToDate = "";
this.addonPrices = new Array();
if(priceData.fare_info && (priceData.fare_info.toUpperCase().search("VALUE") != -1)) {
this.valueFare = true;
}
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)));
}
if(priceData.bfs_add_on) {
tempDepartureCode = "BFS";
tempPrice = priceData.bfs_add_on.replace(/\,/g, '');
this.addonPrices.push(new AddonPrice(tempDepartureCode, Math.round(tempPrice)));
}
}
function AddonPrice(location, price) {
this.location = location;
this.price = price;
}
function WofferOption(title, value) {
this.title = title;
this.value = value;
}
function WofferTable(elementId, fromCode, toCode) {
this.elementId = elementId;
this.fromCode = fromCode;
this.toCode = toCode;
this.footnotes = new Array();
this.includeNonSale = false;
}
WofferTable.prototype.processTypeChangeEvent = function(element) {
var clickedRegionCode = element.getAttribute("regionCode");
this.toCode = clickedRegionCode;
var imageNavItems = $(".typeNavigation li a");
imageNavItems.removeClass("selected");
clickedRegionCode = clickedRegionCode.toLowerCase();
$(".typeNavigation li." + clickedRegionCode + " a").addClass("selected");
switch(clickedRegionCode) {
case "sun": {
$(".cityTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".sunTable").show();
break;
}
case "city": {
$(".sunTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".cityTable").show();
break;
}
case "flydrive": {
$(".cityTable:visible").hide();
$(".sunTable:visible").hide();
$(".flydriveTable").show();
break;
}
default: {
$(".cityTable:visible").hide();
$(".flydriveTable:visible").hide();
$(".sunTable").show();
break;
}
}
}
WofferTable.prototype.trackChanges = function()
{
trackingInfo["JANSALE1"] = gPageType;
trackingInfo["LKDeparturePoint"] = this.fromCode;
trackingInfo["JANSALE2"] = this.toCode;
trackingInfo["pageidextra"] = gPageType + "-" + this.toCode;
document.getElementById("t-tracking-fragment").innerHTML = vsDoTracking();
}
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)
{
var expireDate = new Date();
expireDate.setFullYear(expireDate.getFullYear() + 1);
document.cookie = cName + "=" + escape(cValue) + "; expires=" + expireDate;
}

