(function(A){A.widget("ui.toursearch",{_init:function(){var B=this.element,C=this.options,D=this;B.find("a.selected").click(function(E){E.preventDefault()});A(document).click(function(E){var F=A(E.target);if(!F.closest("div.select",A("#search")).length){D._hideAllPopups()}});A.each(C.elements,function(H,I){var G=A("#"+H),J=(typeof (I.getPopup)=="function")?I.getPopup.call(G):D._getPopup.call(G),F=(typeof (I.getContentHolder)=="function")?I.getContentHolder.call(J):D._getContentHolder.call(J);G.click(function(L){if(I.refreshOnShow!==undefined&&I.refreshOnShow==true){if(typeof (I.getContent)=="function"){I.getContent.call(F)}}D._hideAllPopups();if(typeof (I.showPopup)=="function"){I.showPopup.call(G)}else{D._showPopup.call(G)}});var K=function(M,L){D._setValue.call(G,M,L);if(typeof (C.onChange)=="function"){C.onChange.call(D)}};if(typeof (I.setValue)=="function"){K=function(M,L){I.setValue.call(G,M,L,C.onChange);if(typeof (C.onChange)=="function"){C.onChange.call(D)}}}var E=function(){D._hideAllPopups.apply(D)};F.click(function(L){if(typeof (I.onContentBodyClick)=="function"){I.onContentBodyClick.call(F,L,K,E)}else{D._onContentBodyClick.call(F,L,K,E)}});J.click(function(L){if(typeof (I.onPopupBodyClick)=="function"){I.onPopupBodyClick.call(J,L,K,E)}else{D._onPopupBodyClick.call(J,L,K,E)}})})},_setValue:function(C,B){var F=this.parent(),E=F.find("a.selected"),D=F.find("input:hidden");E.children("strong").html(C);D.val(B)},_onContentBodyClick:function(B,G,E){var D=A(B.target).closest("a");if(D.length==0){return }var F=D.text(),C=D.attr("value");G(F,C);E()},_onPopupBodyClick:function(B,D,C){if(A(B.target).closest("a.selected").length){C()}},_hideAllPopups:function(){var B=this;A.each(this.options.elements,function(D,E){var C=A("#"+D);if(typeof (E.hidePopup)=="function"){E.hidePopup.call(C)}else{B._hidePopup.call(C)}})},_showPopup:function(){this.parent().addClass("active")},_hidePopup:function(){this.parent().removeClass("active")},_getPopup:function(){return this.parent().find("div.drop_down").eq(0)},_getContentHolder:function(){return this.find("ul.scroll").eq(0)},_getValue:function(){return this.parent().find("input:hidden").eq(0).val()},setValue:function(E,G,C){var B=this.options,F=this.options.elements[E],D=A("#"+E);if(F===undefined){return }if(typeof (F.setValue)=="function"){F.setValue.call(D,G,C)}else{this._setValue.call(D,G,C)}if(typeof (B.onChange)=="function"){B.onChange.call(self)}},getValue:function(D){var E=this.options.elements[D],C=A("#"+D),B=this;if(typeof (E.getValue)=="function"){return E.getValue.call(C)}else{return B._getValue.call(C)}},setContent:function(F,H,J,E){if(typeof (this.options.elements[F])===undefined){return }var D=A("#"+F),I=this,B=this.options.elements[F],C=(typeof (B.getPopup)=="function")?B.getPopup.call(D):I._getPopup.call(D),G=(typeof (B.getContentHolder)=="function")?B.getContentHolder.call(C):I._getContentHolder.call(C);G.html(E);if(typeof (B.setValue)=="function"){B.setValue.call(D,H,J)}else{I._setValue.call(D,H,J)}},setLoadingState:function(D,E){if(typeof (this.options.elements[D])===undefined){return }var C=A("#"+D),B=A("<a />").addClass("fake").attr("href","javascript:void(0);").html(E).insertBefore(C).show();C.hide();return function(){B.remove();C.show()}},onChange:function(B){if(typeof (B)=="function"){this.options.onChange=B}}})})(jQuery);$.extend($.ui.toursearch,{"defaults":{"elements":{"a":{"getContent":function(A){var B=this;B.title.html("dialog window");B.content.html("window content");if(typeof (A)=="function"){A.call(this)}},"onDisplay":function(A){A.call(this)},"onClose":function(A){A.call(this)},"permanent":true}},"title_selector":".b-tex__title h3","content_selector":"div.l-popup__i_texover","close_selector":"a.st-close","window_selector":"div.l-popup_small","onChange":null},"getter":"getValue setLoadingState"});(function(A){A.widget("ui.range",{value:null,pairValue:null,_draw:function(){var G=this.element,C=this.options,J=this;var F="";var H=false,B=false;if(C.border=="bottom"){H=true}else{B=true}for(var D=parseInt(C.range[0],10);D<=parseInt(C.range[1],10);D++){var E="";if((D<J.pairValue&&H)||(D>J.pairValue&&B)){E="disabled"}if(D==J.value){E="active"}var I='<span class="'+E+'">'+D+"</span>";if((H&&D==J.pairValue)||(B&&D==J.value)){I="<div>"+I}if((H&&D==J.value)||(B&&D==J.pairValue)){I+="</div>"}F+=I}G.html(F)},_bindHandler:function(C){if(typeof (C)!=="function"){return }var B=this;this.element.click(function(D){var F=A(D.target);if(!F.filter("span:not(."+B.options.disabledClass+")").length){return }var E=parseInt(F.text(),10);C.call(F,E)})},_onSelect:function(B){this.value=B;this._draw()},_init:function(){var B=this.element,C=this.options,D=this;B.addClass(C.rangeClass);D._bindHandler(function(E){D._onSelect.call(D,E)});if(!(C.range instanceof Array)||C.range.length!=2){throw ("Invalid range format: [%d, %d] expected.")}if(C.range[0]>C.range[1]){throw ("Invalid range: [min, max].")}this.value=(C.value===null)?parseInt(C.value,10):parseInt(C.value,10);this.pairValue=(C.pairValue===null)?parseInt(C.pairValue,10):parseInt(C.pairValue,10);this._draw()},setValue:function(B){this._value=parseInt(B,10);this.draw()},setPairValue:function(B){this.pairValue=parseInt(B,10);this._draw()},addOnSelectStack:function(B){this._bindHandler(B)}})})(jQuery);$.extend($.ui.range,{defaults:{range:[1,10],value:null,pairValue:null,activeClass:"active",disabledClass:"disabled",rangeClass:"b-night",border:"top"},getter:"getValue"});var _hotel_labels={};var _inited=false;var _toggleHotel=function(){var E=this,C=this.attr("value"),F=this.attr("label"),D=$("#link-drop-hotels-input"),B=D.val()?D.val().split("-"):new Array();_hotel_labels[C]=F;if(E.filter(":checked").length){if($.inArray(C,B)===-1){B.push(C)}}else{_pos=$.inArray(C,B);if(_pos!==-1){B.splice(_pos,1)}}D.val(B.join("-"));var A=$("#toursearch-select-hotel-list .hotels-list").html("").hide();_html="";$.each(B,function(H,G){_html+='<div style="margin: 0; padding: 0;"><a href="#" class="remove-selected-hotel" value="'+G+'">(x)</a>'+_hotel_labels[G]+"</div>"});if(_html){A.show()}A.html(_html)};function _initToursearchForm(){var F=["asc","desc"],E=["departure","price","duration","meals","rate","name"],K=0,H=1;var A=function(){var M=this.text();this.html("<strong><i></i>"+M+"</strong>").closest("li").addClass("b-poplist__item_cur")};var L=function(O){var P=$("#link-drop-roomsize-adult").attr("value"),N=$("#link-drop-roomsize-children").attr("value");var M={"1-0":15,"2-0":14,"3-0":23,"1-1":18,"1-2":19,"2-1":20,"2-2":21,"3-1":27,"3-2":31};return M[parseInt(P)+"-"+parseInt(N)]};var I=new Date(),C=I.getFullYear()+"-"+(I.getMonth()+1)+"-"+I.getDate();_max_date=new Date();_max_date.setFullYear(_max_date.getFullYear()+1);_max_date_label=_max_date.getFullYear()+"-"+(_max_date.getMonth()+1)+"-"+_max_date.getDate();var J={};$("#tour_search_short, #tour_search").toursearch({"elements":{"link-drop-to":{"onContentBodyClick":function(M,P,R){var N=$(M.target).closest("li");if($(N).hasClass("headline")){M.preventDefault();M.stopPropagation();return }if(N.length==0){return }var Q=N.text(),O=N.attr("value"),S=this.attr("val")!==Q;P(Q,O);if(S){$("#link-drop-regions").select_regions("loadRegions",O)}R()}},"link-drop-from":{"onContentBodyClick":function(M,P,R){var O=$(M.target).closest("li"),N=O.addClass("check"),Q=N.siblings("li").removeClass("check");if(!O.length){return }if($("#tour_search").length&&N.attr("value")!=$("#tour_search").toursearch("getValue","link-drop-from")){reloadCountries(N.attr("value"))}P(N.text(),N.attr("value"));R()},"getContentHolder":function(){return this.find("ul").eq(0)}},"link-drop-departure-from":{"setValue":function(N,M){this.parent().find("a.selected").html(N);$("#departure-from-input").val(M)},"onPopupBodyClick":function(M,N,O){if($(M.target).filter("li, a.calendar_close, a.calendar_close i, a.selected, a.selected strong").length){O()}}},"link-drop-departure-to":{"setValue":function(N,M){this.parent().find("a.selected").html(N);$("#departure-to-input").val(M)},"onPopupBodyClick":function(M,N,O){if($(M.target).filter("li, a.calendar_close, a.calendar_close i, a.selected, a.selected strong").length){O()}}},"link-drop-len-from":{"onContentBodyClick":function(M,P,Q){var N=$(M.target).closest("li"),O=N.attr("value");if(!N.length){return }P(N.text(),O);Q();if($("#tour_search_short, #tour_search").toursearch("getValue","link-drop-len-to")<O){$("#tour_search_short, #tour_search").toursearch("setValue","link-drop-len-to",O,O)}}},"link-drop-len-to":{"onContentBodyClick":function(M,O,P){var N=$(M.target).closest("li");_v=N.attr("value");if(!N.length){return }O(N.text(),_v);P();if($("#tour_search_short, #tour_search").toursearch("getValue","link-drop-len-from")>_v){$("#tour_search_short, #tour_search").toursearch("setValue","link-drop-len-from",_v,_v)}}},"link-drop-class":{"onContentBodyClick":function(M,P,Q){var O=$(M.target).closest("li"),N=O.attr("value");if(!N||N=="10"||N=="12"||N=="1"){$("#hotel-class-and-better-checkbox").hide()}else{$("#hotel-class-and-better-checkbox").show()}if(!O.length){return }P(O.html(),N);Q()},"setValue":function(N,M){this.parent().find("a.selected").html("<strong>"+N+"</strong>").end().find("input:hidden").val(M)},"getContentHolder":function(){return this.find("ul").eq(0)}},"link-drop-meals":{"onContentBodyClick":function(M,P,Q){var O=$(M.target).closest("li"),N=O.attr("value");if(!N||N=="6"){$("#hotel-meals-and-better-checkbox").hide()}else{$("#hotel-meals-and-better-checkbox").show()}if(!O.length){return }P(O.html(),N);Q()},"getContentHolder":function(){return this.find("ul").eq(0)}},"link-drop-room-size":{"onContentBodyClick":function(M,P,R){var O=$(M.target).closest("li"),N=O.attr("value");if(!O){return }var Q=O.text().replace(/(\d+)/g,"<strong>$1</strong>");P(Q,N);R()},"setValue":function(N,M){this.parent().find("a.selected").html(N).end().find("input:hidden").val(M)},"getContentHolder":function(){return this.find("ul").eq(0)}},"link-drop-room-1-child-age":{"onContentBodyClick":function(M,Q,R){var P=$(M.target).closest("li"),N=P.siblings("li").removeClass("check"),O=P.attr("value"),S=_getNumerableStringRu(parseInt(O,10)," год","года","лет");P.addClass("check");$("#room-1-child-label").html(S);Q(O,O);R()},"getContentHolder":function(){return this.find("ul").eq(0)},"setValue":function(N,M){var P=this.parent(),O=P.find("a.selected");$("#room-size-1-child").children("input:hidden").val(M);O.children("strong").html(N)}},"link-drop-room-1-of-2-children-age":{"onContentBodyClick":function(M,Q,R){var P=$(M.target).closest("li"),N=P.siblings("li").removeClass("check"),O=P.attr("value");P.addClass("check");Q(O,O);R()},"getContentHolder":function(){return this.find("ul").eq(0)},"setValue":function(N,M){var P=this.parent(),O=P.find("a.selected");O.children("strong").html(N)}},"link-drop-room-2-of-2-children-age":{"onContentBodyClick":function(M,Q,R){var P=$(M.target).closest("li"),N=P.siblings("li").removeClass("check"),O=P.attr("value"),S=_getNumerableStringRu(parseInt(O,10)," год","года","лет");P.addClass("check");$("#room-2-children-label").html(S);Q(O,O);R()},"getContentHolder":function(){return this.find("ul").eq(0)},"setValue":function(N,M){var P=this.parent(),O=P.find("a.selected");O.children("strong").html(N)}}}});var D=function(Z,X){if(Z.hasClass(this.options.disabledClass)){return }var h=Z.closest(".calendar").find(".month");$("li."+this.options.intermediateClass,h).removeClass(this.options.intermediateClass);$("li."+this.options.parityDateClass,h).removeClass(this.options.parityDateClass);$("li."+this.options.activeDateClass,h).removeClass(this.options.activeDateClass);var U=this._strToDate(Z.attr("date")),g=this.options._current_date,Y=null,R=null,V=Z.closest(".calendar").find(".month").find("li[date]"),T=0,c=0,Q="",P="",d=this.element.find(".month"),N=d.eq(0),M=d.eq(1);if(g<X&&U<=X){Y=U;R=X;Q=this.options.activeDateClass;P=this.options.parityDateClass}else{if(g>X&&U>=X){Y=X;R=U;Q=this.options.parityDateClass;P=this.options.activeDateClass}else{return }}var b=true,a=true;if(Y.getMonth()<(N.attr("month")-1)){Y=new Y.constructor(Y);Y.setMonth(N.attr("month")-1);Y.setDate(1);b=false}if(R.getMonth()>(M.attr("month")-1)){R=new Y.constructor(R);R.setMonth(M.attr("month")-1);R.setDate(this._getLastDayOfMonth(R)-1);a=false}var f=Y.getFullYear()+"-"+(Y.getMonth()+1)+"-"+Y.getDate(),O=R.getFullYear()+"-"+(R.getMonth()+1)+"-"+R.getDate(),S=V.filter("[date='"+f+"']"),W=V.filter("[date='"+O+"']");T=(R-Y)/(1000*24*3600);c=Y.getDate()-1;if(T&&S.closest(".month").attr("month")==W.closest(".month").attr("month")&&N.attr("month")!=W.closest(".month").attr("month")){c+=N.find("li[date]").length}if(b){V.eq(c).addClass(Q)}while(T>=0){V.eq(c++).addClass(this.options.intermediateClass);T--}if(a){V.eq(c-1).addClass(P)}};var G=function(M){if(M.is(":visible")){var N=this.element.find(".month");$("li."+this.options.intermediateClass,N).removeClass(this.options.intermediateClass);$("li."+this.options.parityDateClass,N).removeClass(this.options.parityDateClass);$("li."+this.options.activeDateClass,N).removeClass(this.options.activeDateClass);this._redrawSelected()}};$("#link-drop-departure-start-calendar").calendar({onSelect:function(M){var Q=M.getFullYear(),P=M.getMonth()+1,O=M.getDate(),R="<strong>с "+O+" "+_monthLabelsShortRp[P-1]+"</strong>",N=O+"."+P+"."+Q;$("#link-drop-departure-end-calendar").calendar("setParityDate",N).calendar("moveDateUp",N);$("#tour_search_short, #tour_search").toursearch("setValue","link-drop-departure-from",R,N)},onHoverIn:D,onHoverOut:G,currentDate:$("#departure-from-input").val(),minDate:C,maxDate:_max_date_label,disabledClass:"none",todayClass:"current_date",activeDateClass:"from_date",parityDateClass:"to_date",intermediateClass:"selected_dates",daysPlate:'<span>Пн</span><span>Вт</span><span>Ср</span><span>Чт</span><span>Пт</span><span class="day_off">Сб</span><span class="day_off">Вс</span>',parityDate:$("#departure-to-input").val()});$("#link-drop-departure-end-calendar").calendar({onSelect:function(M){var Q=M.getFullYear(),P=M.getMonth()+1,O=M.getDate(),R="<strong>по "+O+" "+_monthLabelsShortRp[P-1]+"</strong>",N=O+"."+P+"."+Q;$("#link-drop-departure-start-calendar").calendar("setParityDate",N).calendar("moveDateDown",N);$("#tour_search_short, #tour_search").toursearch("setValue","link-drop-departure-to",R,N)},onHoverIn:D,onHoverOut:G,currentDate:$("#departure-to-input").val(),minDate:C,maxDate:_max_date_label,disabledClass:"none",todayClass:"current_date",activeDateClass:"to_date",parityDateClass:"from_date",intermediateClass:"selected_dates",daysPlate:'<span>Пн</span><span>Вт</span><span>Ср</span><span>Чт</span><span>Пт</span><span class="day_off">Сб</span><span class="day_off">Вс</span>',parityDate:$("#departure-from-input").val()});$("#hotel-select-costs-float-link").click(function(){$(this).hide();$("#hotel-select-costs-float-div").show();$("#hotel-select-costs-input-to").focus()});(function(){var O=null,N=function(){$("#hotel-select-costs-input-to").val("")},M=function(){$("#hotel-select-costs-input-from").val("")};$("#hotel-select-costs-input-from, #hotel-select-costs-input-to").blur(function(P){if(isNaN(parseInt($(this).val(),10))){$(this).val("")}if($(this).filter("#hotel-select-costs-input-from").length){if($(this).val()&&parseInt($(this).val(),10)>parseInt($("#hotel-select-costs-input-to").val(),10)){N()}}else{if($(this).val()&&parseInt($(this).val(),10)<parseInt($("#hotel-select-costs-input-from").val(),10)){M()}}O=window.setTimeout(function(){if(!$("#hotel-select-costs-input-from").val()&&!$("#hotel-select-costs-input-to").val()&&!$("#hotel-select-costs-float-locked").filter(":visible").length){$("#hotel-select-costs-float-div").hide();$("#hotel-select-costs-float-link").show()}},200)}).click(function(P){window.clearTimeout(O)}).keydown(function(P){var Q=P.keyCode;if((Q<48||Q>57)&&(Q<96||Q>105)&&(Q<37||Q>40)&&(Q!=9&&Q!=8)){P.preventDefault()}})})();$("#hotel-select-costs-clear-button").click(function(M){M.stopPropagation();M.preventDefault();$("#hotel-select-costs-input-from, #hotel-select-costs-input-to").val("");$("#hotel-select-costs-float-div").hide();$("#hotel-select-costs-float-link").show()});$("#link-drop-room-size-ext").roomsize({"singleChildRoom":"#room-size-1-child","doubleChildrenRoom":"#room-size-2-children","parentSet":"#tour_search_short .set1"});var B=$("#hotel-meals-help-div");$("#hotel-meals-list-ul").find("li").mouseover(function(M){B.html($(this).attr("title"))});if($("#tour_search").length){$("#tour_help, #tour_search a").click(function(){$("#tour_help").fadeOut("slow")});(function(){var N="ready",Q=1,O="",T=false;$("#link-drop-regions").select_regions({"loadRegionsUrl":"/ajax/loadRegions/","onRegionsLoaded":function(W){$("#select_concrete_hotel").select_hotel_dialog("reloadRegions",W)},"regionLabelHolder":"#extend-regions-list-div","onRegionSelect":function(W){var X=W.find(":checkbox");if(X.attr("checked")){X.attr("checked_attr","1")}else{X.removeAttr("checked_attr")}},"onRegionChange":function(){Q=1;$("#select_concrete_hotel").select_hotel_dialog("clearSelectedHotels");$("#select_concrete_hotel").select_hotel_dialog("updateRegions",$("#regions-ul").html())}});var S=$("#help-you-have-no-favorite-hotels .help3span").contents()[0].nodeValue;$("#select_concrete_hotel").select_hotel_dialog({"tint":"#select_hotel_tint","dialog":"#select_hotel","whatIsFavoriteHotelPopup":"#help-what-are-favorite-hotels","whatIsFavoriteHotelLink":"#link-what-are-favorite-hotels","showFavoritesOnly":"#link-show-me-only-favorite-hotels","youHaveNoFavoritesPopup":"#help-you-have-no-favorite-hotels","showAllHotels":"#link-show-me-all-hotels","showAllHotelsLi":"#show-country-hotel-li","regionsFilter":"#select-hotel-filter-regions","classFilter":"#select-hotel-filter-class","howToSelectHotelsPopup":"#help-how-to-select-hotels","regionsList":"#select-hotel-regions-list","hotelsList":"#hotel-list-ul","reloadHotels":function(b,Y){var X=this,Z=$("#find-hotel-country-list li[value="+b+"]").attr("ppad_name"),W=$("#help-you-have-no-favorite-hotels .help3span span"),a="У вас пока нет любимых отелей.";this.html('<div class="wait">Загрузка отелей...</div>');$.ajax({"url":"/ajax/loadDialogHotels/"+b+"/","success":function(c){if(c!==undefined){X.html(c);$("#select_concrete_hotel").select_hotel_dialog("clearFilters");$("#select_concrete_hotel").select_hotel_dialog("updateRegions",$("#regions-ul").html());if(Z&&$("#user-has-favorites").length>0){W.text(a.substring(0,a.length-1)+" "+Z+".")}else{if($("#user-has-favorites").length>0){W.text("У вас пока нет любимых отелей в этой стране.")}}Y()}},"timeout":60000})},"reloadRegions":function(X){$("#select_concrete_hotel").select_hotel_dialog("reloadHotels",$("#find-hotel-country-input").val());var W=this;$(W.options.regionsList).html(X);W.updateRegions()},"updateRegions":function(){var X=this,W=X.options;_list=$(X.options.regionsList);var Y=_list.find(":checkbox[checked_attr]");if(Y.length){X._regions={};Y.each(function(Z,a){$(a).attr("checked","checked");var b=$(a).attr("value").split("-");$(b).each(function(c,d){X._regions[d]=true})});$(W.regionsFilter).find("a.selected").html("<strong> "+_getNumerableStringRu(Y.length,"Выбран ","Выбрано ","Выбрано ")+Y.length+_getNumerableStringRu(Y.length," курорт"," курорта"," курортов")+" </strong>")}},"hotelListBlock":"#hotel-label-list-block","applyButton":"#apply-and-close","onHotelSelect":function(X,W,Y){$("#link-drop-regions").select_regions("clearSelectedRegions");$("#clear-selected-hotels-and-select-by-class").show();$("#select-hotel-class").hide();if(!$("#hotel-select-costs-float-locked").filter(":visible").length){$("#hotel-select-costs-float-link").hide();$("#hotel-select-costs-input-from").val("");$("#hotel-select-costs-input-to").val("");$("#hotel-select-costs-float-div").hide();$("#hotel-select-costs-float-locked").show()}Q=1},"onListClear":function(){$("#clear-selected-hotels-and-select-by-class").hide();$("#select-hotel-class").show();if($.isEmptyObject(this._selectedHotels)){if(!$("#hotel-select-costs-input-from").val()&&!$("#hotel-select-costs-input-to").val()&&!$("#hotel-select-costs-float-locked").filter(":visible").length){$("#hotel-select-costs-float-locked").hide();$("#hotel-select-costs-float-link").show()}}}});$("#select_concrete_hotel_form_link").click(function(W){W.preventDefault();$("#select_concrete_hotel").trigger("click")});$("#clear-selected-hotels-form-link").click(function(W){W.preventDefault();$("#select_concrete_hotel").select_hotel_dialog("clearSelectedHotels")});$("#tour_search").toursearch("onChange",function(){Q=1});if($.History.getHash()){var V=/page=(\d+)/i.exec($.History.getHash());if(V===null||V===undefined){Q=1}else{if((V.length==2)&&(V[1]!==undefined)&&parseInt(V[1],10)){Q=parseInt(V[1],10)}}}$("a.next_page",$("#tour_results")).live("click",function(W){Q++;$("#toursearch-form-submit").trigger("click")});$("a.prev_page",$("#tour_results")).live("click",function(W){if(Q>1){Q--;$("#toursearch-form-submit").trigger("click")}});var R=function(){if(N=="ready"){N="loading";$("#tour_results, #tour_timeout, #tour_unavailable, #tour_whait, #tour_whait2").hide();if($("#tour_whait").length){$("#tour_whait").show()}else{$("#tour_whait2").show()}$.ajax({"url":"/tour/searchTour/"+O,"type":"GET","cache":true,"dataType":"html","error":function(Y,W,X){if(W=="timeout"){$("#tour_timeout").show()}else{$("#tour_unavailable").show()}},"success":function(W){$("#tour_results").html(W).show();$("#legal_info").hide()},"complete":function(){$("#tour_whait").remove();$("#tour_whait2").hide();N="ready"},"timeout":20000})}};var M=$("#tour_search").parent(),U=M.attr("foreign-form")?true:false,P=M.attr("action");if(U){$("#select_concrete_hotel").select_hotel_dialog("reloadHotels",$("#find-hotel-country-input").val(),true)}else{$("#select_concrete_hotel").select_hotel_dialog("reloadHotels",$("#find-hotel-country-input").val())}$("#toursearch-form-submit").click(function(W){W.preventDefault();T=true;var b="",Z="",X="",c=$("#link-drop-regions").select_regions("getSelectedRegions"),Y=$("#select_concrete_hotel").select_hotel_dialog("getSelectedHotels"),a=$("#link-drop-room-size-ext").roomsize("getValue");$("#tour_search").find("input:hidden, input:checkbox").each(function(d,f){f=$(f);if(f.attr("name")){Z+=Z?"&":"";var e;e=(f.filter(":checkbox").length)?(f[0].checked?"1":""):(f.val()==="0"?"":f.val());Z+=f.attr("name")+"="+e}});Z+=a;if(isNaN(parseInt($("#hotel-select-costs-input-from").val(),10))){$("#hotel-select-costs-input-from").val("")}if(isNaN(parseInt($("#hotel-select-costs-input-to").val(),10))){$("#hotel-select-costs-input-to").val("")}Z+="&PrF="+$("#hotel-select-costs-input-from").val();Z+="&PrT="+$("#hotel-select-costs-input-to").val();if(c){Z+="&Re="+c}else{if(Y){Z+="&Als="+Y}}Z="tsf="+Z;X="tsr=Page="+Q+"&Items=10&orderBy=price";b="#"+Z+";"+X;O="?"+Z+"&&"+X;if(!U){$.History.setHash(b);R()}else{window.location.href=(P+b)}});$.History.bind(function(W){if(!T){document.location.reload(true);return }T=false;R()})})()}if($("#tour_search_short").length){(function(){var N="ready",U=0,Q=13,O="",T=false,R=$("#toursearch-full-link").attr("href");var M=function(){var Y="",W="",V="",X=$("#link-drop-room-size-ext").roomsize("getValue");$("#tour_search_short").find("input:hidden, input:checkbox").each(function(Z,b){b=$(b);if(b.attr("name")){W+=W?"&":"";var a;a=(b.filter(":checkbox").length)?(b[0].checked?"1":""):(b.val()==="0"?"":b.val());W+=b.attr("name")+"="+a}});W+=X;W="tsf="+W;V="tsr=tours_offset="+U+"&tours_limit="+Q;return{tsf:W,tsr:V}};var S=function(){U=0;var V=M();var X=V["tsf"],W="tsr=Page=1&Items=10&orderBy=price";var Y=TourToolbox.setHashDataVariable("Als","",X+";"+W);$("#toursearch-full-link").attr("href",R+"#/"+Y+"/")};S();$("#tour_search_short").toursearch("onChange",function(){S()});$("#link-drop-room-size-ext").roomsize("onChange",function(){S()});if($.History.getHash()){U=TourToolbox.getHashVariable("offset")}$("a.next_page",$("#tour_results")).live("click",function(V){U=parseInt(U)+parseInt(Q);$("#toursearch-form-submit").trigger("click")});$("a.prev_page",$("#tour_results")).live("click",function(V){if(U>0){U=parseInt(U)-parseInt(Q);$("#toursearch-form-submit").trigger("click")}});var P=function(){if(N=="ready"){N="loading";$("#tour_results, #tour_timeout, #tour_unavailable").hide();$("#tour_whait").show();$.ajax({"url":"/tour/loadHotelTours/"+O,"type":"GET","cache":true,"dataType":"html","error":function(X,V,W){if(V=="timeout"){$("#tour_timeout").show()}else{$("#tour_unavailable").show()}},"success":function(V){$("#tour_results").html(V).show();$("#legal_info").hide()},"complete":function(){$("#tour_whait").hide();N="ready"},"timeout":20000})}};$("#toursearch-form-submit").click(function(V){V.preventDefault();var W=M();var Y=W["tsf"],X=W["tsr"];var Z="#"+Y+";"+X;O="?"+Y+";"+X;T=true;$.History.setHash(Z);P()});$.History.bind(function(V){if(!T){document.location.reload(true);return }T=false;P()})})()}}function reloadForm(A){if($("#toursearch-form-short-div").length){$("#toursearch-form-short-div").sleep();$.ajax({"url":"/tour/reloadForm/","data":{"hash":$.History.getHash(),"short_form":1,"ti_id":TourToolbox.getHashVariable("Als")},"cache":false,"success":function(B){$("#toursearch-form-short-div").wakeup().html(B);if(typeof (A)=="function"){A.call(document)}}})}else{if($("#toursearch-form-div").length){$("#toursearch-form-div").sleep();$.ajax({"url":"/tour/reloadForm/","data":{"hash":$.History.getHash()},"cache":false,"success":function(B){$("#toursearch-form-div").wakeup().children("div").eq(0).html(B);if(typeof (A)=="function"){A.call(document)}}})}}}function reloadCountries(B){var A=$("#tour_search").toursearch("getValue",["link-drop-to"]);$("#link-drop-to").closest(".set").sleep();$.ajax({url:"/ajax/loadCountries/",data:{country_ti_id:A,city_ti_id:B},dateType:"JSON",type:"GET",cache:true,success:function(C){$("#link-drop-to").next().find("ul.scroll").html(C["list"]);if(C["country_id"]!=undefined){$("#tour_search").toursearch("setValue","link-drop-to",C["country_name"]);$("#find-hotel-country-input").val(C["country_id"]);$("#link-drop-regions").select_regions("loadRegions",C["country_id"])}},complete:function(){$("#link-drop-to").closest(".set").wakeup()}})}(function(){var A=false;$(function(){if(A){return }if($.History.getHash()){reloadForm(function(){_initToursearchForm.call(document);A=true;$("#link-drop-regions").select_regions("refreshValues");$("#toursearch-form-submit").trigger("click");$("#select_concrete_hotel").select_hotel_dialog("updateRegions",$("#regions-ul").html())})}else{_initToursearchForm.call(document);A=true;if($("#link-drop-regions").length){$("#link-drop-regions").select_regions("refreshValues")}if($("#select_concrete_hotel").length){$("#select_concrete_hotel").select_hotel_dialog("updateRegions",$("#regions-ul").html())}}})})();function tour_loader_hotel_init(){$("#toursearch-form-submit").trigger("click")}function tour_loader_init(A){$("#tour_results").tourresult("destroy");$("#tour_results").tourresult(A)}function load_hotel_tours_ex_01(){$("#tour_results .not_all em").click(function(){$.scrollTo("#tour_search_short","normal")})}(function(A){A.widget("ui.morphText",{_inputOnBlur:function(C){var B=this.element,D=this.options,E=this,F=B.val();F=F?F:D.empty_label;this._label.html(F).show();B.hide();if(typeof (D.onInputBlur)=="function"){D.onInputBlur.call(B,C)}},_labelOnFocus:function(C){var B=this.element,D=this.options;this._label.hide();this.element.show().select();if(typeof (D.onLabelFocus)=="function"){D.onLabelFocus.call(B,C)}},_init:function(){var B=this.element,C=this.options,D=this;this._label=A(C.label_element).css(C.label_css).insertAfter(B).hide();if(!B.filter("input:text, textarea").length){return }B.blur(function(E){D._inputOnBlur(E)});this._label.bind("focus, click",function(E){D._labelOnFocus(E)});if(typeof (C.onKeyPress)=="function"){B.bind("keydown",C.onKeyPress)}this._inputOnBlur()},setValue:function(B){this.element.val(B);this._inputOnBlur(null)},setFocus:function(){this._labelOnFocus(null)},purge:function(){this.element.val("").hide();this._label.html(this.options.empty_label).show()}})})(jQuery);$.extend($.ui.morphText,{defaults:{"empty_label":"___","label_element":"<span />","label_css":{"cursor":"pointer"},"onInputBlur":null,"onLabelFocus":null,"onKeyPress":null}});(function(A){A.widget("ui.select_hotel_dialog",{_onDialogShowStack:[],_hotelNameIndex:null,_hotelFavoriteIndex:null,_hotelItems:null,_lastHotelSearchVal:null,_defaultClassLabel:null,_defaultRegionsLabel:null,_selectedHotels:{},_name:null,_class:null,_regions:null,_favorites:false,_showDialog:function(){var B=this.element,C=this.options,D=A(C.tint),E=A(C.dialog);while(this._onDialogShowStack.length){_f=this._onDialogShowStack.pop();_f()}this._hotelItems=A(this.options.hotelsList).children();D.fadeIn(function(){E.show();if(typeof (C.onDialogShow)=="function"){C.onDialogShow.call(E)}})},_filter:function(){var C=this;var B=this._name;if(this._name===null&&this._regions===null&&this._class===null&&!this._favorites){A(this.options.hotelsList).removeClass("hide-children");return }A(this.options.hotelsList).addClass("hide-children");C._hotelItems.each(function(H,I){var I=A(I),E=!C._name||(C._name&&C._name[H]),D=!C._regions||(C._regions&&C._regions[I.attr("region")]),G=!C._class||(C._class&&C._class==I.attr("stars")),F=!C._favorites||(C._favorites&&C._hotelFavoriteIndex[H]);if(E&&D&&G&&F){I.addClass("show-me")}else{I.removeClass("show-me")}})},_searchHotelName:function(H){var B=null;if(!this._hotelNameIndex){return }if(H.length){var B={};H=H.toLowerCase();if(H.length<=2){var E=new RegExp("(^|\\t)"+H,"g");var C=this._hotelNameIndex.split(E)}else{var C=this._hotelNameIndex.split(H)}if(C.length>1){for(var D=1;D<C.length;D++){var G=C[D];if(!G.length){continue}var F=/[^\:]*\:(\d+)/.exec(G);if(F&&F.length==2){B[F[1]]=true}}}}this._name=B;this._filter()},_showFavoritesOnly:function(){var B=this.options,C=this;if(!A.isEmptyObject(C._hotelFavoriteIndex)){C._clearFilters();this._favorites=true;A(B.whatIsFavoriteHotelLink+","+B.showFavoritesOnly).hide();A(B.showAllHotels+","+B.showAllHotelsLi).show();C._filter()}else{A(B.youHaveNoFavoritesPopup).fadeIn("slow")}},_closeDialog:function(){var B=this.element,C=this.options,D=A(C.tint),E=A(C.dialog);E.hide();D.fadeOut();if(typeof (C.onDialogClose)=="function"){C.onDialogClose.call(E)}},_clearFilters:function(){var B=this.options;this._name=null;this._class=null;this._regions=null;this._favorites=false;A(this.options.searchHotelName).smart_input("empty");this._searchHotelName("");A(B.regionsFilter).find("a.selected").html(this._defaultRegionsLabel);A(B.regionsFilter).find("input:checkbox:checked").each(function(C,D){D.checked=false});A(B.classFilter).find("a.selected").html(this._defaultClassLabel)},_selectHotel:function(E,D,C,B){this._selectedHotels[D]={"index":E,"name":C,"href":B};this._refreshHotelListBlock()},_clearSelectedHotels:function(C){if(!C||A.isEmptyObject(C)){C=this._selectedHotels}var B=this;A.each(C,function(D,F){if(B._selectedHotels[D]){var E=B._selectedHotels[D]["index"];if(B._hotelItems.eq(E).find("input:checkbox")[0]!==undefined){B._hotelItems.eq(E).find("input:checkbox")[0].checked=false}delete B._selectedHotels[D]}});this._refreshHotelListBlock();if(typeof (this.options.onListClear)=="function"){this.options.onListClear.call(this)}},_refreshHotelListBlock:function(){var G=A(this.options.hotelListBlock),D=G.children("span").eq(0),C=this;G.find("a._hotel_link").remove();if(A.isEmptyObject(this._selectedHotels)){D.html("Нет выбранных отелей");G.hide()}else{G.show();var F="",B=0;A.each(this._selectedHotels,function(H,I){B++;I.href=(I.href==undefined)?null:I.href;if(I.href){F+='<a href="'+I.href+'" target="_blank" index="'+H+'" class="_hotel_link">'+I.name+" <i></i></a> "}else{F+='<a href="javascript:void(0);" index="'+H+'" class="_hotel_link">'+I.name+" <i></i></a> "}});var E="Искать в "+B+_getNumerableStringRu(B," выбранном вами отеле"," выбранных вами отелях"," выбранных вами отелях")+": ";D.html(E);A(F).insertAfter(D)}},_init:function(){var B=this.element,C=this.options,E=this,G=A(C.tint),H=A(C.dialog),F=A(C.howToSelectHotelsPopup);B.click(function(J){E._showDialog()});A(document).click(function(J){if(!A(J.target).closest(C.whatIsFavoriteHotelPopup).length&&!A(J.target).closest(C.whatIsFavoriteHotelLink).length){A(C.whatIsFavoriteHotelPopup).hide()}if(!A(J.target).closest(C.showFavoritesOnly).length&&!A(J.target).closest(C.youHaveNoFavoritesPopup).length){A(C.youHaveNoFavoritesPopup).hide()}if(!A(J.target).closest("div.select").length){A("div.select",H).removeClass("active")}});H.find(C.closeButton).click(function(J){E._closeDialog()});A(document).keydown(function(J){if(J.keyCode==27){E._closeDialog()}});var D=function(J){J.preventDefault();F.filter(":visible").fadeOut();if(A(J.target).closest(C.showAllHotelsLi).length){A(C.showAllHotels).trigger("click");return }var K=A(J.target).closest("li");if(K.length){var M=K.prevAll("li").length;_checkbox=K.find("input:checkbox"),_hotel_id=_checkbox.val(),_hotel_name=K.find("input:hidden").val(),_href=K.find("a.info").attr("href"),_checked=_checkbox[0].checked,_isCheckboxClicked=(A(J.target).filter("input:checkbox").length>0);if(_hotel_id&&_hotel_name){if(_checked){var L={};L[_hotel_id]=true;E._clearSelectedHotels(L);_checkbox[0].checked=false}else{E._selectHotel(M,_hotel_id,_hotel_name,_href);if(typeof (C.onHotelSelect)=="function"){C.onHotelSelect.call(E,_hotel_id,_hotel_name,M)}_checkbox[0].checked=true}}}};var I=A(C.hotelsList,H);I.click(D);A(C.applyButton).click(function(){E._closeDialog()});A("a.selected",H).live("click",function(){A(this).closest("div.select").toggleClass("active")});A(C.searchHotelName,H).smart_input({"label":"Начните вводить название отеля"}).keyup(function(){E._searchHotelName(A(this).val())});this._hotelItems=A(C.hotelsList,H).children();A(C.whatIsFavoriteHotelLink,H).click(function(J){A(C.whatIsFavoriteHotelPopup).fadeIn("slow")});A(C.showFavoritesOnly,H).click(function(){E._showFavoritesOnly()});A(C.showAllHotels).click(function(){A(C.whatIsFavoriteHotelLink+","+C.showFavoritesOnly).show();A(C.showAllHotels+","+C.showAllHotelsLi).hide();E._clearFilters();E._filter()});E._defaultRegionsLabel=A(C.regionsFilter,H).find("a.selected").html();E._defaultClassLabel=A(C.classFilter,H).find("a.selected").html();A(C.regionsFilter,H).click(function(J){A(C.classFilter,H).removeClass("active");var K=A(J.target);var M=K.closest("li"),N=A(this),L=function(){var O=N.find("input:checked");if(O.length){E._regions={};O.each(function(P,Q){A(Q).attr("checked","checked");var R=A(Q).attr("value").split("-");A(R).each(function(S,T){E._regions[T]=true})});N.find("a.selected").html("<strong> "+_getNumerableStringRu(O.length,"Выбран ","Выбрано ","Выбрано ")+O.length+_getNumerableStringRu(O.length," курорт"," курорта"," курортов")+" </strong>")}else{E._regions=null;N.find("a.selected").html(E._defaultRegionsLabel)}E._filter()};if(M.length){L()}else{if(K.filter("a.save").length){A(this).removeClass("active")}}});A(C.classFilter,H).click(function(J){A(C.regionsFilter,H).removeClass("active");var K=A(J.target),L=K.closest("li");if(L.length){var N=L.attr("value"),M=L.html();E._class=N?N:null;A(this).find("a.selected").html("<strong> "+M+" </strong>").end().removeClass("active");E._filter()}});A(C.hotelListBlock).find("a.clear").hover(function(){A(this).parent().addClass("clear_all")},function(){A(this).parent().removeClass("clear_all")});A(C.hotelListBlock).click(function(J){var L=A(J.target);if(L.closest("a.add").length){E._showDialog();return }else{if(L.closest("a.clear").length){E._clearFilters();E._clearSelectedHotels()}else{if(L.filter("a._hotel_link i").length){J.stopPropagation();J.preventDefault();var M=L.closest("a._hotel_link").attr("index"),K={};K[M]=true;E._clearSelectedHotels(K)}}}}).find("a._hotel_link").each(function(J,L){L=A(L);var K=L.attr("index");if(K){E._selectHotel(J,K,L.text(),L.attr("href"))}})},reloadHotels:function(G,F){var C=this.element,D=this.options,E=this,I=A(D.hotelsList),B=function(){E._hotelItems=A(D.hotelsList).children().each(function(K,M){var L=A(M).find(":checkbox"),J=L.val();if(E._selectedHotels[J]!==undefined){L[0].checked="true";E._selectHotel(K,J,A(M).find("input:hidden").val(),A(M).find("a").eq(0).attr("href"))}});E._filter()},H=function(){D.reloadHotels.call(I,G,B)};if(typeof (D.reloadHotels)=="function"){if(F){this._onDialogShowStack.push(H)}else{H()}}},reloadRegions:function(F){var B=this.element,C=this.options,D=this,E=A(C.regionsList);this._clearSelectedHotels();this._onDialogShowStack=[];if(typeof (C.reloadRegions)=="function"){this._onDialogShowStack.push(function(){C.reloadRegions.call(D,F)})}},updateRegions:function(D){var C=this,B=C.options;A(B.regionsList).html(D);if(typeof (B.updateRegions)=="function"){B.updateRegions.call(C)}C._filter()},clearFilters:function(){this._clearFilters()},filter:function(){this._filter()},setNamesIndex:function(B){this._hotelNameIndex=B},setFavoriteIndex:function(B){this._hotelFavoriteIndex=B},clearSelectedHotels:function(){this._clearSelectedHotels()},getSelectedHotels:function(){var B="";A.each(this._selectedHotels,function(C,D){B+=B?"-":"";B+=C});return B}})})(jQuery);$.extend($.ui.select_hotel_dialog,{"defaults":{"tint":null,"dialog":null,"onDialogShow":null,"onDialogClose":null,"whatIsFavoriteHotelLink":null,"whatIsFavoriteHotelPopup":null,"closeButton":"a.close","hotelsList":"ul","howToSelectHotelsPopup":null,"regionsList":null,"searchHotelName":"#select_hotel_name_input","showFavoritesOnly":null,"youHaveNoFavoritesPopup":null,"regionsFilter":null,"classFilter":null,"showAllHotels":null,"showAllHotelsLi":null,"hotelListBlock":null,"applyButton":null,"onHotelSelect":null,"onListClear":null},getter:"getSelectedHotels"});(function(A){A.widget("ui.select_regions",{_selectedRegions:{},_contentHolder:null,_openDialog:function(){this.element.closest("div.select").addClass("active")},_closeDialog:function(){this.element.closest("div.select").removeClass("active")},_onRegionsLoaded:function(B){this._contentHolder.html(B);this.element.children("strong").html("Все курорты");if(typeof (this.options.onRegionsLoaded)=="function"){this.options.onRegionsLoaded(B)}},_loadRegions:function(C){var B=this;C=parseInt(C,10);this._clearSelectedRegions();A.ajax({url:B.options.loadRegionsUrl+C+"/",dataType:"text",success:function(D){if(D!==undefined){B._onRegionsLoaded(D)}},error:function(E,D){}})},_clearSelectedRegions:function(C){if(!C){C=this._selectedRegions}var B=this;A.each(C,function(D){B._contentHolder.find('input:checkbox[value="'+D+'"]')[0].checked=false;B._contentHolder.find('input:checkbox[value="'+D+'"]').removeAttr("checked_attr")});this._showSelectedRegions()},_showSelectedRegions:function(){var I=this._contentHolder.find("input:checkbox:checked"),F=this.element,C=this.options,B=F.parent().find("a.selected"),J=null,E=A(C.regionLabelHolder),D=A(C.regionLabelHolder).children("span").eq(0),K=this;if(!I.length){J="Все курорты";E.hide()}else{var H=I.length;E.show();J=_getNumerableStringRu(H,"Выбран ","Выбрано ","Выбрано ")+H+_getNumerableStringRu(H," курорт"," курорта"," курортов")}D.html(J+": ");B.children("strong").html(J);var G="";K._selectedRegions={};I.each(function(L,M){M=A(M);K._selectedRegions[M.val()]=true;G+='<a value="'+M.val()+'" class="_region_link" href="javascript:void(0);">'+M.parent().text()+"<i></i></a> "});E.find("a._region_link").remove();A(G).insertAfter(D)},_init:function(){var B=this.element,C=this.options,D=this,F=B.parent().find("ul").eq(0),E=A(C.regionLabelHolder);B.parent().attr("id",B.attr("id")+"-holder");this._contentHolder=F;B.click(function(){D._openDialog()});B.parent().find("a.selected").eq(1).click(function(){D._closeDialog()});this._contentHolder.click(function(G){var H=A(G.target).closest("li");if(H.length){D._showSelectedRegions();if(typeof (C.onRegionSelect)=="function"){C.onRegionSelect.call(D,H)}if(typeof (C.onRegionChange)=="function"){C.onRegionChange.call(D)}}}).find(":checkbox:checked").each(function(G,H){if(typeof (C.onRegionSelect)=="function"){C.onRegionSelect.call(D,A(H).closest("li"))}if(typeof (C.onRegionChange)=="function"){C.onRegionChange.call(D)}});A(document).click(function(G){if(!A(G.target).closest("#"+B.attr("id")+"-holder").length&&!A(G.target).closest("#"+C.regionLabelHolder).length){D._closeDialog()}});B.parent().find("a.save").click(function(){D._closeDialog()});E.find("a.clear").hover(function(){A(this).parent().addClass("clear_all")},function(){A(this).parent().removeClass("clear_all")});E.click(function(G){var I=A(G.target);if(I.closest("a._region_link").length){var J=I.closest("a._region_link").attr("value"),H={};H[J]=true;D._clearSelectedRegions(H)}else{if(I.filter("a.add").length){D._openDialog()}else{if(I.filter("a.clear").length){D._clearSelectedRegions()}}}})},clearSelectedRegions:function(){this._clearSelectedRegions()},getSelectedRegions:function(){var B="";A.each(this._selectedRegions,function(D,C){if(D){B+=B?"-":"";B+=D}});return B},loadRegions:function(B){this._loadRegions(B)},refreshValues:function(){var B=this.options,C=this,D=A(B.regionLabelHolder).find("a._region_link");D.each(function(E,F){C._selectedRegions[A(this).attr("value")]=true})}})})(jQuery);$.extend($.ui.select_regions,{"defaults":{"loadRegionsUrl":null,"onRegionsLoaded":null,"regionLabelHolder":null},getter:"getSelectedRegions"});(function(A){A.widget("ui.roomsize",{_value:null,_setValue:function(K){var H=this.element,D=this.options,C=H.parent(),J=C.find("ul").eq(0),B=C.find("a.selected"),E=J.find("li"),G=E.filter('[value="'+K+'"]').eq(0);if(G.length){var I=G.text();E.removeClass("check");G.addClass("check");B.children("strong").html(I);this._value=K;if(typeof (D.onChange)=="function"){D.onChange.call(self)}C.removeClass("active");A(D.singleChildRoom+","+D.doubleChildrenRoom).hide();var F=function(L){if(A(D.parentSet).length){if(L){A(D.parentSet).addClass("extended")}else{A(D.parentSet).removeClass("extended")}}};switch(K){case 18:case 20:A(D.singleChildRoom).show();F(true);break;case 19:case 21:A(D.doubleChildrenRoom).show();F(true);break;default:F(false);break}}},_init:function(){var C=this.element,D=this.options,B=C.parent(),G=B.find("ul").eq(0),F=B.find("a.selected"),E=this;F.click(function(){B.toggleClass("active")});B.click(function(H){H.stopPropagation();H.preventDefault();if(A(H.target).closest("li").length){E._setValue(A(H.target).closest("li").attr("value"))}});A(document).click(function(){B.removeClass("active")});this._value=parseInt(C.attr("value"),10)},getValue:function(){var F="&RoSi="+this._value,B=this.options;if(this._value==18||this._value==20){var D=parseInt(A(B.singleChildRoom).find("a.selected").eq(0).text(),10);F+="&Ch1="+D}else{if(this._value==19||this._value==21){var E=A(B.doubleChildrenRoom).find("a.selected").filter(":visible"),D=parseInt(E.eq(0).text(),10),C=parseInt(E.eq(1).text(),10);F+="&Ch1="+D+"&Ch2="+C}}return F},setValue:function(C){var B=this.options;this._setValue(C)},onChange:function(B){if(typeof (B)=="function"){this.options.onChange=B}}})})(jQuery);$.extend($.ui.roomsize,{"defaults":{"singleChildRoom":null,"doubleChildrenRoom":null},"getter":"getValue"});var TourToolbox={getHashVariable:function(D,C){var A=new RegExp(D+"=([^&$]*)");if(C===undefined){C=$.History.getHash()}var B=C.match(A);if(B!==null&&B[1]!==undefined){return B[1]}else{return null}},setHashVariable:function(C,I,G,B){var A,D;if(B===undefined){A=$.History.getHash()}else{A=B}var H=A.split(";");switch(G){case"tsf":D=H[0].replace("tsf=","");break;case"tsr":D=H[1].replace("tsr=","");break}var E=new RegExp(C+"=([^&$]*)");if(D.match(E)){D=D.replace(E,C+"="+I)}else{var F=D.split("&");F.push(C+"="+I);D=F.join("&")}switch(G){case"tsf":H[0]="tsf="+D;break;case"tsr":H[1]="tsr="+D;break}A=H.join(";");if(B===undefined){$.History.setHash(A)}return A},setHashDataVariable:function(C,A,B){return this.setHashVariable(C,A,"tsf",B)},setHashParamVariable:function(C,A,B){return this.setHashVariable(C,A,"tsr",B)},clearHashParamVariables:function(B){var A;if(B===undefined){A=$.History.getHash()}else{A=B}A=A.replace(/tsr=.+/,"tsr=");if(B===undefined){$.History.setHash(A)}return A},loadTours:function(B,A){$.ajax({url:"/ajax/loadTours/?"+B,dataType:"json",success:function(C){A(C)},error:function(C,E,D){A(null)}})}};(function(A){A.widget("ui.tourhotel",{expanded:false,ti_id:null,tours_loaded:0,tours_container:undefined,more_button:undefined,hide_button:undefined,_init:function(){var C=this.element,D=this.options,B=this;B.ti_id=D.ti_id;B.tours_container=A("#tours_"+B.ti_id);B.more_button=A("#more_"+B.ti_id);B.hide_button=A("#hide_"+B.ti_id);B.more_button.click(function(E){E.preventDefault();E.stopPropagation();B.showMoreTours()});B.hide_button.click(function(E){E.preventDefault();E.stopPropagation();B.hideContainer()})},showMoreTours:function(){var C=this,D=this.options;if((D.tours_pre_loaded>C.tours_loaded||C.tours_loaded>0)&&!C.expanded){C.showContainer();if(!D.has_more_tours){C.more_button.hide()}}else{var B=parseInt(C.options.tours_start_from)+parseInt(C.tours_loaded)+parseInt(D.tours_pre_loaded);C.more_button.sleep();C.loadTours(C.options.tours_limit,B,function(E){if(E!==undefined){C.tours_container.append(E)}if(!C.expanded){C.showContainer()}else{A.scrollTo(C.hide_button,1000,{offset:-A(window).height()+50})}C.more_button.wakeup();if(!D.has_more_tours){C.more_button.hide()}})}},showContainer:function(){var B=this;this.expanded=true;this.tours_container.slideDown(1000);this.hide_button.show();A.scrollTo(this.element,1000,{offset:-25})},hideContainer:function(){this.expanded=false;var B=this;A.scrollTo(B.element,1000,{offset:-25});B.tours_container.slideUp(1000);B.hide_button.hide();B.more_button.show()},loadTours:function(F,D,B){var C=this;var E=A.History.getHash();E=TourToolbox.clearHashParamVariables(E);E=TourToolbox.setHashParamVariable("tours_limit",F,E);E=TourToolbox.setHashParamVariable("tours_offset",D,E);E=TourToolbox.setHashDataVariable("Als",this.ti_id,E);TourToolbox.loadTours(E,function(G){C.processTours(G,B,C)})},processTours:function(E,B,D){if(E){if(E[D.ti_id]){D.options.has_more_tours=E[D.ti_id].has_more_tours;D.tours_loaded+=E[D.ti_id].tours_count;var C=E[D.ti_id].tours}else{var C=undefined}B(C)}else{B()}}})})(jQuery);$.extend($.ui.tourhotel,{defaults:{tours_start_from:3,tours_limit:10,tours_pre_loaded:0,has_more_tours:1}});(function(A){A.widget("ui.tourresult",{hotels:Array(),hotel_ids:Array(),_init:function(D,C){var E=this.element,F=this.options;this.hotels=E.find("."+F.hotel_class);var B=this;A.each(this.hotels,function(K,I){var J=A(I).attr("hotel_id");var H=A(I).attr("pre_loaded_tours");var G=A(I).attr("has_more_tours");A(I).tourhotel({ti_id:J,tours_start_from:F.tours_start_from,tours_limit:F.tours_limit,tours_pre_loaded:H,has_more_tours:G});B.hotel_ids.push(J)})}})})(jQuery);$.extend($.ui.tourresult,{defaults:{hotel_class:"tour",tours_start_from:3,tours_limit:10}})