function ChoicePanel(A,B){this.choicePanelId=A;this.direction=B}ChoicePanel.prototype.SetTotalCostPanel=function(A){this.totalCostPanel=A};ChoicePanel.prototype.SetJourneyData=function(A){this.journeyPlanningData=A;this.origin=A.data.requestedOrigin;this.destination=A.data.requestedDestination;this.multiplePassengers=A.data.multiplePassengers;this.originalFareGroup=null;if(this.direction==outward){this.date=A.data.outwardDate}else{this.date=A.data.returnDate}this.fares=A.data.fares;this.locations=A.data.locations;this.UpdateDisplay()};ChoicePanel.prototype.SetVisibility=function(A){this.Initialise();ShowElement(this.choicePanel,A)};ChoicePanel.prototype.UpdateDisplay=function(){var A;this.Initialise();if(this.GetFareGroup()!=null){GetLocationData();if(this.direction==outward){this.origin=nlcCodes[this.GetFareGroup().oNlc][0];this.destination=nlcCodes[this.GetFareGroup().dNlc][0]}else{this.origin=nlcCodes[this.GetFareGroup().dNlc][0];this.destination=nlcCodes[this.GetFareGroup().oNlc][0]}}else{this.origin=this.journeyPlanningData.data.requestedOrigin;this.destination=this.journeyPlanningData.data.requestedDestination}this.CalculateSpecificFare();if(!this.IsDisplayingReturn()){this.ShowReturnDetails(false);this.ShowReturnBackground(false)}else{this.ShowReturnDetails(true)}ShowElement(this.chooseOnlineDiscountLine,this.IsFareDiscounted());this.SetFareGroupDetails();this.SetServiceDetails();if(this.IsSelected(this.GetFareGroup())&&this.fare==undefined&&!this.IsServiceRequired()){this.fare=this.fares[this.GetFareGroup().repFareId];this.serviceFare=undefined}if(this.GetFareGroup()!=null){if(this.CanWeBuyThisTicket()){YAHOO.util.Dom.addClass(this.chooseOnlineDiscountLine,"OnlineDiscountLineChosen");if(this.GetFareGroup().isReturn){YAHOO.util.Dom.addClass(this.chooseChosenTicket,"ReturnTicketSelected");YAHOO.util.Dom.removeClass(this.chooseChosenTicket,"TicketSelected");SetVisibility(this.chooseFarePriceIcon,this.direction==inward);this.ShowReturnBackground(true)}else{YAHOO.util.Dom.addClass(this.chooseChosenTicket,"TicketSelected");YAHOO.util.Dom.removeClass(this.chooseChosenTicket,"ReturnTicketSelected");SetVisibility(this.chooseFarePriceIcon,true)}if(this.direction==outward){A=document.getElementById("outwardTicketInformationIFrame")}else{A=document.getElementById("inwardTicketInformationIFrame")}A.deferedSrc=this.fare.ttcUrl;if(this.IsDisplayingReturn()&&this.direction==inward){this.totalCostPanel.SetData(this.direction,null,null)}else{this.totalCostPanel.SetData(this.direction,this.GetFareGroup(),this.serviceFare)}}else{YAHOO.util.Dom.removeClass(this.chooseOnlineDiscountLine,"OnlineDiscountLineChosen");YAHOO.util.Dom.removeClass(this.chooseChosenTicket,"TicketSelected");YAHOO.util.Dom.removeClass(this.chooseChosenTicket,"ReturnTicketSelected");SetVisibility(this.chooseFarePriceIcon,false);this.ShowReturnBackground(false);this.totalCostPanel.SetData(this.direction,undefined,undefined)}}else{this.totalCostPanel.SetData(this.direction,undefined,undefined)}if(this.GetFareGroup()!=null&&this.GetFareGroup().isReturn){this.ShowReturnDetails(true)}};ChoicePanel.prototype.IsServiceRequired=function(){if(this.GetFareGroup().mandRes=="Y"){return true}if(this.GetFareGroup().mandRes=="E"){return !this.IsOutwardServiceSelected()&&!this.IsInwardServiceSelected()}if(this.direction==outward){return this.GetFareGroup().mandRes=="O"}else{return this.GetFareGroup().mandRes=="R"}};ChoicePanel.prototype.IsServiceSelected=function(){var A=this.GetService();return A!=null&&A.selected};ChoicePanel.prototype.IsOutwardServiceSelected=function(){return this.GetSelectedService(outward)!=null&&this.GetSelectedService(outward).selected};ChoicePanel.prototype.IsInwardServiceSelected=function(){return this.GetSelectedService(inward)!=null&&this.GetSelectedService(inward).selected};ChoicePanel.prototype.Initialise=function(){if(this.chooseFare==undefined){this.choicePanel=document.getElementById(this.choicePanelId);this.chooseFare=YAHOO.util.Dom.getElementsByClassName("ChooseFare",undefined,this.choicePanel)[0];this.chooseService=YAHOO.util.Dom.getElementsByClassName("ChooseService",undefined,this.choicePanelId)[0];this.chooseInfo=YAHOO.util.Dom.getElementsByClassName("ChooseInfo",undefined,this.choicePanelId)[0];this.chooseInfoLines=YAHOO.util.Dom.getElementsByClassName("ChooseInfoLine",undefined,this.choicePanelId);this.chooseInfoDetails=YAHOO.util.Dom.getElementsByClassName("ChooseInfoDetails",undefined,this.choicePanelId);this.chooseInfoDateAdditional=YAHOO.util.Dom.getElementsByClassName("ChooseInfoDateAdditional",undefined,this.choicePanelId)[0];this.chooseInfoNote=YAHOO.util.Dom.getElementsByClassName("ChooseInfoNote",undefined,this.choicePanelId)[0];this.chooseInfoReserve=YAHOO.util.Dom.getElementsByClassName("ChooseInfoReserve",undefined,this.choicePanelId)[0];this.chooseInfoReserveOriginalText=this.chooseInfoReserve.innerHTML;this.chooseChosenTicket=YAHOO.util.Dom.getElementsByClassName("ChosenTicket",undefined,this.choicePanelId)[0];if(this.direction==outward){this.chooseChosenReturnTicket=YAHOO.util.Dom.getElementsByClassName("ChosenReturnTicket",undefined,this.choicePanelId)[0]}this.chooseOnlineDiscountLine=YAHOO.util.Dom.getElementsByClassName("OnlineDiscountLine",undefined,this.choicePanelId)[0];this.chooseFareDescription=YAHOO.util.Dom.getElementsByClassName("ChooseInfoTicket",undefined,this.choicePanelId)[0];this.chooseFarePrice=YAHOO.util.Dom.getElementsByClassName("ChooseInfoPrice",undefined,this.choicePanelId)[0];this.chooseFarePriceText=YAHOO.util.Dom.getElementsByClassName("ChooseInfoPriceText",undefined,this.choicePanelId)[0];this.chooseFarePriceIcon=GetNextElement(this.chooseFarePriceText,"IMG");var A=YAHOO.util.Event.addListener(this.chooseFarePriceIcon,"mouseover",this.ShowRolledOverInfoImage,this,true);A=YAHOO.util.Event.addListener(this.chooseFarePriceIcon,"mouseout",this.ShowNormalInfoImage,this,true)}};ChoicePanel.prototype.ShowRolledOverInfoImage=function(){var A=ImagePath+"TotalSelectedInfoIconRollover.gif";if(!this.normalInfoImage){this.normalInfoImage=this.chooseFarePriceIcon.src}if(this.chooseFarePriceIcon.src!=A){this.chooseFarePriceIcon.src=A}};ChoicePanel.prototype.ShowNormalInfoImage=function(){if(this.chooseFarePriceIcon.src!=this.normalInfoImage){this.chooseFarePriceIcon.src=this.normalInfoImage}};ChoicePanel.prototype.GetService=function(){return this.GetSelectedService(this.direction)};ChoicePanel.prototype.SetServiceDetails=function(){var A=this.GetService();if(A==null){this.SetChooseInfoReserveToOriginalText();if(this.direction==outward){this.chooseInfoDetails[0].innerHTML=this.origin;this.chooseInfoDetails[1].innerHTML=this.destination}else{this.chooseInfoDetails[0].innerHTML=this.destination;this.chooseInfoDetails[1].innerHTML=this.origin}this.chooseInfoDetails[2].innerHTML=this.date;ShowElement(this.chooseInfoDateAdditional,false)}else{if(this.GetFareGroup()!=null){ShowElement(this.chooseInfoReserve,!this.IsServiceRequired()&&!A.selected)}else{ShowElement(this.chooseInfoReserve,false)}if(this.direction==inward&&this.InwardBeforeOutwardService()){this.chooseInfoReserve.innerHTML=mixingDeck.resourceStrings.inwardServiceBeforeOutward}else{this.SetChooseInfoReserveToOriginalText()}this.chooseInfoDetails[0].innerHTML=this.locations[A.oNlc].desc+", "+FormatTime(A.dTime);this.chooseInfoDetails[1].innerHTML=this.locations[A.dNlc].desc+", "+FormatTime(A.aTime);this.chooseInfoDetails[2].innerHTML=FormatDate(A.dTime);this.chooseInfoDetails[3].innerHTML=A.nChgs;this.chooseInfoDetails[4].innerHTML=FormatDuration(A.dur*1)+"hrs";ShowElement(this.chooseInfoDateAdditional,true);ShowElement(this.chooseService,false)}};ChoicePanel.prototype.CalculateSpecificFare=function(){this.fare=undefined;if(this.GetFareGroup()){var A;if(!this.GetFareGroup().isReturn){A=this.GetService()}else{A=this.GetSelectedService(outward);if(!A){A=this.GetSelectedService(inward)}}if(A){for(var B in A.serviceFares){if(A.serviceFares[B].fgId==this.GetFareGroup().fareGroupId){this.serviceFare=A.serviceFares[B];this.fare=this.fares[this.serviceFare.fareIds[0]];this.SetFareDescription(this.fare.desc);this.chooseFarePriceText.innerHTML=FormatPrice(this.serviceFare.totFare);break}}}}};ChoicePanel.prototype.SetFareGroupDetails=function(){if(this.GetFareGroup()!=null){this.chooseInfoNote.innerHTML=this.TruncateInfoNote(this.GetFareGroup().briefTsAndCs);if(this.fare==undefined){this.SetFareDescription(this.GetFareGroup().desc);this.chooseFarePriceText.innerHTML=this.GetFareGroup().farePrice;SetVisibility(this.chooseFarePrice,true)}}else{this.SetFareDescription("&nbsp;");this.chooseFarePriceText.innerHTML="&nbsp;";this.chooseInfoNote.innerHTML="&nbsp;";SetVisibility(this.chooseFarePrice,false);YAHOO.util.Dom.removeClass(this.chooseChosenTicket,"TicketSelected")}};ChoicePanel.prototype.ShowReturnDetails=function(A){if(A){if(this.direction==outward){ShowElement(this.chooseOnlineDiscountLine,false);SetVisibility(this.chooseFarePrice,false)}else{SetVisibility(this.chooseFareDescription,false);if(this.GetSelectedService(inward)==null){SetVisibility(this.chooseInfoLines[1],false);SetVisibility(this.chooseInfoLines[2],false);SetVisibility(this.chooseInfoLines[3],false)}else{SetVisibility(this.chooseInfoLines[1],true);SetVisibility(this.chooseInfoLines[2],true);SetVisibility(this.chooseInfoLines[3],true)}this.chooseInfoNote.innerHTML=this.TruncateInfoNote(this.GetFareGroup().retValText)}}else{ShowElement(this.chooseOnlineDiscountLine,true);SetVisibility(this.chooseFarePrice,true);SetVisibility(this.chooseFareDescription,true);if(!this.isOpenReturn){SetVisibility(this.chooseInfoLines[1],true);SetVisibility(this.chooseInfoLines[2],true);SetVisibility(this.chooseInfoLines[3],true)}SetVisibility(this.chooseFarePriceIcon,false)}};ChoicePanel.prototype.ShowReturnBackground=function(A){if(this.chooseChosenReturnTicket!=undefined){SetVisibility(this.chooseChosenReturnTicket,A)}};ChoicePanel.prototype.ShowAddReturnJourneyButton=function(){this.HideChosenInwardDetails();var A=YAHOO.util.Dom.getElementsByClassName("AddReturn",undefined,this.choicePanel)[0];ShowElement(A,true)};ChoicePanel.prototype.HideChosenInwardDetails=function(){var A=YAHOO.util.Dom.getElementsByClassName("ChosenInwardDetails",undefined,this.choicePanel)[0];ShowElement(A,false)};ChoicePanel.prototype.SetAsOpenReturn=function(){this.isOpenReturn=true;SetVisibility(this.chooseInfoLines[1],false);SetVisibility(this.chooseInfoLines[2],false);SetVisibility(this.chooseInfoLines[3],false)};ChoicePanel.prototype.CanWeBuyThisTicket=function(){if(!this.IsSelected(this.GetFareGroup())){return false}if(!this.GetFareGroup().isReturn){var A=(this.GetFareGroup().mandRes=="Y");return(this.IsServiceSelected()||!A)}else{switch(this.GetFareGroup().mandRes){case"N":return true;break;case"O":return this.IsOutwardServiceSelected();break;case"R":return this.IsInwardServiceSelected();break;case"E":return this.IsOutwardServiceSelected()||this.IsInwardServiceSelected();break;case"Y":return this.IsOutwardServiceSelected()&&this.IsInwardServiceSelected();break}}return false};ChoicePanel.prototype.SetChooseInfoReserveToOriginalText=function(){if(this.direction==inward){if(this.chooseInfoReserve.innerHTML!=this.chooseInfoReserveOriginalText){this.chooseInfoReserve.innerHTML=this.chooseInfoReserveOriginalText}}};ChoicePanel.prototype.InwardBeforeOutwardService=function(){if(this.journeyPlanningData._selectedService[outward].service&&this.journeyPlanningData._selectedService[inward].service&&this.journeyPlanningData._selectedService[outward].service.aTime>=this.journeyPlanningData._selectedService[inward].service.dTime){return true}return false};ChoicePanel.prototype.TruncateInfoNote=function(A){return A};ChoicePanel.prototype.IsSelected=function(A){if(this.IsDisplayingReturn()){return mixingDeck.journeyPlanningData.IsSelected(outward,A)}else{return mixingDeck.journeyPlanningData.IsSelected(this.direction,A)}};ChoicePanel.prototype.GetSelectedService=function(A){return mixingDeck.journeyPlanningData._selectedService[A].service};ChoicePanel.prototype.IsDisplayingReturn=function(A){return mixingDeck.journeyPlanningData._selectedFareGroup[outward].fareGroup&&mixingDeck.journeyPlanningData._selectedFareGroup[outward].fareGroup.isReturn};ChoicePanel.prototype.GetFareGroup=function(A){if(this.IsDisplayingReturn()){return mixingDeck.journeyPlanningData._selectedFareGroup[outward].fareGroup}else{return mixingDeck.journeyPlanningData._selectedFareGroup[this.direction].fareGroup}};ChoicePanel.prototype.SetFareDescription=function(A){this.chooseFareDescription.innerHTML=A;if(this.chooseFareDescription.scrollHeight>20){this.chooseFareDescription.style.lineHeight="12px"}else{this.chooseFareDescription.style.lineHeight=""}};ChoicePanel.prototype.UpdateChooseFare=function(A){if(mixingDeck.journeyPlanningData._selectedFareGroup[this.direction].selected||this.isOpenReturn){SetVisibility(this.chooseFare,false)}else{if(this.direction==inward&&mixingDeck.journeyPlanningData._selectedFareGroup[outward].selected&&mixingDeck.journeyPlanningData._selectedFareGroup[outward].fareGroup.isReturn){SetVisibility(this.chooseFare,false)}else{if(A){YAHOO.util.Dom.addClass(this.chooseFare,"TransparentChoose")}else{YAHOO.util.Dom.removeClass(this.chooseFare,"TransparentChoose")}SetVisibility(this.chooseFare,true)}}};ChoicePanel.prototype.UpdateChooseService=function(D){var C;var A;if(this.direction==inward&&this.InwardBeforeOutwardService()){C=false;A=true}else{if(mixingDeck.journeyPlanningData._selectedService[this.direction].selected||this.isOpenReturn){C=false;A=false}else{var E=this.GetFareGroup();var B=this.IsSelected(E);if(E==null||this.IsServiceRequired()||!B){C=true;A=false}else{C=false;A=B}}}if(C){if(D){YAHOO.util.Dom.addClass(this.chooseService,"TransparentChoose")}else{YAHOO.util.Dom.removeClass(this.chooseService,"TransparentChoose")}ShowElement(this.chooseService,true)}else{ShowElement(this.chooseService,false)}if(E!=null&&E.isCarnet){if(this.direction==inward&&this.InwardBeforeOutwardService()){ShowElement(this.chooseInfoReserve,A)}else{ShowElement(this.chooseInfoReserve,A&&!E.isCarnet)}}else{ShowElement(this.chooseInfoReserve,A)}};ChoicePanel.prototype.IsFareDiscounted=function(){var A=this.GetFareGroup();if(A){if(mixingDeck.journeyPlanningData._selectedService[this.direction].service){return mixingDeck.journeyPlanningData._selectedService[this.direction].service.isDiscounted}else{return A.isDiscounted}}else{return false}}
