//pricing options variables
var hotelPriceOptionsIdStartingValue = 0;
var hideProductPriceOptionsText = 'Hide price options';
var showProductPriceOptionsText = 'More price options';
var hidePagePriceOptionsText = 'Hide price options';
var showPagePriceOptionsText = 'View all price options';
var displayAllPricingOptions = true;
var CASH_JOURNEY_TYPE = "cash";
var REDEMPTION_JOURNEY_TYPE = "redemption";
var globalShowHideValue = '';
var PRICE_PREFIX = '<div class="pricePrefixOr" >';
var EMPTY_PREFIX = '<div class="pricePrefixClear"> ';
var CASH_PRICE = 0;
var MILES_PRICE = 1;
var PARTCASH_PRICE_ONE = 2;
var PARTCASH_PRICE_TWO = 3;
var resultBoolean = true;
var resultString  = "";

var displayGlobalSwitch = false;

var hideMilesBack = false;

//This object is used to display the total prices for all the rooms in a hotel. It includes a function for printing out
//the prices and relies on the the data passed into the constructor to extact all the prices. These should be in the
//order to be displayed. The consturctor accepts an array of pricing options for the hotel as well as a cash miles back award
//to display for the full cash price
function HotelPriceOptionsDisplayer(totalPricesArray, cashMilesBackAward, isWizard, journeyType, displaySwitches, showAllPricesOnLoad)
{
    this.prices = totalPricesArray;
    this.cashMilesBackAward = cashMilesBackAward;
    this.journeyType = journeyType;
    this.displaySwitches = displaySwitches;
    this.showAllPricesOnLoad = showAllPricesOnLoad;
    this.hotelPriceOptionsID = hotelPriceOptionsIdStartingValue++;
}

HotelPriceOptionsDisplayer.prototype.dontShowMilesBack = function(hideMilesBack)
{
  this.hideMilesBack = hideMilesBack;
}

//This function is used to print out the price options. All the data is extracted from the array passed into the
//constructor
HotelPriceOptionsDisplayer.prototype.displayTotalPrices = function()
{
  var str = '<div class="price"><ul>';
  var blankSpace = "";

  //set up flags to indicate what types of prices are available for this passenger, which can then be used later to determine which prices need to be inside the switch
  //and whether the switch should be made available for this passenger.
  var cashOnlyPriceFound=false;
  var milesOnlyPriceFound=false;
  var partCashPriceFound=false
  var partCashPrice2Found=false
  //var cashOnlyOrMilesOnlyPriceFound = false;
	var partCashOrMilesOnlyPriceFound = false;

    for ( var i = 0 ; i < this.prices.length ; i++ )
  	{
  	  var priceOption = this.prices[i];

	    if ( priceOption != undefined){

	    var milesPriceOption = priceOption[1];
        var cashPriceOption = priceOption[2];

        var theMiles = autotab_displayCash(milesPriceOption,false);
        var theCash = autotab_displayCash(cashPriceOption,true);

        if ( cashPriceOption == 0 && milesPriceOption != 0){
          milesOnlyPriceFound=true;

        }else if (cashPriceOption != 0 && milesPriceOption == 0 ){
          cashOnlyPriceFound=true;

        }else if (cashPriceOption != 0 && milesPriceOption != 0 ){
          if (partCashPriceFound){
            partCashPrice2Found=true;
          }
          partCashPriceFound=true;

        }else{
          //invalid price, will not be displayed.
        }

      }
    } //end for

  partCashOrMilesOnlyPriceFound = partCashPriceFound || milesOnlyPriceFound;

  var pricesDisplayStyle = "none";

  if (this.showAllPricesOnLoad!=null && this.showAllPricesOnLoad){
    pricesDisplayStyle = "";
  }

  var partCashPriceCount = 0;

  var firstLineDisplayed = false;

  for ( var counter = 0 ; counter < this.prices.length ; counter++ )
  {
    var priceOption = this.prices[counter];

    if ( priceOption != undefined )
    {
      var milesPriceOption = priceOption[1];
      var cashPriceOption = priceOption[2];

      var theMiles = autotab_displayCash(milesPriceOption,false);
      var theCash = autotab_displayCash(cashPriceOption,true);

      var milesOnlyStyle = "";
      var cashOnlyStyle = "";

      if (this.journeyType=='redemption') {
        milesOnlyStyle='txtBoldBlu';
      } else {
        cashOnlyStyle='txtBoldBlu';
      }

      if ( !( cashPriceOption == 0 && milesPriceOption == 0)) {
        if (cashPriceOption == 0) {
          if (this.journeyType==REDEMPTION_JOURNEY_TYPE) {
            str += '<li class="miles">' + theMiles +' miles</li>';
            firstLineDisplayed = true;
          }
        }
        else if ( cashPriceOption != 0 && milesPriceOption != 0) {

          var showPriceSwitchForJourney = false;
          partCashPriceCount = partCashPriceCount+1;

          if ( this.journeyType==CASH_JOURNEY_TYPE && partCashOrMilesOnlyPriceFound
            || this.journeyType==REDEMPTION_JOURNEY_TYPE && (milesOnlyPriceFound || cashOnlyPriceFound) ){
            showPriceSwitchForJourney = true;
          }

          var partCashPriceType;
          if (partCashPriceCount==1) {
            partCashPriceType=PARTCASH_PRICE_ONE;
          } else {
            partCashPriceType=PARTCASH_PRICE_TWO;
          }

          if(this.journeyType==CASH_JOURNEY_TYPE) {
            str +=  '<li';

			if (firstLineDisplayed == false) {
				str += ' class="part"';
			}

			str += ' id="priceOptions_'+this.hotelPriceOptionsID+'_'+counter+'">"';
            if (firstLineDisplayed == true) {
              str +=  'or&nbsp;';
            } else {
              firstLineDisplayed = true;
            }
            str +=  '&pound;' + theCash +
                    ' + ' +
                    theMiles +
                    ' miles' +
                    '</li>';
          } else {
            str +=  '<li';

			if (firstLineDisplayed == false) {
				str += ' class="part"';
			}

			str += ' id="priceOptions_'+this.hotelPriceOptionsID+'_'+counter+'">';
            if (firstLineDisplayed == true) {
              str +=  'or&nbsp;';
            } else {
              firstLineDisplayed = true;
            }
            str +=  theMiles +
                    ' miles ' +
                    '+ ' +
                    '&pound;' +
                    theCash + '</li>';
          }
        } else {
          if(!(isWizard)) {
            if(this.journeyType==CASH_JOURNEY_TYPE) {
              str += '<li class="cash">&pound;' + theCash + ' ';
              if (!this.hideMilesBack) {
                str += '<span class="back">(<a href="collect/milesback/collect-miles-on-your-travel">&amp; receive ' +cashMilesBackAward+'  miles</a>)</span>'
              }
              str += '</li>';
            } else {
              str += '<li';
              if (firstLineDisplayed == true) {
                str +=  '>or&nbsp;';
              } else {
				str += ' class="part">';
                firstLineDisplayed = true;
              }
              str += '&pound;' + theCash;
              if (!this.hideMilesBack) {
                str += ' (<a href="collect/milesback/collect-miles-on-your-travel" target="_blank"><span class="back">&amp; receive ' +cashMilesBackAward+'  miles</span></a>)';
              }
              str += '</li>';
            }
          } else {
            str += '<li';
            if (firstLineDisplayed == true) {
              str +=  '>or&nbsp;';
            } else {
			  str += ' class="part">';
              firstLineDisplayed = true;
            }
            str += '&pound;' + theCash;
            if (!this.hideMilesBack) {
              str += ' <span class="back">(<a href="#">&amp; receive ' +cashMilesBackAward+'  miles</a>)';
            }
            str += '</li>';
          }
        }
      }
    }
  }

  str += '</ul>';
  str += '<div class="clear">&nbsp;</div>';

  var showPriceSwitchForJourney = false;

  if (this.journeyType==CASH_JOURNEY_TYPE){
      if (partCashOrMilesOnlyPriceFound){
        showPriceSwitchForJourney  = true;
      }
  }else{ //assume redemption
    if ( (milesOnlyPriceFound || cashOnlyPriceFound) && partCashPriceFound){
      showPriceSwitchForJourney  = true;
    }
  }

  if(this.displaySwitches && showPriceSwitchForJourney){
    var switchText = "";
    if (this.showAllPricesOnLoad){
      switchText=hideProductPriceOptionsText;
    }else{
      switchText=showProductPriceOptionsText;
    }
//    str +='</div><img src="/images/button/LNK_arrowPNK.gif" border="0">&nbsp;<a href="javascript:void(0);" onclick="showOrHideHotelPrices(\''+this.hotelPriceOptionsID+'\'); return(false);"><span id="priceSwitchText_'+this.hotelPriceOptionsID+'">'+switchText+'</span></a>'
    displayGlobalSwitch = true;
  }

  str +='<p class="tax">Prices include local taxes and services</p>';


  str += "</div>";
  return str;
}

function showOrHideHotelPrices(hotelPriceOptionsID) {
    var arePricesVisible = false;

    for (var i = 0; i < 4; i++) {

        priceOptions = document.getElementById('priceOptions_' + hotelPriceOptionsID + '_' + i);
        pricePrefix = document.getElementById('pp_' + hotelPriceOptionsID + '_' + i);

        if (priceOptions != null && priceOptions != undefined) {
            if (priceOptions.style.display == "") {
                priceOptions.style.display = "none";
                arePricesVisible = false;
            } else {
                priceOptions.style.display = "";
                arePricesVisible = true;
            }
        }

        if (pricePrefix != null && pricePrefix != undefined) {
            if (pricePrefix.style.display == "" || pricePrefix.style.display == "inline") {
                pricePrefix.style.display = "none";
            } else {
                pricePrefix.style.display = "";
            }
        }
    }

    priceSwitchText = document.getElementById('priceSwitchText_' + hotelPriceOptionsID);
    if (arePricesVisible) {
        priceSwitchText.innerHTML = hideProductPriceOptionsText;
    } else {
        priceSwitchText.innerHTML = showProductPriceOptionsText;
    }

}

function showElement(elementID, makeVisible) {
    if (document.getElementById) {
        obj = document.getElementById(elementID);
        style = "";
        if (makeVisible == false) {
            style = "none";
        }
        if (obj != null) {
            obj.style.display = style;
        }
    }
}

function findElementByTagAndId(elementTag, idPrefix) {
    var elementFound = false;

    if (!document.getElementsByTagName) {
        return elementFound;
    }

    arrElements = document.getElementsByTagName(elementTag);

    for (i = 0; i < arrElements.length; i++) {
        element = arrElements[i];
        elementID = element.getAttribute('id');
        if (elementID != null && elementID.substr(0, idPrefix.length) == idPrefix) {
            elementFound = true;
        }
    }

    return elementFound;
}

function showOrHideAllElementsById(elementType, prefix, showElements) {
    var elementFound = false;
    if (!document.getElementsByTagName) {
        return elementFound;
    }

    arr_elements = document.getElementsByTagName(elementType);

    for (i = 0; i < arr_elements.length; i++) {
        element = arr_elements[i];
        elementID = element.getAttribute('id');
        if (elementID != null && elementID.substr(0, prefix.length) == prefix) {
            showElement(elementID, showElements);
            elementFound = true;
        }
    }
    return elementFound;
}

function setTextForAllElementsById(elementType, prefix, text) {
    var elementFound = false;
    if (!document.getElementsByTagName) {
        return elementFound;
    }

    arr_elements = document.getElementsByTagName(elementType);

    for (i = 0; i < arr_elements.length; i++) {
        element = arr_elements[i];
        elementID = element.getAttribute('id');
        if (elementID != null && elementID.substr(0, prefix.length) == prefix) {
            element.innerHTML = text;
            elementFound = true;
        }
    }
    return elementFound;
}

function showOrHideAllHotelPricingOptions() {

    resultBoolean = showOrHideAllElementsById('li', 'priceOptions_', !displayAllPricingOptions);
    showOrHideAllElementsById('li', 'pp', !displayAllPricingOptions);

    if (resultBoolean) {
        displayAllPricingOptions = !displayAllPricingOptions;
    }
    setPageAndProductPricingSwitchText(displayAllPricingOptions);

    if (displayAllPricingOptions) {
        globalShowHideValue = "show";
    } else {
        globalShowHideValue = "hide";
    }

}

function setGlobalSwitchVisibility() {
    var showGlobalSwitch = findElementByTagAndId("span", "priceSwitchText_");
    showElement("showOrHidePricingOptionsElement", showGlobalSwitch);
}

PaneValue.prototype.debug = function()
{
    return("{panevalue:ref=" + this.ref + ";miles=" + this.miles + ";cash=" + this.miles + "}")
}

// Data, single item
function PaneValue(ref, miles, cash, milesBack)
{
    this.miles = miles
    this.cash = cash
    this.ref = ref
    this.milesBack = milesBack
}

function Pane(ref, count, taxes, arrayData, tabBlock)
{
    this.ref = ref
    this.count = count
    this.taxes = taxes;

    var dataArray = new Array(arrayData.length);
    for (var ii = 0; ii < arrayData.length; ii++)
    {
        var paneValueData = arrayData[ii];
        dataArray[ii] = new PaneValue(paneValueData[0], paneValueData[1], paneValueData[2], paneValueData[3]);
        this[dataArray[ii].ref] = dataArray[ii];
    }
    this.values = dataArray;
    this.tabBlock = tabBlock;
}

Pane.prototype.debug = function()
{
    var ret = "{pane:ref=" + this.ref + ";count=" + this.count + ";vals="
    for (var ii = 0; ii < this.values.length; ii++)
    {
        ret += this[this.values[ii].ref].debug()
    }
    ret = ret + "}"
    return( ret );
}


// Data, multiple panes, each in a tab
function TabBlock(arrayData, milesBack)
{
    this.ref = arrayData[0];
    this.milesBack = milesBack;
    var dataArray = new Array(arrayData.length - 1);
    var totals = new Object();
    var totalTax = 0;
    for (var ii = 1; ii < arrayData.length; ii ++)
    {
        var paneData = arrayData[ii];
        var newPane = new Pane(paneData[0], paneData[1], paneData[2], paneData[3], this);
        // sum the tax for individual panes
        totalTax += paneData[1] * paneData[2];
        dataArray[ii - 1] = newPane;
        this[dataArray[ii - 1].ref] = newPane;
        for (var jj = 0; jj < newPane.values.length; jj++)
        {
            var paneData = newPane.values[jj];
            var sumData = totals[paneData.ref];
            if (sumData === undefined)
            {
                sumData = [paneData.ref,0,0,0];
                totals[paneData.ref] = sumData;
            }
            sumData[1] += paneData.miles * newPane.count;
            sumData[2] += paneData.cash * newPane.count;
            sumData[3] += paneData.milesBack * newPane.count;
        }
    }

    // Add total tab
    var totalList = new Array();
    for (var ii in totals)
    {
        totalList.push(totals[ii]);
    }
    var totalsTab = new Pane("total", 0, totalTax, totalList, this);
    this["total"] = totalsTab;
    dataArray.push(totalsTab);
    this.values = dataArray
}

TabBlock.prototype.dontShowMilesBack = function (hideMilesBack)
{
  this.hideMilesBack = hideMilesBack;
}

TabBlock.prototype.debug = function()
{
    var ret = "{tabblock:values="
    for (var ii = 0; ii < this.values.length; ii++)
    {
        ret += this[this.values[ii].ref].debug()
    }
    ret = ret + "}"
    return( ret );
}


// Layouts

// Layout for a single pane

function PaneLayout(ref, title)
{
    this.ref = ref;
    this.title = title;
}

// Layout for a tabed block of panes
function TabBlockLayout(ref, paneRefArray, itemRefArray)
{
    this.ref = ref
    this.paneRefArray = paneRefArray
    this.itemRefArray = itemRefArray
    this.enclosingTableStyle = "";
    this.titleStyle = ' style="text-align: left"';
}

// Factory functions for standard layouts
PaneLayout.stockLayouts = new Object();

PaneLayout.stockLayouts["Double"] = new PaneLayout("Double", "Prices per room");
PaneLayout.stockLayouts["Twin"] = new PaneLayout("Twin", "Prices per room");
PaneLayout.stockLayouts["Single"] = new PaneLayout("Single", "Prices per room");
PaneLayout.stockLayouts["Triple"] = new PaneLayout("Triple", "Prices per room");
PaneLayout.stockLayouts["Quad"] = new PaneLayout("Quad", "Prices per room");
PaneLayout.stockLayouts["adult"] = new PaneLayout("adult", "Prices per person (return)");
PaneLayout.stockLayouts["child"] = new PaneLayout("child", "Prices per child (return)");
PaneLayout.stockLayouts["infant"] = new PaneLayout("infant", "Prices per infant (return)");

PaneLayout.HOTEL_TOTAL = new PaneLayout("total", "Total price for all rooms");
PaneLayout.FLIGHT_TOTAL = new PaneLayout("total", "Total for all travellers (return)");
PaneLayout.OFFER_PERSON = new PaneLayout("perperson", "Prices per person (return)");
PaneLayout.OFFER_TOTAL = new PaneLayout("total", "Total for all travellers (return)");

TabBlockLayout.CASH_TYPES = ["MILES","PARTCASH","PARTCASH2","CASH"];
TabBlockLayout.OFFER_CASH_TYPES = ["COST0","COST1","COST2","COST3"];

TabBlockLayout.FLIGHT = "flight";
TabBlockLayout.HOTEL = "hotel";
TabBlockLayout.OFFER = "offer";

TabBlockLayout.OFFER_LAYOUT = new TabBlockLayout(TabBlockLayout.OFFER, [PaneLayout.OFFER_PERSON,PaneLayout.OFFER_TOTAL], TabBlockLayout.OFFER_CASH_TYPES);

function setTabBlockLayoutCashTypes(journeyType) {

    if (journeyType != undefined && journeyType != null) {
        if (journeyType == CASH_JOURNEY_TYPE) {
            TabBlockLayout.CASH_TYPES = ["MILES","PARTCASH","PARTCASH2","CASH"];
        } else {
            TabBlockLayout.CASH_TYPES = ["CASH", "PARTCASH2", "PARTCASH", "MILES"];
        }
    } else {
        TabBlockLayout.CASH_TYPES = ["CASH", "PARTCASH2", "PARTCASH", "MILES"];
    }

}

// Builds a layout given one or two room types
TabBlockLayout.buildHotelLayout = function(roomType1, roomType2)
{
    var hotelLayout;
    if (roomType2 === undefined)
        hotelLayout = new TabBlockLayout(TabBlockLayout.HOTEL, [PaneLayout.stockLayouts[roomType1],PaneLayout.HOTEL_TOTAL], TabBlockLayout.CASH_TYPES);
    else
        hotelLayout = new TabBlockLayout(TabBlockLayout.HOTEL, [PaneLayout.stockLayouts[roomType1],PaneLayout.stockLayouts[roomType2],PaneLayout.HOTEL_TOTAL], TabBlockLayout.CASH_TYPES);

    return( hotelLayout );
}

// Builds a layout given one, two or three passenger types
TabBlockLayout.buildFlightLayout = function(passengerTypeList, journeyType)
{
    var layoutData = new Array();

    for (var ii = 0; ii < passengerTypeList.length; ii++) {
        layoutData.push(PaneLayout.stockLayouts[passengerTypeList[ii]]);
    }

    layoutData.push(PaneLayout.FLIGHT_TOTAL);

    setTabBlockLayoutCashTypes(journeyType);

    return( new TabBlockLayout(TabBlockLayout.FLIGHT, layoutData, TabBlockLayout.CASH_TYPES) );
}

// Builder Objects to show given data, in the form set by the given layout

// Incremetor for pane names
var nameCounter = 101;

// Mapping of individual panes by name
var panes = new Object();

// callback when a tab button is pressed
function switchOnTab(tabName, bHighLightTab)
{
    var thePane = panes[tabName];
    thePane.switchTo(bHighLightTab);
    if (thePane.tabBlockBuilder.allPricesDisplayed) {
        setProductPriceOptionsSwitchText('priceSwitchText_' + tabName, true);
    } else {
        setProductPriceOptionsSwitchText('priceSwitchText_' + tabName, false);
    }
}

function showOrHide(paneID) {
    if (document.getElementById) {

        var thePane = panes[paneID];
        var arePricesVisible = false;
        for (var i = 0; i < 3; i++) {

            priceID = paneID + '_' + i;
            obj = document.getElementById('po_' + priceID);

            objPricePrefix = document.getElementById('pp_' + priceID);
            if (obj != null && obj != undefined) {
                if (obj.style.display == "none") {
                    obj.style.display = "";
                    arePricesVisible = true;
                } else {
                    obj.style.display = "none";
                    arePricesVisible = false;
                }
            }
            if (objPricePrefix != null && objPricePrefix != undefined) {
                if (objPricePrefix.style.display == "none") {
                    objPricePrefix.style.display = "";
                } else {
                    objPricePrefix.style.display = "none";
                }
            }

        }

        thePane.tabBlockBuilder.allPricesDisplayed = arePricesVisible;
        setProductPriceOptionsSwitchText('priceSwitchText_' + paneID, arePricesVisible);

    }
}

function setProductPriceOptionsSwitchText(id, pricesDisplayed) {
    priceSwitch = document.getElementById(id);
    var text = '';
    if (pricesDisplayed) {
        text = hideProductPriceOptionsText;
    } else {
        text = showProductPriceOptionsText;
    }
    if (priceSwitch != undefined && priceSwitch != null) {
        priceSwitch.innerHTML = text;
    }
}


function showOrHideAllPricingOptions() {
    resultBoolean = showOrHideAllElementsById('div', 'po', !displayAllPricingOptions);
    showOrHideAllElementsById('div', 'pp', !displayAllPricingOptions);

    if (resultBoolean) {
        displayAllPricingOptions = !displayAllPricingOptions;
    }

    if (displayAllPricingOptions) {
        globalShowHideValue = "show";
    } else {
        globalShowHideValue = "hide";
    }

    var tabBlockBuilderArray = flightPriceGroup.tabBlockBuilderArray;

    for (var i = 0; i < tabBlockBuilderArray.length; i++) {
        var tabBlock = tabBlockBuilderArray[i];

        if (tabBlock != null && tabBlock !== undefined) {
            tabBlock.allPricesDisplayed = displayAllPricingOptions;
        }
    }
    setPageAndProductPricingSwitchText(displayAllPricingOptions);
}

function setPageAndProductPricingSwitchText(displayAllPricingOptions) {
    if (displayAllPricingOptions) {
        document.getElementById("showOrHidePricingOptions").innerHTML = hidePagePriceOptionsText;
        setTextForAllElementsById('span', 'priceSwitchText', hideProductPriceOptionsText);
    } else {
        document.getElementById("showOrHidePricingOptions").innerHTML = showPagePriceOptionsText;
        setTextForAllElementsById('span', 'priceSwitchText', showProductPriceOptionsText);
    }
}

// holds builder data for a single pane (tab)
function TabPaneBuilder(tabBlockBuilder, paneLayout, isWizard, paneData, highLight, journeyType, displaySwitches, showAllPricesOnLoad)
{
    this.highLight = false;

    if (highLight != null && highLight != undefined) {
        this.highLight = highLight;
    }
    this.journeyType = journeyType;
    this.displaySwitches = displaySwitches;
    //determines whether pricing switches should be displayed for this tab (pane)
    this.showAllPricesOnLoad = showAllPricesOnLoad;
    //determines the default visibility of pricing options.
    this.tabBlockBuilder = tabBlockBuilder;
    //reference to the parent tab control.
    this.paneLayout = paneLayout;
    this.paneData = null;
    this.titleData = null;
    this.FQN = "pane" + nameCounter++;
    panes[this.getFQN()] = this;
}

// get the pane name
TabPaneBuilder.prototype.getFQN = function()
{
    return( this.FQN );
}

//layoutContent implementation with additional highLighting arguments
TabPaneBuilder.prototype.layoutHighlightContent = function(bHighLight)
{
    if (this.tabBlockBuilder.off) {
        return( this.tabBlockBuilder.offMessage );
    }
    this.hideMilesBack = this.tabBlockBuilder.hideMilesBack;

    var str = "";
    var tabs = "";

    str += '<table border="0" cellpadding="0" cellspacing="0"  width="140"' + this.tabBlockBuilder.tabBlockLayout.enclosingTableStyle + '>'
    str += '<tr><td valign="top" align="right" style="background-color:#ffffff;height:24px;" >'

    for (var ii = 0; ii < this.tabBlockBuilder.tabPanes.length; ii++)
    {
        var tabPane = this.tabBlockBuilder.tabPanes[ii];
        // the tab images are placed INSIDE the optionsContainer and then pulled up so that the selected image
        // flows over the top margin giving the impression of the currently selected tab
        if (tabPane == this) {
            tabs += '<img SRC="/images/tabs/tab_' + tabPane.paneLayout.ref.toLowerCase() + '_on.gif" border="0" style="position:absolute;margin:-24px -1px 0 0;right:' + (this.tabBlockBuilder.tabPanes.length - ii - 1) * 45 + 'px;">';
        } else {
            tabs += '<a href="javascript:void(0);" onClick="switchOnTab(' + "'" + tabPane.getFQN() + "'" + ',' + bHighLight + ');">' + '<img SRC="/images/tabs/tab_' + tabPane.paneLayout.ref.toLowerCase() + '_off.gif" border="0" style="position:absolute;margin:-24px -1px 0 0;right:' + (this.tabBlockBuilder.tabPanes.length - ii - 1) * 45 + 'px;">' + '</a>'
        }
    }

    str += '</td></tr><tr><td valign="top" colspan="4"><div id="optionsContainer" style="position:relative;width:180px; border:1px solid #FFDA6D; border-bottom:0px;">' + tabs;

    // Single item start
    str += '<table border="0" cellpadding="0" cellspacing="0" width="100%" class="homesearchBG">';
    str += '<tr><td valign="top" class="cashMilesBox" colspan="4"">';

    var tbList = this.tabBlockBuilder.tabBlockLayout.itemRefArray;
    var blankSpace = "";
    str += '<div class="panelTopTitle">';
    str += this.paneLayout.title;
    str += '</div>';
    str += '<p style="margin:0px 0px 0px 0px;"></p>';

    //determine the current pricing visibility for this tab control.
    var currentPricesAreVisible = this.tabBlockBuilder.allPricesDisplayed;
    var pricesDisplayStyle = "none";
    var pricePrefixDisplayStyle = "none";

    if (( tabPane.showAllPricesOnLoad != undefined && tabPane.showAllPricesOnLoad ) || currentPricesAreVisible) {
        pricesDisplayStyle = "";
        pricePrefixDisplayStyle = "";
        this.tabBlockBuilder.allPricesDisplayed = true;
        currentPricesAreVisible = true;
        tabPane.showAllPricesOnLoad = undefined;
    } else {
        this.tabBlockBuilder.allPricesDisplayed = false;
        tabPane.showAllPricesOnLoad = undefined;
        currentPricesAreVisible = false;
    }

    //set up flags to indicate what types of prices are available for this passenger, which can then be used later to determine which prices need to be inside the switch
    //and whether the switch should be made available for this passenger.
    var cashOnlyPriceFound = false;
    var milesOnlyPriceFound = false;
    var partCashPriceFound = false
    var partCashPrice2Found = false
    //var cashOnlyOrMilesOnlyPriceFound = false;
    var partCashOrMilesOnlyPriceFound = false;

    for (ii = tbList.length - 1; ii >= 0; ii--)
    {

        if (this.paneData != undefined) {
            var theData = this.paneData[tbList[ii]];
            if (theData != undefined) {
                var theMiles = autotab_displayCash(theData.miles, false);
                var theCash = autotab_displayCash(theData.cash, true);
                //alert('theData.miles:'+theData.miles+ 'theData.cash:'+ theData.cash);
                if (theData.miles == 0 && theData.cash != 0) {
                    cashOnlyPriceFound = true;

                } else if (theData.miles != 0 && theData.cash == 0) {
                    milesOnlyPriceFound = true;

                } else if (theData.miles != 0 && theData.cash != 0) {
                    if (partCashPriceFound) {
                        partCashPrice2Found = true;
                    }
                    partCashPriceFound = true;

                } else {
                    //invalid price, will not be displayed.
                }

            }
        }

    }
    //end for

    partCashOrMilesOnlyPriceFound = partCashPriceFound || milesOnlyPriceFound;

    var partCashPriceCount = 0;

    //build price option HTML string, determine which prices are within the show/hide switch based on journey type.
    for (ii = tbList.length - 1; ii >= 0; ii--)
    {
        if (this.paneData === undefined)
        {
            blankSpace += " &nbsp;<BR>"
        }
        else
        {
            var theData = this.paneData[tbList[ii]]
            if (theData === undefined || ( theData.miles == 0 && theData.cash == 0 ))
            {
                blankSpace += " &nbsp;<BR>"
            }
            else
            {
                var theMiles = autotab_displayCash(theData.miles, false);
                var theMilesBack = autotab_displayCash(theData.milesBack, false);
                var theCash = autotab_displayCash(theData.cash, true);

                //get styles for miles and cash only prices for this journey type.
                var milesOnlyStyle = "";
                var cashOnlyStyle = "";

                if (this.journeyType == REDEMPTION_JOURNEY_TYPE) {
                    milesOnlyStyle = 'txtBoldBlu';
                } else {
                    cashOnlyStyle = 'txtBoldBlu';
                }

                if (theData.miles == 0) {

                    str = appendPricePrefix(str, this.journeyType, CASH_PRICE, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricePrefixDisplayStyle, this.FQN, ii);

                    if (theData.milesBack == 0) {
                        str += '><div class="priceStandard">&nbsp;&pound;' + theCash + '</div></div>';
                    }
                    else {
                        if (!(isWizard)) {
                          str +='<div class="priceStandard">&nbsp;&pound;' + theCash;
                          if (!this.hideMilesBack) {
                            str += '<a href="collect/milesback/collect-miles-on-your-travel" target="_blank"><span class="back"> and receive ' + theMilesBack + '  miles</span></a>';
                          }
                          str += '</div></div>';
                        } else {
                          str +='<div class="priceStandard">&nbsp;&pound;' + theCash;
                          if (!this.hideMilesBack) {
                            str += '</span><span class="back"> and receive ' + theMilesBack + ' miles</span>';
                          }
                          str += '</div></div>';
                        }

                    }

                }
                else if (theData.cash == 0) {

                    if (this.displaySwitches && this.journeyType == CASH_JOURNEY_TYPE && partCashOrMilesOnlyPriceFound) {
                        str += '<div style="display:' + pricesDisplayStyle + ';" id="po_' + this.FQN + '_' + ii + '">';
                    }

                    str = appendPricePrefix(str, this.journeyType, MILES_PRICE, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricePrefixDisplayStyle);

                    str += '<div class="priceProminent">&nbsp;' + theMiles + ' miles</div></div>';

                    if (this.displaySwitches && this.journeyType == CASH_JOURNEY_TYPE && partCashOrMilesOnlyPriceFound) {
                        str += '</div>';
                    }

                }
                else {

                    var showPriceSwitchForJourney = false;

                    partCashPriceCount = partCashPriceCount + 1;

                    if (this.journeyType == CASH_JOURNEY_TYPE && partCashOrMilesOnlyPriceFound
                            || this.journeyType == REDEMPTION_JOURNEY_TYPE && (milesOnlyPriceFound || cashOnlyPriceFound)) {
                        showPriceSwitchForJourney = true;
                    }

                    if (this.displaySwitches && showPriceSwitchForJourney) {
                        str += '<div style="display:' + pricesDisplayStyle + ';" id="po_' + this.FQN + '_' + ii + '">';
                    }
                    var partCashPriceType;
                    if (partCashPriceCount == 1) {
                        partCashPriceType = PARTCASH_PRICE_ONE;
                    } else {
                        partCashPriceType = PARTCASH_PRICE_TWO;
                    }

                    str = appendPricePrefix(str, this.journeyType, partCashPriceType, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricePrefixDisplayStyle);

                    if (this.journeyType == CASH_JOURNEY_TYPE) {
                        str += '<div class="priceStandard">&nbsp;&pound;' + theCash + ' + ' + theMiles + ' miles' + '</div></div>';
                    } else {
                        str += '<div class="priceStandard">&nbsp;' + theMiles + ' miles' + ' + ' + '&pound;' + theCash + '</div></div>';
                    }

                    if (this.displaySwitches && showPriceSwitchForJourney) {
                        str += '</div>';
                    }

                }

            }
        }
    }
    //end for

    var showPriceSwitchForJourney = false;

    if (this.journeyType == CASH_JOURNEY_TYPE) {
        if (partCashOrMilesOnlyPriceFound) {
            showPriceSwitchForJourney = true;
        }
    } else { //assume redemption
        if ((milesOnlyPriceFound || cashOnlyPriceFound) && partCashPriceFound) {
            showPriceSwitchForJourney = true;
        }
    }

    if (this.displaySwitches && showPriceSwitchForJourney) {
        var switchText = "";
        if (this.tabBlockBuilder.allPricesDisplayed) {
            switchText = hideProductPriceOptionsText;
        } else {
            switchText = showProductPriceOptionsText;
        }
        str += '<img src="/images/button/LNK_arrowPNK.gif" border="0">&nbsp;<a href="javascript:void(0);" onclick="showOrHide(\'' + this.FQN + '\'); return(false);"><span id="priceSwitchText_' + this.FQN + '">' + switchText + '</span></a>'

        displayGlobalSwitch = true;
    }

    if (displayGlobalSwitch) {
        showElement("showOrHidePricingOptionsElement", true);
    } else {
        showElement("showOrHidePricingOptionsElement", false);
    }

    str += '<div class="panelBotTitle">';
    str += '<img src="/images/common/1px_dots_w172.gif" style="margin: 8px -7px 5px -2px; "/><br>';
    str += this.paneLayout.title;
    str += "</div>";
    // Single item end

    // TAX BLOCK START ******
    // obtain the tax from this pane and format the string
    var taxString = '' + this.tabBlockBuilder.tabData[this.paneLayout.ref].taxes;
    var index = taxString.indexOf('.');
    if (index == -1) {
        taxString += '.00';
    }
    else if (index == taxString.length - 1) {
        taxString += '00';
    }
    else if (index == taxString.length - 2) {
        taxString += '0';
    }
    else {
        taxString = taxString.slice(0, index + 3);
    }

    // write the html to display the tax string
    str += '</td></tr><tr><td><div class="tax">Including airline taxes, fees &amp; charges</div></td></tr>';

    // TAX BLOCK END **********

    str += "</div>";
    str += "</td></tr>";
    str += "</table>";

    return( str );
}

// build the HTML for the contents of this pane
//Original layoutContent implmentation
TabPaneBuilder.prototype.layoutContent = function()
{
    return (this.layoutHighlightContent(false));
}

//Original layout implementation
TabPaneBuilder.prototype.layout = function()
{
    return (this.layoutHighlight(false));
}

//layout with additional highlighting flag
TabPaneBuilder.prototype.layoutHighlight = function(bHighLightLayout)
{
    var str = "";

    str = '<div id="' + this.tabBlockBuilder.getFQN() + '" >';

    str += this.layoutHighlightContent(bHighLightLayout);

    str += "</div>";

    return(str);
}

TabPaneBuilder.prototype.layoutTitle = function()
{
    if (this.titleData == null)
    // the style for this span class needs to be removed as it is still being blocked by the prices container
    // return( '<span class="bodyTxt" style="position:absolute;margin:30px 0 0 20px">'+this.paneLayout.title+'</span>' );
        return( '<span class="bodyTxt">' + this.paneLayout.title + '</span>' );
    else
        return( '<span class="bodyTxt">' + this.titleData + '</span>' );
}

TabPaneBuilder.prototype.switchTo = function(bHighLightSwitchTo)
{
    this.tabBlockBuilder.showBlock(this, bHighLightSwitchTo);

    // deal with grouping
    if (this.tabBlockBuilder.group != null)
    {
        this.tabBlockBuilder.group.setTab(this.paneLayout.ref);
    }
    if (this.tabBlockBuilder.persistTabSetting)
        tabCookie.setLayoutTab(this.tabBlockBuilder.tabBlockLayout.ref, this.paneLayout.ref);
}

TabPaneBuilder.prototype.show = function(bShowHighLightLayout)
{
    this.tabBlockBuilder.layer.rebind(this.tabBlockBuilder.forceLayerRebind);
    this.tabBlockBuilder.forceLayerRebind = false;
    this.tabBlockBuilder.layer.replace(this.layoutHighlight(bShowHighLightLayout));
}

TabPaneBuilder.prototype.hide = function()
{

    // Nothing happens if this is not multilayer, as the content is overwritten, not hidden
}


function TabBlockBuilder(tabBlockLayout, isWizard, tabData, defaultPane, highLight, journeyType, displaySwitches, showAllPricesOnLoad)
{
    this.tabBlockLayout = tabBlockLayout;
    this.tabData = tabData;

    this.tabPanes = new Array();
    this.titles = new Object();
    this.titles.order = new Array();
    this.allPricesDisplayed = false;
    if (showAllPricesOnLoad && displaySwitches) {
        this.allPricesDisplayed = true;
    }

    for (var ii = 0; ii < tabBlockLayout.paneRefArray.length; ii++)
    {
        var newPaneBuilder = new TabPaneBuilder(this, tabBlockLayout.paneRefArray[ii], isWizard, null, highLight, journeyType, displaySwitches, showAllPricesOnLoad);
        //saz
        this.tabPanes.push(newPaneBuilder);
        this[newPaneBuilder.paneLayout.ref] = newPaneBuilder;
    }

    if (defaultPane != undefined && defaultPane != null)
    {
        this.defaultPane = this[defaultPane];
        this.persistTabSetting = false;

    }
    else
    {
        var defaultTab = tabCookie.getLayoutTab(tabBlockLayout.ref);

        if (defaultTab == "")
            this.defaultPane = this.tabPanes[0];
        else
        {
            var theFirstPane = this[defaultTab];
            if (theFirstPane)
                this.defaultPane = theFirstPane;
            else
                this.defaultPane = this.tabPanes[0];
        }
        this.persistTabSetting = true;
    }

    this.activePane = this.defaultPane;

    this.group = null;
    this.FQN = "TBBpane" + nameCounter++;
    this.hasTitle = false;

    this.layer = new LayerLite(this.FQN);
    this.forceLayerRebind = true;

    if (tabData === undefined || tabData == null)
    {
        this.off = true;
    }
    else
    {
        this.rebindData(tabData, false);
        this.off = false;
    }
    this.offMessage = "";
}

TabBlockBuilder.prototype.setOffMessage = function(message)
{
    this.offMessage = message;
}

TabBlockBuilder.prototype.rebindData = function(tabData, showImmediately)
{
    this.tabData = tabData;
    this.hideMilesBack = this.tabData.hideMilesBack;
    for (var ii = 0; ii < this.tabPanes.length; ii++)
    {
        var pane = this.tabPanes[ii];
        pane.paneData = tabData[pane.paneLayout.ref];
    }
    if (this.off)
        return;
    var show = true;
    if (showImmediately !== undefined)
        show = showImmediately;

    if (show)
    {
        this.refresh(show);
    }
}

TabBlockBuilder.prototype.refresh = function(bHighLightRefresh)
{
    this.activePane.show(bHighLightRefresh);

    if (this.hasTitle)
    {
        this.titleLayer.rebind();
        this.titleLayer.replace(this.activePane.layoutTitle());
    }
}

TabBlockBuilder.prototype.showBlock = function(paneToShow, bHighLightTabBlock)
{
    if (this.activePane != paneToShow)
    {
        this.activePane.hide();
        paneToShow.show(bHighLightTabBlock);
        if (this.hasTitle)
        {
            this.titleLayer.rebind();
            this.titleLayer.replace(paneToShow.layoutTitle());
        }
        this.activePane = paneToShow;
    }
}

TabBlockBuilder.prototype.layout = function()
{
    var str = this.activePane.layout();
    this.forceLayerRebind = true;
    return(str)
}

TabBlockBuilder.prototype.layoutHighlight = function(highLightTabBlock)
{
    var str = this.activePane.layoutHighlight(highLightTabBlock);
    this.forceLayerRebind = true;
    return(str);
}

TabBlockBuilder.prototype.layoutTitle = function()
{
    var str = "";

    // Only need one pannel here
    var titleLayerID = "TBBTitlepane" + nameCounter++;
    str += '<div id="' + titleLayerID + '"' + this.tabBlockLayout.titleStyle + '>';
    str += this.activePane.layoutTitle();
    str += '</div>';
    this.titleLayer = new LayerLite(titleLayerID);
    this.hasTitle = true;
    return(str)
}

TabBlockBuilder.prototype.setOff = function (offValue, bHighLightSetOff)
{
    if (this.off == offValue)
        return;

    this.off = offValue;

    if (this.off)
    {
    }
    else
    {
        this.activePane = this.defaultPane;
    }

    this.refresh(bHighLightSetOff);
}

TabBlockBuilder.prototype.isOff = function()
{
    return( off );
}

TabBlockBuilder.prototype.getFQN = function()
{
    return( this.FQN );
}


TabBlockBuilder.encode = function(htmlStr)
{
    return ( htmlStr.replace(/</g, "&lt;").replace(/>/g, "&gt;") );
}

// Grouping object.  Grouped tab blocks change together

function GroupedBlocks(ref, tabBlockBuilderArray)
{
    this.ref = ref
    for (var ii = 0; ii < tabBlockBuilderArray.length; ii++)
    {
        tabBlockBuilderArray[ii].group = this
    }
    this.tabBlockBuilderArray = tabBlockBuilderArray
}

GroupedBlocks.prototype.addTab = function(tabToAdd)
{
    tabToAdd.group = this;
    this.tabBlockBuilderArray.push(tabToAdd);
}

GroupedBlocks.prototype.setTab = function(tabRef)
{
    for (var ii = 0; ii < this.tabBlockBuilderArray.length; ii++)
    {
        var tabBlock = this.tabBlockBuilderArray[ii];

        if (tabBlock != null && tabBlock !== undefined)
        {
            if (tabBlock.activePane != null && tabBlock.activePane !== undefined)
            {
                if (tabBlock.activePane.paneData != null && tabBlock.activePane.paneData !== undefined)
                {
                    if (tabBlock.activePane.paneData.ref != null && tabBlock.activePane.paneData.ref !== undefined)
                    {
                        if (tabBlock.activePane.paneData.ref != tabRef)
                        {
                            tabBlock.showBlock(tabBlock[tabRef], tabBlock[tabRef].highLight);
                        }
                    }
                }
            }
        }
    }
}

// Default styles

function TabBlockStyles()
{
    this.tab = "";
}

// Tab state held in cookies
// Use a single cookie of the format
// AUTOTABSETTING=flight:<tab_id>&hotel:<tab_id>&offer:<tab_id>

function TabCookie()
{
    this.layoutNames = new Array();
    this.readCookie();
}

TabCookie.COOKIE_NAME = "AUTOTABSETTING";

TabCookie.prototype.readCookie = function()
{
    var allCookies = document.cookie;
    var start = allCookies.indexOf(TabCookie.COOKIE_NAME + '=');
    if (start != -1)
    {
        start += TabCookie.COOKIE_NAME.length + 1;
        var end = allCookies.indexOf(';', start);
        if (end == -1)
            end = allCookies.length;
        var cookieVal = allCookies.substring(start, end);

        var vals = cookieVal.split('&');
        for (var ii = 0; ii < vals.length; ii++)
        {
            vals[ii] = vals[ii].split(':');
            this.layoutNames.push(vals[ii][0]);
            this[vals[ii][0]] = vals[ii][1];
        }
    }
}


TabCookie.prototype.getLayoutTab = function(layoutName)
{
    var val = this[layoutName];
    if (val === undefined || val == null)
    {
        return "";
    }
    else
    {
        return val
    }
}

TabCookie.prototype.setLayoutTab = function(layoutName, val)
{
    var found = false;
    for (var ii = 0; ii < this.layoutNames.length; ii++)
    {
        if (this.layoutNames[ii] == layoutName)
        {
            found = true;
            break;
        }
    }

    if (! found)
        this.layoutNames.push(layoutName);

    this[layoutName] = val;

    this.writeCookie();
}

TabCookie.prototype.writeCookie = function()
{
    if (this.layoutNames.length == 0)
        return;

    var cookieVal = "";
    for (var ii = 0; ii < this.layoutNames.length; ii++)
    {
        if (ii != 0)
            cookieVal += '&';

        cookieVal += this.layoutNames[ii] + ':' + this[this.layoutNames[ii]];
    }

    document.cookie = TabCookie.COOKIE_NAME + '=' + cookieVal + ';path=/';
}

TabCookie.prototype.removeCookie = function()
{
    var expiredDate = new Date();
    expiredDate.setFullYear(expiredDate.getFullYear() - 1);

    document.cookie = TabCookie.COOKIE_NAME + '=noValue;path=/;' +
                      'expires=' + expiredDate.toGMTString();
}

var tabCookie = new TabCookie();

// Utilities

function autotab_displayCash(numb, withPence) {

    var strNum = new String(Math.round(numb * 100));
    var newNum = new Number(strNum);

    if (newNum == 0) return "0";
    if (strNum.length == 1) strNum = "0.0" + strNum;
    else if (strNum.length == 2) strNum = "0." + strNum;
    resultString = strNum.substring(0, strNum.length - 2);

    var holdsTempResult = new String(resultString);

    resultString = "";
    while (holdsTempResult.length > 0) {
        if (holdsTempResult.length > 3) {
            resultString = "," + holdsTempResult.substring(holdsTempResult.length - 3, holdsTempResult.length) + resultString;
            holdsTempResult = holdsTempResult.substring(0, holdsTempResult.length - 3);
        }
        else {
            resultString = holdsTempResult + resultString;
            break;
        }
    }

    if (withPence) {
        pence = strNum.substring(strNum.length - 2);
        if (pence != "00") {
            resultString += "." + strNum.substring(strNum.length - 2);
        }
    }
    return resultString;
}

function appendPricePrefix(priceOptionsHTMLString, journeyType, priceType, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricesDisplayStyle, FQN, counter) {
    var testString = priceOptionsHTMLString;
    if (this.journeyType == CASH_JOURNEY_TYPE && priceType != CASH_PRICE) {
        priceOptionsHTMLString += PRICE_PREFIX;
    }

    if (this.journeyType == REDEMPTION_JOURNEY_TYPE && priceType != MILES_PRICE) {

        if (priceType == CASH_PRICE) {

            if (milesOnlyPriceFound) {

                priceOptionsHTMLString += PRICE_PREFIX;
            } else {

                if ((partCashPriceFound || partCashPrice2Found)) {
                     str =  PRICE_PREFIX;
                     priceOptionsHTMLString += str;
                }

            }

        } else {  //pc
            if (milesOnlyPriceFound) {

                priceOptionsHTMLString += PRICE_PREFIX;
            } else {

                if (priceType == PARTCASH_PRICE_TWO && partCashPriceFound) {
                    priceOptionsHTMLString += PRICE_PREFIX;
                }
            }

        }

    }
    if (testString == priceOptionsHTMLString) {
        priceOptionsHTMLString += EMPTY_PREFIX;

    }
    return priceOptionsHTMLString;
}

function wrapPriceWithOrPrefix(priceString, journeyType, priceType, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricesDisplayStyle, FQN, counter ){
  var outStr = "";
  if (this.journeyType==CASH_JOURNEY_TYPE && priceType!=CASH_PRICE){
    outStr = PRICE_PREFIX + priceString + "</div>";
  }

  if (this.journeyType==REDEMPTION_JOURNEY_TYPE && priceType!=MILES_PRICE){
     //alert('priceType'+priceType);
    if (priceType==CASH_PRICE){
      if (milesOnlyPriceFound){
        outStr = PRICE_PREFIX + priceString + "</div>";
      }else{

        if( (partCashPriceFound || partCashPrice2Found) ){
          outStr = '<div class="pricePrefixOr" style="display:'+pricesDisplayStyle+';" id="pp_'+FQN+'_'+counter+'">' + priceString + '</div>';
        }

      }

    }else{  //pc
      if (milesOnlyPriceFound){
       outStr = PRICE_PREFIX + priceString + "</div>";
      }else{
         if(priceType==PARTCASH_PRICE_TWO && partCashPriceFound){
         outStr = PRICE_PREFIX + priceString + "</div>";
        }
      }

    }

  }

  if ( outStr == ""){
      outStr = EMPTY_PREFIX + priceString + '</div>';
  }
  return outStr;
}

function displayOr(priceOptionsHTMLString, journeyType, priceType, cashOnlyPriceFound, milesOnlyPriceFound, partCashPriceFound, partCashPrice2Found, pricesDisplayStyle, FQN, counter ){

  if (this.journeyType==CASH_JOURNEY_TYPE && priceType!=CASH_PRICE){
    return true;
  }

  if (this.journeyType==REDEMPTION_JOURNEY_TYPE && priceType!=MILES_PRICE){
     //alert('priceType'+priceType);
    if (priceType==CASH_PRICE){
      if (milesOnlyPriceFound){
        return true;
      }else{

        if( (partCashPriceFound || partCashPrice2Found) ){
         // str = '<div style="display:'+pricesDisplayStyle+';" id="pp_'+FQN+'_'+counter+'">'+PRICE_PREFIX+'</div>';
         // priceOptionsHTMLString += str; //
         return true;
        }

      }

    }else{  //pc
      if (milesOnlyPriceFound){
        return true;
      }else{
         if(priceType==PARTCASH_PRICE_TWO && partCashPriceFound){
          return true;
        }
      }

    }

  }
  return false;
}