onHistoryChange=function(){};(function(A){if(typeof console==="undefined"){console=typeof window.console!=="undefined"?window.console:{}}console.log=console.log||function(){};console.debug=console.debug||console.log;console.warn=console.warn||console.log;console.error=console.error||function(){var B=[];for(var C=0;C<arguments.length;C++){B.push(arguments[C])}alert(B.join("\n"))};console.trace=console.trace||console.log;console.group=console.group||console.log;console.groupEnd=console.groupEnd||console.log;console.profile=console.profile||console.log;console.profileEnd=console.profileEnd||console.log;A.History={options:{debug:false},state:"",$window:null,$iframe:null,handlers:{generic:[],specific:{}},format:function(B){B=B.replace(/^.+?#/g,"").replace(/^#?\/?|\/?$/g,"");return B},getState:function(){var B=A.History;return B.state},setState:function(C){var B=A.History;C=B.format(C);B.state=C;return B.state},getHash:function(){var B=A.History;var C=window.location.hash||location.hash;C=B.format(C);return C},setHash:function(C){var B=A.History;C=A.History.format(C);C=C.replace(/^\/?|\/?(\?)|\/?$/g,"/$1");if(typeof window.location.hash!=="undefined"){window.location.hash=C}else{location.hash=C}if(A.browser.msie&&parseInt(A.browser.version,10)<8){A.History.$iframe.contentWindow.document.open();A.History.$iframe.contentWindow.document.close();A.History.$iframe.contentWindow.document.location.hash=C}},go:function(C){var B=A.History;C=B.format(C);var D=B.getHash();if(D!==C){B.setHash(C)}else{B.setState(C);B.trigger()}return true},hashchange:function(E){var B=A.History;if(B.options.debug){console.debug("History.hashchange",this,arguments)}var D=B.getHash();var C=B.getState();if((!B.$iframe&&C===D)||(B.$iframe&&B.hash===B.$iframe.contentWindow.document.location.hash)){return false}if(C===D){return false}B.setState(D);B.trigger();return true},bind:function(D,B){var C=A.History;if(B){if(typeof C.handlers.specific[D]==="undefined"){C.handlers.specific[D]=[]}C.handlers.specific[D].push(B)}else{B=D;C.handlers.generic.push(B)}return true},trigger:function(F){var D=A.History;if(typeof F==="undefined"){F=D.getState()}var B,G,C,E;if(typeof D.handlers.specific[F]!=="undefined"){E=D.handlers.specific[F];for(B=0,G=E.length;B<G;++B){C=E[B];C(F)}}E=D.handlers.generic;for(B=0,G=E.length;B<G;++B){C=E[B];C(F)}return true},construct:function(){var B=A.History;A(document).ready(function(){B.domReady()});return true},configure:function(B){var C=A.History;C.options=A.extend(C.options,B);return true},domReadied:false,domReady:function(){var B=A.History;if(B.domRedied){return }B.domRedied=true;B.$window=A(window);B.$window.bind("hashchange",this.hashchange);setTimeout(B.hashchangeLoader,200);return true},hashchangeLoader:function(){var C=A.History;if(!(A.browser.msie&&parseInt(A.browser.version)>=8)){var B;if(A.browser.msie){C.$iframe=A('<iframe id="jquery-history-iframe" style="display: none;"></$iframe>').prependTo(document.body)[0];try{C.$iframe.contentWindow.document.open();C.$iframe.contentWindow.document.close()}catch(E){}var D=C.getHash();if(D){C.$iframe.contentWindow.document.location.hash=D}B=function(){var F=C.format(C.$iframe.contentWindow.document.location.hash);if(C.getState()!==F){C.setHash(C.$iframe.contentWindow.document.location.hash)}var G=C.getHash();if(C.getState()!==G){C.go(G)}}}else{B=function(){var F=C.getHash();if(C.getState()!==F){C.go(F)}}}setInterval(B,200)}else{var D=C.getHash();if(D){C.$window.trigger("hashchange")}}return true}};A.History.construct()})(jQuery);(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.prototype,{options:{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();if(!$("#select-price-type").find("input:checked").length){$("#select-price-type").find("input").eq(0).attr("checked",true)}$("#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 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.prototype,{options:{"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,_hotelItemsHTML:null,_hotelItemsInfo:null,_hotelItemHeight:23,_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._redrawList();D.fadeIn(function(){E.show();if(typeof (C.onDialogShow)=="function"){C.onDialogShow.call(E)}})},_redrawList:function(){this._hotelWrapperScrollHandler(null)},_filter:function(){var D=this;function H(){A("#hotels-wrapper").css("height",D._getItemsNum()*D._hotelItemHeight+"px");D._redrawList()}if(this._name===null&&this._regions===null&&this._class===null&&!this._favorites){D._shownIds=null;H();return }var G=D._hotelItemsInfo;D._shownIds=[];for(var E=0;E<G.length;E++){var I=G[E];if(D._favorites){if(_favorites_index[I["hotel_id"]]){D._shownIds.push(E)}}else{var C=!D._name||(D._name&&D._name[E]),B=!D._regions||(D._regions&&D._regions[I["region"]]),F=!D._class||(D._class&&D._class==I["class"]);if(C&&B&&F){D._shownIds.push(E)}}}H()},_shownIds:null,_searchHotelName:function(H){var B=null;if(!this._hotelNameIndex){return }if(H.length){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(C._hotelFavoriteIndex){C._clearFilters();this._favorites=true;if(C._hotelFavoriteIndex.indexOf("#")!=-1){A(B.whatIsFavoriteHotelLink+","+B.showFavoritesOnly).hide();A(B.showAllHotels+","+B.showAllHotelsLi).show()}else{A(B.youHaveNoFavoritesPopup).fadeIn("slow");return }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);this._redrawList();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("[selected_container]").html(this._defaultRegionsLabel);A(B.regionsFilter).find("input:checkbox:checked").each(function(C,D){D.checked=false});A(B.classFilter).OWidget().setValue("any")},_modifyHotelItemSelect:function(B){var C=this;if(!C._hotelItemsHTML){return false}var D=C._hotelItemsHTML[B];if(!D){return }D=D.replace(/ checked\="checked"/g,"").replace(/type\="checkbox"/g,'type="checkbox" checked="checked"');C._hotelItemsHTML[B]=D},_modifyHotelItemDeselect:function(B){var C=this;if(!C._hotelItemsHTML){return false}var D=C._hotelItemsHTML[B];if(!D){return }D=D.replace(/ checked\="checked"/g,"");C._hotelItemsHTML[B]=D},_selectHotel:function(F,E,C,B){var D=this;E=parseInt(E);if(D._hotelItemsHTML){D._modifyHotelItemSelect(F)}D._selectedHotels[E]={"index":F,"name":C,"href":B};D._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"];B._modifyHotelItemDeselect(E);delete B._selectedHotels[D]}});this._refreshHotelListBlock();if(A.isEmptyObject(B._selectedHotels)&&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();A(document).focus();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 F=this.element,C=this.options,I=this,J=A(C.tint),B=A(C.dialog),D=A(C.howToSelectHotelsPopup);if(typeof (_favorites_index)=="object"){var E=[];A.each(_favorites_index,function(K,L){E.push("#fv"+K)});this._hotelFavoriteIndex=E.join(",")}F.click(function(K){I._showDialog()});A(document).click(function(K){if(!A(K.target).closest(C.whatIsFavoriteHotelPopup).length&&!A(K.target).closest(C.whatIsFavoriteHotelLink).length){A(C.whatIsFavoriteHotelPopup).hide()}if(!A(K.target).closest(C.showFavoritesOnly).length&&!A(K.target).closest(C.youHaveNoFavoritesPopup).length){A(C.youHaveNoFavoritesPopup).hide()}if(!A(K.target).closest("div.select").length){A("div.select",B).removeClass("active")}});B.find(C.closeButton).click(function(K){I._closeDialog()});A(document).keydown(function(K){if(K.keyCode==27){I._closeDialog()}});var G=function(L){if(A(this).filter(C.showAllHotelsLi).length){A(C.showAllHotels).trigger("click");return }var M=A(this),P=M.attr("i"),N=A("label input:checkbox",M),S=N.val(),O=M.children("p").html(),R=A("label a",M).attr("href"),Q=N[0].checked;if(Q){I._selectHotel(P,S,O,R);if(typeof (C.onHotelSelect)=="function"){C.onHotelSelect.call(I,S,O,P)}}else{var K={};K[S]=true;I._clearSelectedHotels(K)}};var H=A(C.hotelsList);A("li",H).live("click",G);A(C.applyButton).click(function(){I._closeDialog()});A("a.selected",B).live("click",function(){A(this).closest("div.select").toggleClass("active")});A(C.searchHotelName,B).smart_input({"label":"Начните вводить название отеля"}).keyup(function(){I._searchHotelName(A(this).val())});A(C.whatIsFavoriteHotelLink,B).click(function(K){A(C.whatIsFavoriteHotelPopup).fadeIn("slow")});A(C.showFavoritesOnly,B).click(function(){I._showFavoritesOnly()});A(C.showAllHotels).click(function(){A(C.whatIsFavoriteHotelLink+","+C.showFavoritesOnly).show();A(C.showAllHotels+","+C.showAllHotelsLi).hide();I._clearFilters();I._filter()});I._defaultRegionsLabel=A(C.regionsFilter,B).find("a.selected").html();I._defaultClassLabel=A(C.classFilter,B).find("a.selected").html();A(C.regionsFilter,B).click(function(K){A(C.classFilter,B).removeClass("active");var L=A(K.target);var N=L.closest("li"),O=A(this),M=function(){var P=O.find("input:checked");if(P.length){I._regions={};P.each(function(Q,R){A(R).attr("checked","checked");var S=A(R).attr("value").split("-");A(S).each(function(T,U){I._regions[U]=true})});O.find("a.selected").html("<strong> "+_getNumerableStringRu(P.length,"Выбран ","Выбрано ","Выбрано ")+P.length+_getNumerableStringRu(P.length," курорт"," курорта"," курортов")+" </strong>")}else{I._regions=null;O.find("a.selected").html(I._defaultRegionsLabel)}I._filter()};if(N.length){M()}else{if(L.filter("a.save").length){A(this).removeClass("active")}}});A(C.classFilter,B).click(function(K){A(C.regionsFilter,B).removeClass("active");var L=A(K.target),M=L.closest("li");if(M.length){var O=M.attr("value"),N=M.html();I._class=O?O:null;A(this).find("a.selected").html("<strong> "+N+" </strong>").end().removeClass("active");I._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(K){var M=A(K.target);if(M.closest("a.add").length){I._showDialog();return }else{if(M.closest("a.clear").length){I._clearFilters();I._clearSelectedHotels()}else{if(M.filter("a._hotel_link i").length){K.stopPropagation();K.preventDefault();var N=M.closest("a._hotel_link").attr("index"),L={};L[N]=true;I._clearSelectedHotels(L)}}}}).find("a._hotel_link").each(function(K,M){M=A(M);var L=M.attr("index");if(L){I._selectHotel(K,L,M.text(),M.attr("href"))}})},_recentTimeout:null,_lastRenderTime:50,_getItemsNum:function(){var B=this;if(B._shownIds==null){return B._hotelItemsHTML?B._hotelItemsHTML.length:-1}else{return B._shownIds.length}},_itemHTMLForIndex:function(B){var D=this;var C=D._shownIds==null?B:D._shownIds[B];if(!D._hotelItemsInfo){return null}return D._hotelItemsHTML[C]},_hotelWrapperScrollHandler:function(B){var C=this;if(C._recentTimeout){clearTimeout(C._recentTimeout);C._recentTimeout=null}C._recentTimeout=setTimeout(function(){var I=new Date();var L=A("#hotels-wrapper");if(!L.length){return }var D=L[0].parentNode.scrollTop,G=C._hotelItemHeight;var K=Math.max(0,Math.floor(D/G)-20);var E=Math.ceil(A(L[0].parentNode).height()/G)+40;var H=Math.min(C._getItemsNum()-1,K+E);var J=['<ul style="padding-top: '+(K*G)+'px;">'];for(var F=K;F<=H;F++){J.push(C._itemHTMLForIndex(F))}J.push("</ul>");L.html(J.join(""));C._lastRenderTime=(new Date()).getTime()-I.getTime();C._recentTimeout=null},C._lastRenderTime)},_modifyItemsFavourite:function(){var C=this;if(window._favorites_index){for(var B in C._hotelItemsInfo){var D=C._hotelItemsInfo[B];if(_favorites_index[D["hotel_id"]]){C._hotelItemsHTML[B]=C._hotelItemsHTML[B].replace('id="fv'+D["hotel_id"]+'"','id="fv'+D["hotel_id"]+'" class="love"')}}}},reloadHotels:function(G,F){var C=this.element,D=this.options,E=this,I=A(D.hotelsList),B=function(){var O=E._hotelItemsHTML;if(O&&O.length>0){I.html("<ul>"+O[0]+"</ul>");var M=A("li",I);var L=parseInt(M.css("height"))+(parseInt(M.css("border-top-width"))||0)+(parseInt(M.css("border-bottom-width"))||0);if(L){E._hotelItemHeight=L}I.html('<div id="hotels-wrapper" style="height: '+(E._hotelItemHeight*O.length)+'px; overflow: hidden;"></div>');var N={};A(D.hotelListBlock).find("a._hotel_link").each(function(P,R){R=A(R);var Q=R.attr("index");if(Q){N[Q]={name:R.text(),href:R.attr("href")}}});for(var K=0;K<E._hotelItemsInfo.length;K++){var J=parseInt(E._hotelItemsInfo[K]["id"]);if(N[J]){E._selectHotel(K,J,N[J]["name"],N[J]["href"])}}E._modifyItemsFavourite();E._redrawList();I.unbind("scroll");I.scroll(function(P){E._hotelWrapperScrollHandler(P)})}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="";var C=new Array();A.each(this._selectedHotels,function(D,E){C.push(D)});C.sort(function(E,D){return E-D});B=C.join("-");return B},setHotelItemsHTML:function(B){this._hotelItemsHTML=B},setHotelItemsInfo:function(B){this._hotelItemsInfo=B}})})(jQuery);$.extend($.ui.select_hotel_dialog.prototype,{"options":{"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=$.hash()}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=$.hash()}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){$.hash(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=$.hash()}else{A=B}A=A.replace(/tsr=.+/,"tsr=");if(B===undefined){$.hash(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.hash();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:[],hotel_ids:[],_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}})
