function SeasonJourneyPlanningData(A,B){this.allServicesReceived={"O":{"E":false,"L":false},"R":{"E":false,"L":false}};this.data=A;this.timetableOnly=B;if(!mixingDeck.showServices){this.data.outwardServices=null;this.data.inwardServices=null}this.farePanel=new Object();this.servicePanel=new Object();this.SetFareGroupIds(this.data.outwardFareGroups);this.SetFareGroupIds(this.data.inwardFareGroups);this.SetServiceIds(this.data.outwardServices,"O");this.SetServiceIds(this.data.inwardServices,"R");this.OrderFares();this.flexibility=3;this.bShowStandard=true;this.bShowFirst=true;this.isPromo=false;this._selectedFareGroup=new Object();this._selectedFareGroup[outward]=new Object();this._selectedFareGroup[inward]=new Object();this._selectedService=new Object();this._selectedService[outward]=new Object();this._selectedService[inward]=new Object();this.SetServiceArrays();this.SetAvailability()}SeasonJourneyPlanningData.prototype.SetPostbackControls=function(A,D,B,C){this.fareGroupPostbackControl=new Object();this.servicePostbackControl=new Object();this.fareGroupPostbackControl[outward]=A;this.fareGroupPostbackControl[inward]=D;this.servicePostbackControl[outward]=B;this.servicePostbackControl[inward]=C};SeasonJourneyPlanningData.prototype.SetServicePanel=function(A){this.servicePanel[A.direction]=A;var B;if(A.direction==outward){B=this.allServicesReceived["O"]["E"]&&this.allServicesReceived["O"]["L"]}else{B=this.allServicesReceived["R"]["E"]&&this.allServicesReceived["R"]["L"]}A.ShowServices(this.data[A.panelDataName],B)};SeasonJourneyPlanningData.prototype.SetFarePanel=function(A){this.farePanel[A.direction]=A;A.AddEventListener(this,this.OnFarePanelChanged);A.AddRolloverListener(this)};SeasonJourneyPlanningData.prototype.SetTotalCostPanel=function(A){this.totalCostPanel=A;this.totalCostPanel.SetInitialData(this);this.totalCostPanel.SetVisibility(true)};SeasonJourneyPlanningData.prototype.SetChoicePanel=function(A){if(this.choicePanel==undefined){this.choicePanel=new Object()}this.choicePanel[A.direction]=A;A.SetTotalCostPanel(this.totalCostPanel);A.SetJourneyData(this);A.SetVisibility(true)};SeasonJourneyPlanningData.prototype.SetFitlerPanel=function(A){this.filterPanel=A;this.filterPanel.SetRoutes(this.data.routes);this.filterPanel.SetIsPromotion(this.data.isPromo)};SeasonJourneyPlanningData.prototype.UpdateChooseFare=function(A,B){if(A==inward){this.choicePanel[outward].UpdateChooseFare(B)}else{this.choicePanel[outward].UpdateChooseFare(false)}};SeasonJourneyPlanningData.prototype.UpdateChooseService=function(A,B){if(A==inward){this.choicePanel[outward].UpdateChooseService(B);this.choicePanel[inward].UpdateChooseService(false)}else{this.choicePanel[outward].UpdateChooseService(false);this.choicePanel[inward].UpdateChooseService(B)}this.choicePanel[outward].UpdateChooseFare(B);this.choicePanel[inward].UpdateChooseFare(B)};SeasonJourneyPlanningData.prototype.OnFarePanelChanged=function(E,G){var H=G[0];var B=G[1];var C=G[2];var F=this._selectedFareGroup[outward].fareGroup&&this._selectedFareGroup[outward].fareGroup.isReturn;this.SelectFareGroup(H,B,B?C:false);var A=this._selectedFareGroup[outward].selected?this._selectedFareGroup[outward].fareGroup:null;var D=this._selectedFareGroup[inward].selected?this._selectedFareGroup[inward].fareGroup:null;if(A){this.fareGroupPostbackControl[outward].value=A.fareGroupId}else{this.fareGroupPostbackControl[outward].value=""}if(D&&(A==null||!A.isReturn)){this.fareGroupPostbackControl[inward].value=D.fareGroupId}else{this.fareGroupPostbackControl[inward].value=""}this.servicePanel[H].SetAvailableServices(B);this.choicePanel[H].UpdateDisplay();if(this.data.returnDate){this.servicePanel[inward].SetAvailableServices(this._selectedFareGroup[inward])}var I=(this.farePanel[H].inRollOver&&!C);this.UpdateChooseFare(H,I);mixingDeck.CheckKeepAliveTimeout()};SeasonJourneyPlanningData.prototype.OnShowCheaperFares=function(A){this.farePanel[A].OnShowCheaperFares();this.farePanel[A].SetAvailableFares(this._selectedService[A].service)};SeasonJourneyPlanningData.prototype.OnShowMoreExpensiveFares=function(A){this.farePanel[A].OnShowMoreExpensiveFares();this.farePanel[A].SetAvailableFares(this._selectedService[A].service)};SeasonJourneyPlanningData.prototype.SetFareGroupIds=function(B){for(var A in B){B[A].fareGroupId=A;B[A].selected=false}};SeasonJourneyPlanningData.prototype.SetServiceIds=function(B,C,D){var E=0;for(var A in B){B[A].serviceId=A;if(B[A].firstInDay){this.allServicesReceived[C]["E"]=true}if(B[A].lastInDay){this.allServicesReceived[C]["L"]=true}E++}if(E==0){if(D){this.allServicesReceived[C][D]=true}else{this.allServicesReceived[C]["E"]=true;this.allServicesReceived[C]["L"]=true}}};SeasonJourneyPlanningData.prototype.OrderFares=function(){this.orderedFares=new Object();this.orderedFares.outward=new Object();this.orderedFares.outward.singles=new Array();this.orderedFares.outward.returns=new Array();for(var A in this.data.outwardFareGroups){if(this.data.outwardFareGroups[A].isReturn){this.orderedFares.outward.returns[this.orderedFares.outward.returns.length]=this.data.outwardFareGroups[A]}else{this.orderedFares.outward.singles[this.orderedFares.outward.singles.length]=this.data.outwardFareGroups[A]}}this.orderedFares.inward=new Object();this.orderedFares.inward.singles=new Array();for(A in this.data.inwardFareGroups){this.orderedFares.inward.singles[this.orderedFares.inward.singles.length]=this.data.inwardFareGroups[A]}this.orderedFares.outward.singles.sort(this.CompareFares);this.orderedFares.outward.returns.sort(this.CompareFares);this.orderedFares.inward.singles.sort(this.CompareFares)};SeasonJourneyPlanningData.prototype.AddFTAEnquiryExtensionData=function(D,C,B){var A;this.SetFareGroupIds(D.outwardFareGroups);this.SetFareGroupIds(D.inwardFareGroups);this.AddElements(D,"fares");this.AddElements(D,"locations");this.AddElements(D,"tocs");if(C==outward){this.SetServiceIds(D.outwardServices,"O",B);this.AddElements(D,"outwardServices")}else{this.SetServiceIds(D.inwardServices,"R",B);this.AddElements(D,"inwardServices")}if(!this.timetableOnly&&(D.outwardFareGroups!=undefined||D.inwardFareGroups!=undefined)){this.AddFareGroupElements(D,"outwardFareGroups");this.AddFareGroupElements(D,"inwardFareGroups");this.OrderFares()}this.SetServiceArrays();this.SetAvailability();if(C==outward){A=this.allServicesReceived["O"]["E"]&&this.allServicesReceived["O"]["L"];this.servicePanel[outward].AddServices(D.outwardServices,B=="E",A)}else{A=this.allServicesReceived["R"]["E"]&&this.allServicesReceived["R"]["L"];this.servicePanel[inward].AddServices(D.inwardServices,B=="E",A)}if(!this.timetableOnly&&(D.outwardFareGroups!=undefined||D.inwardFareGroups!=undefined)){this.SetFlexibility()}};SeasonJourneyPlanningData.prototype.AddElements=function(B,A){for(var C in B[A]){if(!this.data[A][C]){this.data[A][C]=B[A][C]}}};SeasonJourneyPlanningData.prototype.AddFareGroupElements=function(B,A){for(var C in B[A]){if(!this.data[A][C]){this.data[A][C]=B[A][C]}else{this.data[A][C].isDisabled=B[A][C].isDisabled;this.data[A][C].isDiscounted=B[A][C].isDiscounted;this.data[A][C].minFare=B[A][C].minFare;this.data[A][C].maxFare=B[A][C].maxFare}}};SeasonJourneyPlanningData.prototype.AddStoppingPoints=function(A){if(this.data.outwardServices[A.sId]!=undefined){this.data.outwardServices[A.sId].stoppingPoints=A}else{if(this.data.inwardServices[A.sId]!=undefined){this.data.inwardServices[A.sId].stoppingPoints=A}}};SeasonJourneyPlanningData.prototype.AllDataReceived=function(B,A){return this.allServicesReceived[B][A]};SeasonJourneyPlanningData.prototype.SetFlexibility=function(H,I,G,A,B,J,D,E){if(H!=undefined){this.flexibility=H}if(I!=undefined){this.bShowStandard=I}if(G!=undefined){this.bShowFirst=G}if(E!=undefined){this.bShowITSOSmartcardFares=E}var K;this.isPromo=false;switch(this.flexibility){case 0:this.isPromo=true;break;case 1:K="N";break;case 2:K="NP";break}var C=this.FilterTickets(outward,this.orderedFares.outward.singles,K,this.bShowStandard,this.bShowFirst,this.isPromo,A,B,J,D,E);var F=this.FilterTickets(outward,this.orderedFares.outward.returns,K,this.bShowStandard,this.bShowFirst,this.isPromo,A,B,J,D,E);this.SetFarePanelData(this.farePanel[outward],C,F);this.farePanel[outward].SetAvailableFares(this._selectedService[outward].service,this._selectedService[inward].service);this.farePanel[outward].SetAvailableFares(this._selectedService[inward].service)};SeasonJourneyPlanningData.prototype.SetSeasonFilter=function(D,C,B,E){var A=this.FilterSeasonType(this.orderedFares.outward.singles,D,C,B,E);var F=this.FilterSeasonType(this.orderedFares.outward.returns,D,C,B,E);this.SetFarePanelData(this.farePanel[outward],A,F)};SeasonJourneyPlanningData.prototype.FilterTickets=function(I,C,N,K,G,L,A,B,J,E,D){var M=new Array();for(var H in C){var F=false;if(L){if(C[H].isPromo){F=true}}else{if(N==undefined){F=true}else{if(N.indexOf(C[H].flex)!=-1){F=true}}}if(C[H].fClass=="S"&&!K){F=false}if(C[H].fClass=="1"&&!G){F=false}if(C[H].sClass=="W"&&!A){F=false}if(C[H].sClass=="M"&&!B){F=false}if(C[H].sClass=="A"&&!J){F=false}if(C[H].sClass=="C"&&!E){F=false}if((!(C[H].isSmartcardFare)&&D)){F=false}if(F){M.push(C[H])}else{if(C[H].selected){C[H].selected=false;this.OnFarePanelChanged(null,[I,null])}}}return M};SeasonJourneyPlanningData.prototype.FilterSeasonType=function(A,D,C,B,F){var H=new Array();for(var G in A){var E=true;if(A[G].sClass=="W"&&!D){E=false}if(A[G].sClass=="M"&&!C){E=false}if(A[G].sClass=="A"&&!B){E=false}if(A[G].sClass=="C"&&!F){E=false}if(E){H.push(A[G])}else{if(A[G].selected){A[G].selected=false;this.OnFarePanelChanged(null,[direction,null])}}}return H};SeasonJourneyPlanningData.prototype.SetFarePanelData=function(A,B,C){if(A.direction==outward){if(this.data.isReturn){if(this.data.returnDate==undefined){A.SetData(C,new Array(),this.data.routes)}else{A.SetData(B,C,this.data.routes)}}else{A.SetData(B,new Array(),this.data.routes)}}else{A.SetData(B,new Array(),this.data.routes)}A.UpdateDisplay()};SeasonJourneyPlanningData.prototype.SetSelectedData=function(){this.SetSelectedServicesAndFares(this.GetSelectedFareGroup(this.data.outwardFareGroups),this.GetSelectedFareGroup(this.data.inwardFareGroups),this.GetSelectedService(this.data.outwardServices),this.GetSelectedService(this.data.inwardServices))};SeasonJourneyPlanningData.prototype.SetSelectedServicesAndFares=function(A,D,B,C){this._selectedFareGroup[outward].fareGroup=A;this._selectedFareGroup[outward].selected=(A!=null);this._selectedFareGroup[inward].fareGroup=D;this._selectedFareGroup[inward].selected=(D!=null);this._selectedService[outward].service=B;this._selectedService[outward].selected=(B!=null);this._selectedService[inward].service=C;this._selectedService[inward].selected=(C!=null);this.SetAvailability();if(this.filterPanel){if(A){this.filterPanel.SetClassAndFlexibility(A.fClass,A.flex)}if(D){this.filterPanel.SetClassAndFlexibility(D.fClass,D.flex)}}if(this.farePanel[outward]){if(A){this.farePanel[outward].SelectFare(A);this.servicePanel[outward].SetAvailableServices(A);this.servicePanel[inward].SetAvailableServices(D)}else{this.farePanel[outward].ClearSelection();this.servicePanel[outward].SetAvailableServices(null);this.servicePanel[inward].SetAvailableServices(null)}}if(B){this.servicePanel[outward].SelectService(B)}else{this.servicePanel[outward].ClearSelection();if(mixingDeck.outwardDateTime){this.servicePanel[outward].ScrollToShowTime(mixingDeck.outwardDateTime,mixingDeck.outwardDepartAfter)}}if(C){this.servicePanel[inward].SelectService(C)}else{this.servicePanel[inward].ClearSelection();if(mixingDeck.returnDateTime){this.servicePanel[inward].ScrollToShowTime(mixingDeck.returnDateTime,mixingDeck.returnDepartAfter)}}if(this.choicePanel&&this.choicePanel[outward]){this.choicePanel[outward].UpdateDisplay();this.choicePanel[outward].UpdateChooseFare(false)}if(this.choicePanel&&this.choicePanel[inward]){this.choicePanel[inward].UpdateDisplay();this.choicePanel[inward].UpdateChooseFare(false)}this.SetPostbackDetails()};SeasonJourneyPlanningData.prototype.GetSelectedService=function(B){for(var A in B){if(B[A].isSel){return B[A]}}return null};SeasonJourneyPlanningData.prototype.GetSelectedFareGroup=function(B){for(var A in B){if(B[A].isSel){return B[A]}}return null};SeasonJourneyPlanningData.prototype.SetServiceArrays=function(){this.outwardServiceArray=new Array();for(var A in this.data.outwardServices){this.outwardServiceArray.push(this.data.outwardServices[A])}this.outwardServiceArray.sort(this.CompareDepartureTimes);this.inwardServiceArray=new Array();for(A in this.data.inwardServices){this.inwardServiceArray.push(this.data.inwardServices[A])}this.inwardServiceArray.sort(this.CompareDepartureTimes)};SeasonJourneyPlanningData.prototype.CompareDepartureTimes=function(B,A){if(B.dTime>A.dTime){return 1}else{if(B.dTime<A.dTime){return -1}else{return 0}}};SeasonJourneyPlanningData.prototype.CompareFares=function(B,A){if(B.minFare>A.minFare){return 1}if(B.minFare<A.minFare){return -1}else{if(B.maxFare>A.maxFare){return 1}}if(B.maxFare<A.maxFare){return -1}else{return 0}};SeasonJourneyPlanningData.prototype.SelectFareGroup=function(B,C,A){if(A){this._selectedFareGroup[B].fareGroup=C;this._selectedFareGroup[B].selected=true;this.SetAvailability()}else{if(!this._selectedFareGroup[B].selected){this._selectedFareGroup[B].fareGroup=C;this._selectedFareGroup[B].selected=false;this.SetAvailability()}else{if(this._selectedFareGroup[B].fareGroup==C){this._selectedFareGroup[B].fareGroup=C;this._selectedFareGroup[B].selected=false;this.SetAvailability()}}}this.SetPostbackDetails()};SeasonJourneyPlanningData.prototype.SelectService=function(C,A,B){if(B){this._selectedService[C].service=A;this._selectedService[C].selected=true}else{if(!this._selectedService[C].selected||this._selectedService[C].service==A){this._selectedService[C].service=A;this._selectedService[C].selected=false}}this.SetAvailability();this.SetPostbackDetails()};SeasonJourneyPlanningData.prototype.SetAvailability=function(){var B;var A;for(A in this.outwardServiceArray){if(this._selectedFareGroup[outward].fareGroup){B=this.GetServiceFare(this._selectedFareGroup[outward].fareGroup.fareGroupId,this.outwardServiceArray[A]);this.outwardServiceArray[A]._available=(B!=null);this.outwardServiceArray[A]._serviceFare=(B!=null)?B.totFare:undefined;this.outwardServiceArray[A].isDiscounted=this.IsDiscounted(B)}else{this.outwardServiceArray[A]._available=true;this.outwardServiceArray[A].isDiscounted=false}}for(A in this.inwardServiceArray){if(this._selectedFareGroup[outward].fareGroup&&this._selectedFareGroup[outward].fareGroup.isReturn){B=this.GetServiceFare(this._selectedFareGroup[outward].fareGroup.fareGroupId,this.inwardServiceArray[A]);this.inwardServiceArray[A]._available=(B!=null);this.inwardServiceArray[A]._serviceFare=undefined;this.inwardServiceArray[A].isDiscounted=this.IsDiscounted(B)}else{if(this._selectedFareGroup[inward].fareGroup){B=this.GetServiceFare(this._selectedFareGroup[inward].fareGroup.fareGroupId,this.inwardServiceArray[A]);this.inwardServiceArray[A]._available=(B!=null);this.inwardServiceArray[A]._serviceFare=(B!=null)?B.totFare:undefined;this.inwardServiceArray[A].isDiscounted=this.IsDiscounted(B)}else{this.inwardServiceArray[A]._available=true;this.inwardServiceArray[A]._serviceFare=undefined;this.inwardServiceArray[A].isDiscounted=false}}}var D;for(D in this.orderedFares.outward.singles){if(this._selectedService[outward].service){B=this.GetServiceFare(this.orderedFares.outward.singles[D].fareGroupId,this._selectedService[outward].service);this.orderedFares.outward.singles[D]._available=(B!=null)}else{this.orderedFares.outward.singles[D]._available=true}}for(D in this.orderedFares.outward.returns){var C=true;if(this._selectedService[outward].service){B=this.GetServiceFare(this.orderedFares.outward.returns[D].fareGroupId,this._selectedService[outward].service);C=(B!=null)}if(this._selectedService[inward].service&&C){B=this.GetServiceFare(this.orderedFares.outward.returns[D].fareGroupId,this._selectedService[inward].service);C=(B!=null)}this.orderedFares.outward.returns[D]._available=C}for(D in this.orderedFares.inward.singles){if(this._selectedFareGroup[outward].fareGroup&&this._selectedFareGroup[outward].fareGroup.isReturn){}else{if(this._selectedService[inward].service){B=this.GetServiceFare(this.orderedFares.inward.singles[D].fareGroupId,this._selectedService[inward].service);this.orderedFares.inward.singles[D]._available=(B!=null)}else{this.orderedFares.inward.singles[D]._available=true}}}if(this._selectedService[inward].service&&this._selectedService[inward].service.selected&&!this._selectedService[inward].service._available){this._selectedFareGroup[inward].fareGroup.selected=false;this._selectedFareGroup[inward].selected=false;this.OnFarePanelChanged(null,[inward,null,false])}};SeasonJourneyPlanningData.prototype.GetServiceFare=function(C,A){for(var B in A.serviceFares){if(parseInt(A.serviceFares[B].fgId)+1==C||parseInt(A.serviceFares[B].fgId)==C){return A.serviceFares[B]}}return null};SeasonJourneyPlanningData.prototype.IsDiscounted=function(B){if(!B){return false}if(B.isDiscounted==undefined){B.isDiscounted=false;for(var A in B.fareIds){if(this.data.fares[B.fareIds[A]].isDiscounted){B.isDiscounted=true;break}}}return B.isDiscounted};SeasonJourneyPlanningData.prototype.IsSelected=function(A,B){if(this._selectedFareGroup[A].fareGroup==B){return this._selectedFareGroup[A].selected}else{return false}};SeasonJourneyPlanningData.prototype.SetPostbackDetails=function(){if(this.fareGroupPostbackControl&&this.fareGroupPostbackControl[outward]){if(this._selectedFareGroup[outward].selected){this.fareGroupPostbackControl[outward].value=this._selectedFareGroup[outward].fareGroup.fareGroupId}else{this.fareGroupPostbackControl[outward].value=""}}if(this.fareGroupPostbackControl&&this.fareGroupPostbackControl[inward]){if(!this._selectedFareGroup[outward].selected||!this._selectedFareGroup[outward].fareGroup.isReturn){if(this._selectedFareGroup[inward].selected){this.fareGroupPostbackControl[inward].value=this._selectedFareGroup[inward].fareGroup.fareGroupId}else{this.fareGroupPostbackControl[inward].value=""}}else{this.fareGroupPostbackControl[inward].value=""}}this.SetPostbackService(outward);this.SetPostbackService(inward)};SeasonJourneyPlanningData.prototype.SetPostbackService=function(A){if(!this._selectedService[A].selected){this.servicePostbackControl[A].value=""}else{this.servicePostbackControl[A].value=this._selectedService[A].service.serviceId}}