var outward=0;var inward=1;function SeasonMixingDeck(){this.railDataProvider=new RailDataProvider();this.outwardFarePanel=new SeasonFarePanel("outwardJourney",outward,"outwardFareGroups");this.outwardServicePanel=new SeasonServicePanel("outwardServicePanel",outward,"outwardServices");this.inwardServicePanel=new SeasonServicePanel("inwardServicePanel",inward,"inwardServices");this.outwardChoicePanel=new SeasonChoicePanel("outwardChoicePanel",outward);this.totalCostPanel=new SeasonTotalCostPanel("totalCostPanel");this.stoppingPointPanel=new StoppingPointPanel("ctl00_mainContentPlaceHolder_stoppingPointPanel");this.filterPanel=new SeasonFilterPanel("filterControl");this.timeoutSet=false;this.outstandingEnquiry=new Object();this.startTime=0}SeasonMixingDeck.prototype.ProcessInitialData=function(B,C){if(B.complete){this.journeyPlanningData=new SeasonJourneyPlanningData(B);this.journeyPlanningData.SetPostbackControls(document.getElementById(this.hdnOutwardFareGroupId),document.getElementById(this.hdnInwardFareGroupId),document.getElementById(this.hdnOutwardServiceId),document.getElementById(this.hdnInwardServiceId));ShowElement(document.getElementById("pleaseWait"),false);this.journeyPlanningData.SetFarePanel(this.outwardFarePanel);this.journeyPlanningData.SetServicePanel(this.outwardServicePanel);this.journeyPlanningData.SetServicePanel(this.inwardServicePanel);this.StartTimeTableEnquiryExtension("O","E");this.StartTimeTableEnquiryExtension("O","L");this.StartTimeTableEnquiryExtension("R","E");this.StartTimeTableEnquiryExtension("R","L");this.journeyPlanningData.SetTotalCostPanel(this.totalCostPanel);this.journeyPlanningData.SetChoicePanel(this.outwardChoicePanel);this.journeyPlanningData.SetFitlerPanel(this.filterPanel);this.extensionState=0;this.filterPanel.SetVisibilityOfFlexibilityButtons(this.journeyPlanningData.data.outwardFareGroups,this.journeyPlanningData.data.inwardFareGroups);DisableWTButton(document.getElementById(this.btnOutwardPrev),!this.enableOutwardPrev);DisableWTButton(document.getElementById(this.btnOutwardNext),!this.enableOutwardNext);document.getElementById("outwardJourneyDate").innerHTML=B.outwardDate;helpPanels.DataLoaded(false);this.UpdateFilter();this.journeyPlanningData.SetSelectedData(this.journeyPlanningData);if(B.nrsFailure){this.nrsFailure=true;this.DisplayMessage(mixingDeck.resourceStrings.nrsFailure)}if(!this.debug){this.disableErrorReporting=true}}else{switch(B.status){case"expired":this.DisplayMessage(mixingDeck.resourceStrings.requestExpired);break;case"error":this.DisplayError("error in ProcessInitialData");break;case"no fares":this.DisplayMessage(mixingDeck.resourceStrings.noFares);break;case"no direct services":this.noDirectServices=true;this.DisplayMessage(mixingDeck.resourceStrings.noDirectServices);break;case"no smartcard fares found":this.noSmartcardFares=true;this.DisplayMessage(mixingDeck.resourceStrings.noSmartCardFares);break;default:var A=new Date()-this.startTime;if(A/1000>this.pollTimeout){this.DisplayError("Timeout in ProcessInitialData")}else{timer.SetTimer(this.standardPollInterval,this,this.PollForInitialData)}break}}};SeasonMixingDeck.prototype.PollForInitialData=function(){try{if(!this.bSubmitHooked){this.hookedOnSubmitFunction=document.forms[0].onsubmit;document.forms[0].onsubmit=OnSubmitMixingDeck;this.bSubmitHooked=true}this.railDataProvider.SetTimeout(this.pollTimeout*1000);this.railDataProvider.SetErrorFunction(this,"DisplayError");if(this.enquiryIds){this.railDataProvider.GetInitialFareData(this.enquiryIds,this,this.ProcessInitialData)}else{this.railDataProvider.GetInitialFareOnlyData(this,this.ProcessInitialData)}}catch(A){this.DisplayError("PollForInitialData",A)}};SeasonMixingDeck.prototype.ProcessStartEnquiryExtensionData=function(B,A){if(B.enquiryIds){A[2]=B.enquiryIds;A[3]=new Date();timer.SetTimer(this.standardPollInterval,this,this.PollForExtensionData,A)}else{if(this.debug){this.DisplayError("No returned service in ProcessStartEnquiryExtensionData")}else{this.HandleReturnedError(A[0],A[1])}}};SeasonMixingDeck.prototype.StartTimeTableEnquiryExtension=function(C,B){if(this.journeyPlanningData.AllDataReceived(C,B)){return false}if(!this.outstandingEnquiry[C+B]){this.outstandingEnquiry[C+B]=true;try{this.railDataProvider.StartFTAEnquiryExtension(C,B,this,this.ProcessStartEnquiryExtensionData)}catch(A){if(this.debug){this.DisplayError("StartTimeTableEnquiryExtension",A)}return false}}return true};SeasonMixingDeck.prototype.HandleReturnedError=function(B,A){if(this.journeyPlanningData&&this.journeyPlanningData.servicePanel[B]){this.journeyPlanningData.servicePanel[B].ShowGettingServiceData(false)}this.outstandingEnquiry[(B==0?"O":"R")+A]=false};SeasonMixingDeck.prototype.ProcessExtensionData=function(C,B){if(C.complete){this.journeyPlanningData.AddFTAEnquiryExtensionData(C,B[0],B[1]);this.outstandingEnquiry[(B[0]==0?"O":"R")+B[1]]=false;this.UpdateFilter()}else{if(C.status=="error"){if(this.debug){this.DisplayError("error in ProcessExtensionData")}else{this.HandleReturnedError(B[0],B[1])}}else{var A=new Date()-B[3];if(A/1000>this.pollTimeout){this.DisplayError("timeout in ProcessExtensionData")}else{timer.SetTimer(this.standardPollInterval,this,this.PollForExtensionData,B)}}}};SeasonMixingDeck.prototype.DisplayError=function(A,C){var B;if(this.debug){if(C){B=A+" "+C.name+" "+C.message}else{B=A}}else{B=this.resourceStrings.errorMessage}this.DisplayMessage(B)};SeasonMixingDeck.prototype.DisplayMessage=function(B){if(this.disableErrorReporting){return }var C=document.getElementById(this.divDisableScreenId);if(B!=null){var A=YAHOO.util.Dom.getElementsByClassName("ErrorMessage",undefined,C)[0];A.innerHTML=B}ShowElement(document.getElementById("pleaseWait"),false);if(this.journeyPlanningData){if(this.journeyPlanningData.servicePanel[outward]){this.journeyPlanningData.servicePanel[outward].ShowGettingServiceData(false)}if(this.journeyPlanningData.servicePanel[inward]){this.journeyPlanningData.servicePanel[inward].ShowGettingServiceData(false)}}ticketSearchControl.ShowTicketSearchControl(false);YAHOO.util.Dom.removeClass(C,"Transparent");YAHOO.util.Dom.addClass(C,"ErrorOverlay");ShowElement(C,true)};SeasonMixingDeck.prototype.ShowTransparentDiv=function(A){var C=document.getElementById(this.divDisableScreenId);var B=document.getElementById("rightcolumnPH");disabledScreenShowing=A;if(A){YAHOO.util.Dom.addClass(C,"Transparent");YAHOO.util.Dom.removeClass(C,"ErrorOverlay");B.style.zIndex="50"}else{if(!showingSavedJourneys){B.style.zIndex="0"}}ShowElement(C,A)};SeasonMixingDeck.prototype.OnErrorContinue=function(){if(this.nrsFailure){this.ShowTransparentDiv(false)}else{this.ShowTransparentDiv(true);ticketSearchControl.DisableClose();if(this.noDirectServices){ticketSearchControl.SearchForNonDirectTrains()}else{if(this.noSmartcardFares){ticketSearchControl.SearchForNonSmartcardFares()}else{ticketSearchControl.ShowTicketSearchControl(true)}}}};SeasonMixingDeck.prototype.DisableErrorReporting=function(){this.disableErrorReporting=true};SeasonMixingDeck.prototype.PollForExtensionData=function(A){try{this.railDataProvider.CheckForFTAExtensionCompletion(A[2],this,this.ProcessExtensionData,A)}catch(B){if(this.debug){this.DisplayError("PollForExtensionData",B)}}};SeasonMixingDeck.prototype.SetFlexibility=function(A){this.showingFlexible=A;this.UpdateFilter()};SeasonMixingDeck.prototype.ShowStandard=function(A){this.showingStandard=A};SeasonMixingDeck.prototype.ShowFirst=function(A){this.showingFirst=A};SeasonMixingDeck.prototype.ShowWeekly=function(A){this.showingWeekly=A};SeasonMixingDeck.prototype.ShowMonthly=function(A){this.showingMonthly=A};SeasonMixingDeck.prototype.ShowAnnual=function(A){this.showingAnnual=A};SeasonMixingDeck.prototype.ShowCustom=function(A){this.showingCustom=A};SeasonMixingDeck.prototype.UpdateFilter=function(){if(this.journeyPlanningData){this.journeyPlanningData.SetFlexibility(this.showingFlexible,this.showingStandard,this.showingFirst,this.showingWeekly,this.showingMonthly,this.showingAnnual,this.showingCustom,this.showingOnlySmartCardFares)}};SeasonMixingDeck.prototype.OnUpdate=function(){this.filterPanel.OnUpdate()};SeasonMixingDeck.prototype.ProcessKeepAliveMessage=function(B,A){};SeasonMixingDeck.prototype.CheckKeepAliveTimeout=function(){var A=(new Date()-this.railDataProvider.lastCommunication)/1000;if(A>this.keepAliveInterval){try{this.railDataProvider.SendKeepAliveMessage(this,this.ProcessKeepAliveMessage)}catch(B){if(this.debug){this.DisplayError("CheckKeepAliveTimeout",B)}}}};SeasonMixingDeck.prototype.ProcessStoppingPoints=function(B,A){if(B.status=="error"){if(this.debug){this.DisplayError("Error in ProcessStoppingPoints")}else{this.stoppingPointPanel.HidePanel()}}else{this.journeyPlanningData.AddStoppingPoints(B);this.stoppingPointPanel.StoppingPointsReceived()}};SeasonMixingDeck.prototype.ShowServiceInformation=function(B,A,D){this.stoppingPointPanel.ShowPanel(B,A,D);if(B.stoppingPoints==undefined){try{this.railDataProvider.GetStoppingPoints(B,this,this.ProcessStoppingPoints,null,false)}catch(C){this.stoppingPointPanel.HidePanel();if(this.debug){this.DisplayError("ShowServiceInformation",C)}}}};SeasonMixingDeck.prototype.OnShowCheaperFares=function(A){this.journeyPlanningData.OnShowCheaperFares(A)};SeasonMixingDeck.prototype.OnShowMoreExpensiveFares=function(A){this.journeyPlanningData.OnShowMoreExpensiveFares(A)};SeasonMixingDeck.prototype.GetServiceId=function(A){if(A!=undefined){return A.serviceId}else{return undefined}};SeasonMixingDeck.prototype.OnRouteClicked=function(A){this.filterPanel.OnRouteClicked(A)};SeasonMixingDeck.prototype.GetFareGroupId=function(A){if(A!=undefined){return A.fareGroupId}else{return undefined}};SeasonMixingDeck.prototype.ShowOnlySmartCardFares=function(A){this.showingOnlySmartCardFares=A};SeasonMixingDeck.prototype.HandleSaveResponse=function(A){};SeasonMixingDeck.prototype.ClearPendingSavedJourney=function(){try{this.railDataProvider.ClearPendingSavedJourney(this,this.HandleSaveResponse)}catch(A){if(this.debug){this.DisplayError("ClearPendingSavedJourney",A)}}};SeasonMixingDeck.prototype.DisplayImmediateErrorMessage=function(){this.DisplayMessage(this.errorMessageToDisplay)};var mixingDeck=new SeasonMixingDeck();function OnSubmitMixingDeck(A){mixingDeck.DisableErrorReporting();if(mixingDeck.hookedOnSubmitFunction){mixingDeck.hookedOnSubmitFunction(A)}}function InitialiseSeasonMixingDeck(){if(BrowserDetect.browser=="Explorer"){try{if(document.execCommand){document.execCommand("BackgroundImageCache",false,true)}}catch(A){}}mixingDeck.startTime=new Date();if(mixingDeck.mode=="Display"&&!mixingDeck.errorMessageToDisplay){ShowElement(document.getElementById("pleaseWait"),true);timer.SetTimer(mixingDeck.initialPollInterval,mixingDeck,mixingDeck.PollForInitialData);mixingDeck.filterPanel.Show(true);mixingDeck.totalCostPanel.SetVisibility(true,true);timer.SetTimer(3000,helpPanels,helpPanels.ShowFarePanel);LoadAllImages()}}