/*
	Compressed from: general.jquery.js
	On: 22/06/2009 16:50
	For licences see individual files
*/


function jQueryInit(){search.init();jQuery("#dest_guide_list").makeAbsolute(true);magicMap.init(jQuery("#destinationMapLarge.world"));magicMap.init(jQuery("#top-destination"));jQuery(".showJsOnly").removeClass("showJsOnly");jQuery(".renderHidden").removeClass("renderHidden");jQuery(".renderVisible").removeClass("renderVisible");jQuery("div.videoTitle a").each(function(){var C=jQuery(this).html();jQuery(this).html(truncate(C,16))});jQuery("a.nb").nb();jQuery("#print").click(function(C){self.print();C.preventDefault()});var A=jQuery("#SEOIntro").html();if(A!==null){var B=templates.SEOIntroPlaceholder.tpl({html:A});jQuery("#contentBox").append(B);jQuery("#SEOIntro").remove()}}var magicMap={vars:{elem:null,mapEnabled:false,allMaps:null},init:function(A){if(A.length==0){return }this.vars.elem=A;this.initLabels();this.initMap()},initMap:function(){var A=jQuery("#continents li.renderHidden");this.vars.allMaps=A;if(A==null||A.length<=1){return }A.hide();this.vars.mapEnabled=true},showMap:function(A){var B=jQuery("#continents li."+A);this.vars.allMaps.hide();B.show()},hideMap:function(){this.vars.allMaps.hide()},initLabels:function(){var A=jQuery("#map_label");var B=this;A.makeAbsolute();jQuery(this.vars.elem).find("#map_points a").each(function(C){var D=jQuery(this).attr("title");jQuery(this).attr({title:""});jQuery(this).mouseover(function(){A.find("span.innerLabel").html(D);var E=jQuery(this).parent().position();A.attr({style:"left: "+(E.left-174)+"px !important; top: "+(E.top-37)+"px !important"});B.showMap(jQuery(this).parent().attr("class"));A.show()}).mouseout(function(){B.hideMap();A.hide()})});A.hide()}};jQuery.fn.makeAbsolute=function(A){return this.each(function(){var B=jQuery(this);var C=B.position();B.css({position:"absolute",marginLeft:0,marginTop:0,top:C.top,left:C.left});if(A){B.remove().appendTo("body")}})};var search={v:{location:null,id:null,wrapper_el:null,panels:[],panel_to_show:null,ajax_queue:[]},config:{panels:{"holiday-search-panel":{url:"/search-panel/holiday-search-panel.jsp",submit:"/search/holiday/",formName:"searchHolidayForm",searchType:"holiday"},"hotel-search-panel":{url:"/search-panel/hotel-search-panel.jsp",submit:"/search/hotel/",formName:"searchHotelForm",searchType:"hotel"},"cruise-search-panel":{url:"/search-panel/cruise-search-panel.jsp",submit:"/search/cruise/",formName:"searchCruiseForm",searchType:"cruise"},"flightHotel-search-panel":{url:"/search-panel/flightHotel-search-panel.jsp",submit:"/search/flightAndHotel/",formName:"searchFlightAndHotelForm",searchType:"flightAndHotel"},"car-search-panel":{url:"/search-panel/car-search-panel.jsp",submit:"/search/carHire/",formName:"searchCarForm",searchType:"carHire"}},searchTypeToPanel:{holiday:"holiday-search-panel",hotel:"hotel-search-panel",cruise:"cruise-search-panel",flightAndHotel:"flightHotel-search-panel",carHire:"car-search-panel"},children:{flightHotel:"/search-panel/children.html",hotel:"/search-panel/children2.html"},date_format:"{$day}/{$month}/{$year}",holidayDropDown:{holidayTo:"/searchFormDataFetch/destinationTo",holidayFrom:"/searchFormDataFetch/destinationFrom"},cosmosDropDowns:{holidayTo:"/searchFormDataFetch/cosmosRegionTo",cosmosRegionTo:"/searchFormDataFetch/cosmosResortTo",holidayFrom:"/searchFormDataFetch/destinationTo",flightHotelFrom:"/searchFormDataFetch/expediaDepartFrom",flightHotelTo:"/searchFormDataFetch/expediaDestTo"},formTypes:{search:{cruiseSearchUrl:"/searchFormDataFetch/virginLists",dataToform:{where:"cruiseWhere",howlong:"cruiseDuration",when:"cruiseDepartDate",which:"cruiseShip",cruisetype:"cruiseType"},fields:["cruiseWhere","cruiseDuration","cruiseDepartDate","cruiseShip","cruiseType"],formStates:[]},searchSmall:{cruiseSearchUrl:"/searchFormDataFetch/virginListsSmall",dataToform:{where:"cruiseWhereSmall",when:"cruiseDepartDateSmall",which:"cruiseShipSmall"},fields:["cruiseDepartDateSmall","cruiseWhereSmall","cruiseShipSmall"],formStates:[]}},fields:{search:["cruiseWhere","cruiseDuration","cruiseDepartDate","cruiseShip","cruiseType"],searchSmall:["cruiseWhereSmall","cruiseDurationSmall","cruiseDepartDateSmall","cruiseShipSmall","cruiseTypeSmall"]}},init:function(A,E){var B=jQuery("#search");var D=jQuery("#cruise-small-search-panel");if(B.length==0&&D.length==0){return }B.submit(function(G){var F=jQuery(this).attr("name");if(F=="searchCruiseForm"){}simpleCookies.set("formState",jQuery(this).serialize())});var C=this;this.v.wrapper_el=B;this.panel.init(E);this.room.init();this.restoreOnBlur(B);this.date.init();this.destination.init();this.cruise.init()},cruise:{init:function(){if(jQuery("#cruise-search-panel").length==0&&jQuery("#cruise-small-search-panel").length==0){return }jQuery.timer(2000,function(D){D.stop();search.overlayHide()});var A=this;jQuery("#cruise-search-panel select").change(function(){A.storeStates("search");A.updateForm("search")});jQuery("#cruise-small-search-panel select").change(function(){A.storeStates("searchSmall");A.updateForm("searchSmall")});var C=this.findDefaultValues("lastCruiseSearchSmall","search");this.updateForm("search",C[0],function(){jQuery.timer(200,function(D){D.stop();search.cruise.selectCurrent(C,"search")})});var B=this.findDefaultValues("lastCruiseSearchSmall","searchSmall");this.updateForm("searchSmall",B[0],function(){jQuery.timer(200,function(D){D.stop();search.cruise.selectCurrent(B,"searchSmall")})})},selectCurrent:function(D,C){for(var A=0;A<search.config.fields[C].length;A++){if(D[1][A]!=="xxx"){var B=jQuery("#"+search.config.fields[C][A]);B.val(D[1][A])}}},findDefaultValues:function(G,E){var D=jQuery("#"+G);if(D.length==1){var F=D.attr("value");if(F.length>=5){var C=F.split("|");var B="";for(var A=0;A<search.config.fields[E].length;A++){B+=search.config.fields[E][A]+"="+C[A]+"&"}return[B,C]}}return["",false]},storeStates:function(B){search.config.formTypes[B].formStates=[];for(var A=0;A<search.config.formTypes[B].fields.length;A++){search.config.formTypes[B].formStates.push(jQuery("#"+search.config.formTypes[B].fields[A]).attr("value"))}},restoreStates:function(C){for(var A=0;A<search.config.formTypes[C].fields.length;A++){var B=search.config.formTypes[C].formStates[A];jQuery("#"+search.config.formTypes[C].fields[A]).attr({value:B})}},updateForm:function(G,A,C){var B=jQuery("#"+G);var F=true;if(typeof C=="undefined"){F=false;C=function(){}}if(B.length==0){return }var E=B.serialize();var D=(A)?A:E;jQuery.ajax({url:search.config.formTypes[G].cruiseSearchUrl,type:"POST",data:D,cache:false,dataType:"json",success:function(J){for(var K in J){var I="";if(G=="searchSmall"&&F){var L=J[K];I=jQuery("#"+search.config.formTypes[G].dataToform[K]).html();for(var H=1;H<L.length;H++){I+=L[H]}}else{var L=J[K];for(var H=0;H<L.length;H++){I+=L[H]}}jQuery("#"+search.config.formTypes[G].dataToform[K]).html(I);C()}search.cruise.restoreStates(G)}})}},restoreOnBlur:function(A){A.find("input.restore-on-blur").each(function(){var B=jQuery(this).attr("value");jQuery(this).focus(function(){if(jQuery(this).attr("value")==B){jQuery(this).attr({value:""}).removeClass("restore-on-blur")}}).blur(function(){if(jQuery(this).attr("value")==""){jQuery(this).attr({value:B}).addClass("restore-on-blur")}})});jQuery("#carLocation, #hotelLocation").change(function(){var B=jQuery(this).attr("value");if(B){search.v.location=B}})},overlayHide:function(){var A=jQuery("iframe.searchWaitingIframe.show");if(A.length===0){A=jQuery("form span.searchWaitingMsg.show")}A.fadeOut("fast",function(){jQuery(this).removeClass("show")})},destination:{init:function(){this.dynamicDropDowns()},dynamicDropDowns:function(){var B={holidayFrom:{update:"holidayTo",hide:["cosmosRegionTo","cosmosResortTo"]},holidayTo:{update:"cosmosRegionTo",hide:["cosmosResortTo"]},cosmosRegionTo:{update:"cosmosResortTo",hide:[]}};var C=this;for(var A in B){jQuery("#"+A).change(function(){var F=this;var E=B[this.id];var G=jQuery("#holidayTo").attr("value");if(E){C.submitAndUpdate(jQuery(this),jQuery("#"+E.update),function(){if(F.id=="holidayFrom"){var H=jQuery("#holidayTo option[value='"+G+"']");jQuery("#holidayTo").attr({value:G});if(H.length!==1||G=="Destination"){C.hideDropDowns(E.hide)}}else{C.hideDropDowns(E.hide)}})}})}var D=jQuery("#holidayTo").attr("value");if(D=="Destination"){this.hideDropDowns(B.holidayFrom.hide)}if(D==""){this.submitAndUpdate(jQuery("#holidayFrom"),jQuery("#holidayTo"));this.hideDropDowns(B.holidayFrom.hide)}},hideDropDowns:function(A){for(var B=A.length-1;B>=0;B--){jQuery("#"+A[B]).hide()}},submitAndUpdate:function(D,F,C,B){if(typeof B=="undefined"){B=search.config.cosmosDropDowns}var E=D.attr("id");var A=B[E];jQuery.ajax({url:A,type:"POST",cache:false,dataType:"json",data:"destNameParam="+D.find("option:selected").attr("value"),success:function(I){var H="";for(var G=0;G<I.length;G++){if(typeof I[G]=="string"){H+='<option value="'+I[G]+'">'+I[G]+"</option>"}else{if(typeof I[G]=="object"){if(I[G].airportCode=="a_no_data"){var K=I[G].regionName;var J=I[G].regionName}else{switch(E){case"holidayFrom":case"flightHotelFrom":var K=I[G].regionName+", "+I[G].country+","+I[G].airportCode;var J=I[G].regionName+", "+I[G].airportCode;break;default:var K=I[G].regionName+", "+I[G].country+","+I[G].airportCode;var J=I[G].regionDisplayName}}H+='<option value="'+K+'">'+J+"</option>"}}}F.html(H);F.show();F.parent("label").show();if(typeof C=="function"){C()}}})}},date:{init:function(A){A=(A)?A:search.v.wrapper_el;var B=this;jQuery(A).find("input.ret-date, input.dep-date").each(function(){var C=parseInt(B.getNumberOfDays(jQuery(this).attr("class")));jQuery(this).attr({value:B.getDate(C)})});this.getDate();datePickerController.create()},getNumberOfDays:function(B){var A=B.match(/(add-days-)[0-9]{1,3}/g);if(A){A=A[0].split("add-days-");if(A.length==2){return A[1]}}return 0},getDate:function(A){A=(A)?A:0;var E=new Date();E.addDays(A);var B=E.getDate();var D=E.getMonth();D++;var C=E.getFullYear();return this.returnAsString(B,D,C)},returnAsString:function(A,C,B){A=(A<=9)?"0"+A:A;C=(C<=9)?"0"+C:C;return search.config.date_format.tpl({day:A,month:C,year:B})}},carLabelTabs:{init:function(){var B=jQuery("#carSearchOccuracy li > label");if(B.length==0){return }var A=this;if(jQuery.browser.msie){jQuery("#carSearchOccuracy li input").focus(function(){A.update(B)}).trigger("focus")}else{B.change(function(){A.update(B)}).trigger("change")}},update:function(A){A.each(function(){if(jQuery(this).find("input:checked").length!==0){jQuery(this).next("div").show()}else{jQuery(this).next("div").css({display:"none"})}})}},panel:{init:function(){this.createTabs("types-list");jQuery("#all-search-panels > div").each(function(){search.v.panels.push(jQuery(this).attr("id"))});search.carLabelTabs.init();this.appendSubmitAction()},appendSubmitAction:function(A){if(A){var B=jQuery("#"+A+" .buttons input")}else{var B=jQuery("#all-search-panels .selected .buttons input");A=jQuery("#all-search-panels .selected").attr("id")}},get:function(B){var A=jQuery("#"+B);search.v.panel_to_show=B;if(A.length==0){search.v.ajax_queue.push(B);search.v.panels.push(B);this.request()}else{this.showCurrent(B)}},show:function(A){jQuery("#"+A).show().addClass("selected")},hideAll:function(){for(var A=search.v.panels.length-1;A>=0;A--){this.hide(search.v.panels[A])}},hide:function(A){jQuery("#"+A).hide().removeClass("selected")},showCurrent:function(A){A=(A)?A:search.v.panel_to_show;this.hideAll();this.show(A)},createTabs:function(C){var A=jQuery("#"+C+" li input");if(A.length==0){return }var B=this;if(jQuery.browser.msie){A.focus(function(){B.doStuff(this,A)})}else{A.change(function(){B.doStuff(this,A)})}},doStuff:function(B,A){A.removeClass("selected");jQuery(B).addClass("selected");jQuery(B).attr({selected:"selected"});var C=jQuery(B).parent().parent().attr("id").split("-search-type")[0];search.v.id=C;search.v.wrapper_el.attr("action",search.config.panels[C+"-search-panel"].submit);search.v.wrapper_el.attr("name",search.config.panels[C+"-search-panel"].formName);jQuery("#searchType").attr("value",search.config.panels[C+"-search-panel"].searchType);search.panel.get(C+"-search-panel")},request:function(){var B=search.v.ajax_queue.pop();var A=this;if(B){jQuery.ajax({url:search.config.panels[B].url,cache:false,success:function(C){A.hideAll();jQuery("#all-search-panels").append(C);A.init_single(B);if(search.v.ajax_queue.length>0){A.requestSearchPanels()}else{search.panel.showCurrent()}}})}else{this.showCurrent()}},inputValues:function(){jQuery("#carLocation, #hotelLocation").each(function(){if(search.v.location){jQuery(this).attr({value:search.v.location}).removeClass("restore-on-blur")}})},init_single:function(D){var C=jQuery("#"+D);var B=D.split("-search-panel")[0];switch(B){case"car":search.carLabelTabs.init();break;case"cruise":search.cruise.init();break;case"flightHotel":var A=jQuery("#flightHotelFrom");search.destination.submitAndUpdate(A,A);A=jQuery("#flightHotelTo");search.destination.submitAndUpdate(A,A);break;case"holiday":var A=jQuery("#holidayFrom");search.destination.submitAndUpdate(A,A,null,search.config.holidayDropDown);A=jQuery("#holidayTo");search.destination.submitAndUpdate(A,A,null,search.config.holidayDropDown);search.destination.init();break;default:break}search.room.initDropDown(B);search.restoreOnBlur(C);search.date.init(C);search.panel.inputValues();search.panel.appendSubmitAction(D)}},room:{init:function(){this.initAllDropDowns()},initAllDropDowns:function(){for(var A=search.v.panels.length-1;A>=0;A--){this.initDropDown(search.v.panels[A].split("-search-panel")[0])}},initDropDown:function(B){this.updateDropDowns();var A=jQuery("#"+B+"Rooms option:last").attr("value");if(A==0){return }var C=this;jQuery("#"+B+"Rooms").change(function(){var D=jQuery(this).find("option:selected").attr("value");C.showCurrentDropDowns(B,D,A)}).trigger("change");search.children.init(B,A)},updateDropDowns:function(){},showCurrentDropDowns:function(C,B,A){for(var E=A;E>B;E--){this.hideDropDown(C+"Room"+E)}for(var E=B;E>0;E--){this.showDropDown(C+"Room"+E)}var D=0;for(var E=A;E>0;E--){D+=search.toInteger(jQuery("#"+C+"Room"+E+"Children:visible option:selected").attr("value"))}search.children.update(C,A)},hideDropDown:function(A){jQuery("#"+A).hide()},showDropDown:function(A){jQuery("#"+A).show()},roomsDropDown:function(){}},children:{init:function(B,A){this.addControls(B,A);this.showCurrent(B,function(){search.children.update(B,A)})},hidePanel:function(A){jQuery("#"+A+"ChildRoomsWrapper").hide()},showPanel:function(A){jQuery("#"+A+"ChildRoomsWrapper").show()},hideRow:function(B,A){jQuery("#"+B+"ChildRoom"+A).hide()},showRow:function(B,A){jQuery("#"+B+"ChildRoom"+A).show()},addControls:function(B,A){var D=this;for(var C=A;C>0;C--){jQuery("#"+B+"Room"+C+"Children").change(function(){D.update(B,A)})}},showDropDown:function(B,C,A){jQuery("#"+B+"Room"+C+"Child"+A).show()},hideDropDown:function(B,C,A){jQuery("#"+B+"Room"+C+"Child"+A).hide()},update:function(C,A){var E=0;for(var D=A;D>0;D--){var F=search.toInteger(jQuery("#"+C+"Room"+D+"Children:visible").attr("value"));if(F&&F!==0){E=(F>E)?F:E;this.showCurrent(C);for(var B=4;B>0;B--){if(B>F){this.hideDropDown(C,D,B)}else{this.showDropDown(C,D,B)}}this.showRow(C,D)}else{this.hideRow(C,D)}}if(E==0){this.hidePanel(C)}this.updateDropDownLabels(C,E)},updateDropDownLabels:function(B,A){jQuery("#"+B+"ChildRooms ul.labels li").each(function(C){if(C+1<=A){jQuery(this).removeClass("nonActive")}else{jQuery(this).addClass("nonActive")}})},showCurrent:function(A,B){var C=jQuery("#"+A+"ChildRooms");if(C.length==0){jQuery.ajax({url:search.config.children[A],cache:false,success:function(D){if(jQuery("#"+A+"ChildRooms").length==0){jQuery("#"+A+"ChildRoomsWrapper").append(D);if(typeof B=="function"){B()}}}})}else{this.showPanel(A)}}},toInteger:function(A){if(A==undefined){return 0}return parseInt(A)}};Date.prototype.addDays=function(A){this.setDate(this.getDate()+A)};jQuery.timer=function(A,B){var A=A||100;if(!B){return false}_timer=function(D,E){this.stop=function(){clearInterval(C.id)};this.internalCallback=function(){E(C)};this.reset=function(F){if(C.id){clearInterval(C.id)}var F=F||100;this.id=setInterval(this.internalCallback,F)};this.interval=D;this.id=setInterval(this.internalCallback,this.interval);var C=this};return new _timer(A,B)};jQuery.fn.nb=function(){this.blur();return this.focus(function(){this.blur()})};jQuery.fn.makeAbsolute=function(A){return this.each(function(){var B=jQuery(this);if(A){B.remove().appendTo("body")}if(jQuery.browser.msie){B.addClass("msie_positioned")}else{B.addClass("positioned")}})};var simpleCookies={set:function(C,D,B,E){var A="";if(B){A=this.getHoursFromNow(B)}E=E||"/";document.cookie=C+"="+escape(D)+"; expires="+A+"; path="+E},getHoursFromNow:function(A){return new Date(new Date().getTime()+A*3600000)},get:function(B){B+="=";var E,D=document.cookie.split(";");for(var C=0,A=D.length;C<A;C++){E=D[C];while(E.charAt(0)==" "){E=E.substring(1,E.length)}if(E.indexOf(B)==0){return unescape(E.substring(B.length,E.length))}}}};jQuery.fn.replace=function(){var A=[];return this.domManip(arguments,true,1,function(B){this.parentNode.replaceChild(B,this);A.push(B)}).pushStack(A)};

