function FarePanel(C,B,A){this.farePanelId=C;this.panelDataName=A;this.direction=B;this.currentPage=0;this.disableAll=false;this.inRollOver=false}FarePanel.prototype.AddRolloverListener=function(A){this.journeyPlanningData=A;this.availableFares=YAHOO.util.Dom.getElementsByClassName("AvailableFares",undefined,this.farePanelId)[0];var B=YAHOO.util.Event.addListener(this.availableFares,"mouseover",this.OnRollover,this,true);B=YAHOO.util.Event.addListener(this.availableFares,"mouseout",this.OnRolloverExit,this,true)};FarePanel.prototype.OnRollover=function(A){if(!this.inRollOver){this.inRollOver=true;this.journeyPlanningData.UpdateChooseFare(this.direction,this.inRollOver)}};FarePanel.prototype.OnRolloverExit=function(A){if(this.inRollOver){if(StillInsideElementOnMouseOut(this.availableFares,A)){return }this.inRollOver=false;this.journeyPlanningData.UpdateChooseFare(this.direction,this.inRollOver)}};FarePanel.prototype.AddEventListener=function(B,A){if(this.changedEvent==undefined){this.changedEvent=new YAHOO.util.CustomEvent("FareGroupSelected"+this.direction)}this.changedEvent.subscribe(A,B,true)};FarePanel.prototype.FireEvent=function(A,B){if(this.changedEvent!=undefined){this.changedEvent.fire(this.direction,A,B)}};FarePanel.prototype.OnShowCheaperFares=function(){this.currentPage--;this.UpdateDisplay()};FarePanel.prototype.OnShowMoreExpensiveFares=function(){this.currentPage++;this.UpdateDisplay()};FarePanel.prototype.DisableAllFares=function(B){if(this.disableAll!=B){this.disableAll=B;var A=this.GetFareControls();for(var C=0;C<A.length;C++){this.SetAppearance(A[C])}}};FarePanel.prototype.SetData=function(C,B,A){this.singleFareGroups=C;this.returnFareGroups=B;this.routes=A;this.CalculatePagesRequired();if(!this.isEnabled){this.EnablePanel()}};FarePanel.prototype.CalculatePagesRequired=function(){if(this.returnFareGroups.length==0){this.pagesRequired=Math.floor((this.singleFareGroups.length-1)/10+1)}else{this.pagesRequired=Math.floor(Math.max((this.returnFareGroups.length-1)/5+1,(this.singleFareGroups.length-1)/5+1))}if(this.pagesRequired==0){this.pagesRequired=1}if(this.currentPage>=this.pagesRequired){this.currentPage=this.pagesRequired-1}};FarePanel.prototype.UpdateDisplay=function(){this.fareKeys=new Array();var A=this.GetFareControls();for(var B=0;B<A.length;B++){A[B].fareGroup=undefined;this.ClearFare(A[B])}if(this.returnFareGroups.length==0){this.SetFares(A,this.singleFareGroups,0,10)}else{this.SetFares(A,this.singleFareGroups,0,5);this.SetFares(A,this.returnFareGroups,5,5)}for(B=0;B<A.length;B++){this.SetAppearance(A[B])}if(!this.btnMoreFares){this.btnMoreFares=YAHOO.util.Dom.getElementsByClassName("MoreFares",undefined,this.farePanelId)[0]}ShowElement(this.btnMoreFares,this.currentPage<this.pagesRequired-1);if(!this.btnCheaperFares){this.btnCheaperFares=YAHOO.util.Dom.getElementsByClassName("CheaperFares",undefined,this.farePanelId)[0]}ShowElement(this.btnCheaperFares,this.currentPage>0)};FarePanel.prototype.SetFares=function(C,G,E,D){var B=D*this.currentPage;var H=0;var I=E;for(var F in G){if(H>=B){if(I>=E+D){break}this.SetFare(C[I],G[F],F);var A=new Object();A.farePanel=this;A.fareControl=C[I];var J=YAHOO.util.Event.addListener(C[I],"mouseover",this.FareMouseOver,A);J=YAHOO.util.Event.addListener(C[I],"mouseout",this.FareMouseOut,A);J=YAHOO.util.Event.addListener(C[I],"click",this.FareMouseClick,A);I++}H++}};FarePanel.prototype.ClearFare=function(A){var D=YAHOO.util.Event.removeListener(A,"mouseover");D=YAHOO.util.Event.removeListener(A,"mouseout");D=YAHOO.util.Event.removeListener(A,"click");var C=YAHOO.util.Dom.getElementsByClassName("FarePriceText",undefined,A);C[0].innerHTML="";var B=YAHOO.util.Dom.getElementsByClassName("FareType",undefined,A);B[0].innerHTML="";if(A.webFare==undefined){A.webFare=YAHOO.util.Dom.getElementsByClassName("WebFare",undefined,A)[0];A.dummyWebFare=YAHOO.util.Dom.getElementsByClassName("DummyWebFare",undefined,A)[0]}this.ShowWebFareElement(A,false);A.title=""};FarePanel.prototype.ShowWebFareElement=function(A,B){ShowElement(A.webFare,B);var C;if(B){C=A.fareGroup.minFare<10000&&A.fareGroup.minFare!=A.fareGroup.maxFare}else{C=A.fareGroup&&A.fareGroup.minFare==A.fareGroup.maxFare}ShowElement(A.dummyWebFare,C)};FarePanel.prototype.SetFare=function(A,D){A.fareGroup=D;A.fareKey=D.fareGroupId;this.fareKeys[D.fareGroupId]=A;var C=YAHOO.util.Dom.getElementsByClassName("FarePriceText",undefined,A);if(D.minFare==D.maxFare){D.farePrice=FormatPrice(D.minFare);C[0].innerHTML=this.FormatPrice(D.minFare);C[0].style.display="block";C[0].style.clear="both";C[0].parentNode.style.paddingTop=""}else{D.farePrice=this.FormatPrice(D.minFare)+" "+mixingDeck.resourceStrings.to+" "+this.FormatPrice(D.maxFare);C[0].innerHTML=this.FormatPrice(D.minFare)+mixingDeck.resourceStrings.to+" "+this.FormatPrice(D.maxFare);C[0].style.display="";C[0].style.clear="";C[0].parentNode.style.paddingTop="4px";C[0].innerHTML=this.FormatPrice(D.minFare)+"<br/>"+mixingDeck.resourceStrings.to+this.FormatPrice(D.maxFare)}var B=YAHOO.util.Dom.getElementsByClassName("FareType",undefined,A);if(D.isReturn){B[0].innerHTML=mixingDeck.resourceStrings.returnTicket}else{B[0].innerHTML=mixingDeck.resourceStrings.singleTicket}this.ShowWebFareElement(A,D.isDiscounted)};FarePanel.prototype.FareMouseOver=function(D,B){var A=B.fareControl;var C=B.farePanel;if(A.fareGroup==undefined){return }if(!A.hover){A.hover=true;B.farePanel.SetAppearance(A);if(!C.disableAll&&!B.farePanel.FareSelected()&&C.IsAvailable(A)){B.farePanel.FireEvent(A.fareGroup,false)}}};FarePanel.prototype.FareMouseOut=function(G,C){var F=C.fareControl;var D=C.farePanel;if(StillInsideElementOnMouseOut(F,G)){return }if(F.fareGroup==undefined){return }F.hover=false;C.farePanel.SetAppearance(F);if((D.IsAvailable(F)||F.fareGroup.isDisabled)&&!D.disableAll&&!C.farePanel.FareSelected()){var E=G.relatedTarget||G.toElement;var H=(E==null||E==undefined);if(!H){var B=E;var A;var I;while(B!=undefined){if(HasClass(B,"FareLineEntry")){I=B}if(B.id==D.farePanelId){A=true;break}B=B.parentNode}H=(I==undefined||I.fareGroup==undefined||!D.IsAvailable(I)||!A)}if(H){C.farePanel.FireEvent(null,false)}}};FarePanel.prototype.SelectFare=function(D){var C;var B;var A;if(this.returnFareGroups.length==0){for(A=0;this.singleFareGroups[A]!=D;A++){if(!this.singleFareGroups[A]){return }}C=Math.floor(A/10);B=A%10}else{if(D.isReturn){for(A=0;this.returnFareGroups[A]!=D;A++){if(this.returnFareGroups[A]==undefined){return }}B=A%5+5}else{for(A=0;this.singleFareGroups[A]!=D;A++){if(this.singleFareGroups[A]==undefined){return }}B=A%5}C=Math.floor(A/5)}this.currentPage=C;this.UpdateDisplay();this.SetAvailableFares(null)};FarePanel.prototype.FareMouseClick=function(D,B){var A=B.fareControl;var C=B.farePanel;if(!C.IsAvailable(A)||C.disableAll){return }var E=null;if(!C.IsSelected(A.fareGroup)){E=C.GetSelectedControl()}B.farePanel.FireEvent(A.fareGroup,!C.IsSelected(A.fareGroup));if(E){C.SetAppearance(E)}B.farePanel.SetAppearance(A)};FarePanel.prototype.GetSelectedControl=function(){var A=this.GetFareControls();for(var B=0;B<A.length;B++){if(A[B].fareGroup&&this.IsSelected(A[B].fareGroup)){return A[B]}}return null};FarePanel.prototype.ClearSelection=function(){var A=this.GetSelectedControl();if(A){this.FireEvent(null,false);this.SetAppearance(A)}};FarePanel.prototype.CentreFareText=function(A,C,B){if(B){C.style.display="";C.style.clear=""}else{C.style.display="block";C.style.clear="both"}};FarePanel.prototype.FormatPrice=function(A){if(A%100==0){return"&pound;"+(A/100)}else{return"&pound;"+(A/100).toFixed(2)}};FarePanel.prototype.SetAvailableFares=function(A,D){var C;var B=this.GetFareControls();for(C in B){this.SetAppearance(B[C])}};FarePanel.prototype.IsFareGroupInService=function(C,A){for(var B in A.serviceFares){if(A.serviceFares[B].fgId==C){return true}}return false};FarePanel.prototype.SetTooltip=function(A){if(A.fareGroup==undefined){A.title="";return }var B=A.fareGroup.desc;if(!A.fareGroup.multiRoutes&&A.fareGroup.routeCode!="00000"){B+=mixingDeck.resourceStrings.validVia+this.routes[A.fareGroup.routeCode].routeDesc}if(A.fareGroup.railcardText!=undefined){B+=A.fareGroup.railcardText}if(this.IsAvailable(A)){A.title=B}else{if(A.fareGroup.isDisabled){A.title=B+mixingDeck.resourceStrings.isDisabled}else{A.title=B+mixingDeck.resourceStrings.notAvailable}}};FarePanel.prototype.GetFareControls=function(){if(this.fareControls==undefined){this.fareControls=YAHOO.util.Dom.getElementsByClassName("FareLineEntry",undefined,this.farePanelId)}return this.fareControls};FarePanel.prototype.SetAppearance=function(A){var F=0;var E;var C="";var D="0px 0px";this.SetTooltip(A);if(A.fareGroup==undefined){E=6}else{switch(A.fareGroup.isReturn){case true:switch(A.fareGroup.fClass){case"S":F=2;break;case"1":F=3;break}break;case false:switch(A.fareGroup.fClass){case"S":F=0;break;case"1":F=1;break}break}if(this.IsAvailable(A)==false||this.disableAll){C="#c7c7c7";if(A.hover){E=5}else{E=4}if(A.fareGroup.isDiscounted){D="0px -20px"}}else{if(this.IsSelected(A.fareGroup)){if(A.hover){E=3}else{E=2}}else{if(A.hover){E=1}else{E=0}}}if(A.hover){C="#002e4f"}}if(A.webFare.style.backgroundPosition!=D){A.webFare.style.backgroundPosition=D}if(A.style.color!=C){A.style.color=C}var B=(-62*E+1)+"px "+(-45*F-3)+"px";if(A.style.backgroundPosition!=B){A.style.backgroundPosition=B}};FarePanel.prototype.EnablePanel=function(){var A=document.getElementById(this.farePanelId);YAHOO.util.Dom.addClass(A,"PanelAvailable");this.isEnabled=true};FarePanel.prototype.IsAvailable=function(A){return !A.fareGroup.isDisabled&&A.fareGroup._available};FarePanel.prototype.IsSelected=function(A){return mixingDeck.journeyPlanningData.IsSelected(this.direction,A)};FarePanel.prototype.FareSelected=function(){return mixingDeck.journeyPlanningData._selectedFareGroup[this.direction].selected}