function TotalCostPanel(A){this.totalCostPanelId=A;this.transactionAdminCharge=0;this.serviceFares=new Object;this.serviceFares[outward]=undefined;this.serviceFares[inward]=undefined;this.fareGroup=new Object;this.fareGroup[outward]=undefined;this.fareGroup[inward]=undefined}TotalCostPanel.prototype.SetInitialData=function(A){this.Initialise();this.journeyPlanningData=A;if(A.data.txnAdminChg!=undefined){this.transactionAdminCharge=A.data.txnAdminChg}this.isReturn=A.data.isReturn;this.isOpenReturn=A.data.isReturn&&!A.data.returnDate;this.fares=A.data.fares;SetVisibility(this.allPassengersInclusive,this.journeyPlanningData.data.multiplePassengers)};TotalCostPanel.prototype.SetData=function(D,E,B){this.Initialise();this.fareGroup[D]=E;this.serviceFares[D]=B;if(this.CanBuy()){DisableWTButton(this.btnBuyNow,false);DisableWTButton(this.saveForLater,false);var C=this.GetFarePrice(this.fareGroup[outward],this.serviceFares[outward])+this.GetFarePrice(this.fareGroup[inward],this.serviceFares[inward]);var A=0;switch(this.journeyPlanningData.data.feeType){case"F":A=this.journeyPlanningData.data.fixedCostPence;break;case"T":A=this.GetFareAdminCharge(this.fareGroup[outward],this.serviceFares[outward])+this.GetFareAdminCharge(this.fareGroup[inward],this.serviceFares[inward]);break;case"X":A=this.CalculateTransactionFee(C,this.journeyPlanningData.data.minimumCostPence,this.journeyPlanningData.data.percentage,this.journeyPlanningData.data.roundToValuePence,this.journeyPlanningData.data.roundingRule);break}if(A>0){this.adminFee.innerHTML=this.adminFeeText+FormatPrice(A);this.ticketCost.innerHTML=this.ticketCostText+FormatPrice(C);SetVisibility(this.ticketCost,true);SetVisibility(this.adminFee,true)}else{SetVisibility(this.ticketCost,false);SetVisibility(this.adminFee,false)}this.totalCost.innerHTML=FormatPrice(A+C)}else{DisableWTButton(this.btnBuyNow,true);DisableWTButton(this.saveForLater,true);SetVisibility(this.ticketCost,false);SetVisibility(this.adminFee,false);this.totalCost.innerHTML=FormatPrice(0)}};TotalCostPanel.prototype.CanBuy=function(){var A=(typeof (this.fareGroup[outward])!="undefined");if(this.isOpenReturn){return A}A=(A&&(typeof (this.fareGroup[inward])!="undefined"||!this.isReturn));if(this.journeyPlanningData._selectedService[outward].service&&this.journeyPlanningData._selectedService[inward].service&&this.journeyPlanningData._selectedService[outward].service.aTime>=this.journeyPlanningData._selectedService[inward].service.dTime){A=false}return A};TotalCostPanel.prototype.SetVisibility=function(A,B){this.Initialise();if(B){YAHOO.util.Dom.addClass(this.totalCostPanel,"DisableCostPanel")}else{YAHOO.util.Dom.removeClass(this.totalCostPanel,"DisableCostPanel")}ShowElement(this.totalCostPanel,A)};TotalCostPanel.prototype.Initialise=function(){var A=null;if(this.totalCostPanel==undefined){this.totalCostPanel=document.getElementById(this.totalCostPanelId);this.ticketCost=YAHOO.util.Dom.getElementsByClassName("TicketCostLine",undefined,this.totalCostPanel)[0];this.ticketCostText=this.ticketCost.innerHTML;this.adminFee=YAHOO.util.Dom.getElementsByClassName("AdminFeeLine",undefined,this.totalCostPanel)[0];this.adminFeeText=this.adminFee.innerHTML;this.totalCost=YAHOO.util.Dom.getElementsByClassName("TotalCost",undefined,this.totalCostPanel)[0];this.allPassengersInclusive=YAHOO.util.Dom.getElementsByClassName("AllPassengersInclusive",undefined,this.totalCostPanel)[0];this.btnBuyNow=YAHOO.util.Dom.getElementsByClassName("limouse_d",undefined,this.totalCostPanel)[0].firstChild;A=YAHOO.util.Dom.getElementsByClassName("liarrowprfp_d",undefined,this.totalCostPanel);if(undefined!=A&&A!=null&&A.length>0){this.saveForLater=A[0].firstChild}}};TotalCostPanel.prototype.GetFarePrice=function(B,A){if(A==null){if(B==null){return 0}else{return B.maxFare}}else{return A.totFare}};TotalCostPanel.prototype.GetFareAdminCharge=function(B,A){if(A==null){if(B==null){return 0}else{if(B.fareAdminCharge!=undefined){return B.fareAdminCharge}else{return 0}}}else{if(A.fareAdminCharge!=undefined){return A.fareAdminCharge}else{return 0}}};TotalCostPanel.prototype.CalculateTransactionFee=function(E,B,C,F,D){var A=Math.floor(E*C/100);A=this.RoundValue(D,A,F);if(A<B){return B}else{return A}};TotalCostPanel.prototype.RoundValue=function(D,B,C){var A=B%C;if(A!=0){if(D=="U"){return B-A+C}else{if(D=="D"){return B-A}else{if(A<C/2){return B-A}else{return B-A+C}}}}else{return B}};TotalCostPanel.prototype.IsFareDiscounted=function(A){if(A==null){return false}else{return A.isDiscounted}}