(function(){var F=[],C="mousedown",E="click";var I=function(){var L=$D.getElementsByClassName("ss-ancpanel"),K=SS.factories.ItineraryFactory.getItinerary();F=$D.getElementsByClassName("ss-anclink");K.itineraryChanged.subscribe(B,this,true);B();$E.addListener(L,"mousedown",D,{eventName:C});$E.addListener(L,"click",D,{eventName:E})};var D=function(O,M){try{var P=$E.getTarget(O),K=M.eventName,L;while(P&&!$D.hasClass(P,"ss-ancpanel")){L=P.tagName.toUpperCase();if(L==="A"&&$D.hasClass(P,"ss-anclink")){G(O,P,K);break}else{P=P.parentNode}}}catch(N){$log("Error during ancillaries panel click: "+N.message)}};var G=function(N,K,L){var M=H(K),O=K.getAttribute("target");switch(L){case C:if(!J(K)){SS.services.Contrail.logAncillaryRedirect(K.getAttribute("category"))}break;case E:K.setAttribute("href",M);if(O==="_blank"){window.open(M)}else{location.href=M}$E.stopEvent(N);break}};var J=function(K){var L=(null!==$D.getAncestorByClassName(K,"selected"));return L};var B=function(){var L=0,M=F.length,K;for(;L<M;L++){K=F[L];if(!J(K)){K.setAttribute("href",H(K))}}};var H=function(R){var M=R.getAttribute("category"),T=SS.factories.ItineraryFactory.getItinerary(),Q=SS.factories.SessionFactory.getSession(),O={},P=[],K=R.getAttribute("rooturl"),S,N,L;O.oplace=SS.services.LookupService.getIATACityID(T.oPlaceId);O.iplace=SS.services.LookupService.getIATACityID(T.iPlaceId);O.f_oplace=O.oplace;O.f_iplace=O.iplace;O.f_oa=T.oPlaceId.length==3?"1":"";O.f_ia=T.iPlaceId.length==3?"1":"";if(!T.wholeYear){N=T.oDatecode;if(T.flexibleDates){N=N.substring(0,4)}O.odate=N;O.f_odate=N;if(T.isReturn){N=T.iDatecode;if(T.flexibleDates){N=N.substring(0,4)}O.idate=N;O.f_idate=N}else{if(!T.flexibleDates){oDate=new Date();oDate.setFullYear("20"+N.substring(0,2),N.substring(2,4)-1,N.substring(4,6));oDate.setDate(oDate.getDate()+7);N=SS.util.toDateCode(oDate);O.idate=N;O.f_idate=N}}}O.adults=T.adults;O.children=T.children;O.infants=T.infants;O.f_adults=T.adults;O.f_children=T.children;O.f_infants=T.infants;O.ucy=Q.ucy;O.lang=Q.language;O.ccy=Q.currency;O.view=Q.view;O.mode=Q.mode;if(Q.semid!=""){O.semid=Q.semid;if(Q.semoplace){O.oplace=SS.services.LookupService.getIATACityID(O.semid);O.f_oplace=O.oplace;O.f_oa=O.semid.length==3?"1":""}}if(Q.set1>0){O.set1=Q.set1}if(Q.set2>0){O.set2=Q.set2}if(Q.set3>0){O.set3=Q.set3}O.owfc=Q.owfc;O.iwfc=Q.iwfc;O.oqrid=Q.oqrid;O.iqrid=Q.iqrid;O.days=Q.days;O.targetleg=Q.leg;O.si=document.location.href.match(/si=1/)?"1":"";O.rtn=T.isReturn?"1":"0";O.f_rtn=O.rtn;O.infopage=Q.infopage;O.rurl=Q.rurl;L=SS.util.appendParamToUrl(K,"anccat",M);for(S in O){if(O[S]!=""){L=SS.util.appendParamToUrl(L,"s-"+S,O[S])}}L=A(R,L);return L};var A=function(M,L){var K=M.getAttribute("bookingSpecificOPlace"),O=M.getAttribute("bookingSpecificIPlace"),P=M.getAttribute("bookingSpecificODate"),N=M.getAttribute("bookingSpecificIDate");if(K){K=K.toLowerCase();L=L.replace(/(s-oplace=)[^&]{3,4}/,"$1"+K);L=L.replace(/(s-f_oplace=)[^&]{3,4}/,"$1"+K)}if(O){O=O.toLowerCase();L=L.replace(/(s-iplace=)[^&]{3,4}/,"$1"+O);L=L.replace(/(s-f_iplace=)[^&]{3,4}/,"$1"+O)}if(P){L=L.replace(/(s-odate=)[^&]{6}/,"$1"+P);L=L.replace(/(s-f_odate=)[^&]{6}/,"$1"+P)}if(N){L=L.replace(/(s-idate=)[^&]{6}/,"$1"+N);L=L.replace(/(s-f_idate=)[^&]{6}/,"$1"+N)}return L};$E.onDOMReady(I)}());