(function(){var I=false;jQuery.hash=function(L,K){if(!arguments.length){return J()}if(L.charAt(0)=="#"){L=L.substring(1)}if(K){B(L)}else{location.href="#"+L}return L};var C=J(),F=null,E=100;function H(M,K){var L=M.indexOf(K);return(L>=0)?M.substring(L+1):""}function J(){return H(location.href,"#");document.write(location.href)}var D=function(){var K=new jQuery.Event("hashchange");K.hash=J();$(document).trigger(K)};function A(){if(J()===C){return }C=J();D()}function B(M){if(F){if(F.isTransitioning()){setTimeout(function(){B.call(null,M)},E);return }var K=F.iframe.location.href;var L=K.indexOf("?");F.iframe.location.replace(K.substring(0,L)+"?"+M);return }location.replace("#"+M);A()}function G(){var Q=$("<iframe />").attr("src","/IETourIframe?"+J()).attr("id","IFRAME_ID").hide().appendTo($("body"))[0],S="/",K=J();this.iframe=document.getElementById("IFRAME_ID").contentWindow;var R,T,L,O,M,P=this.iframe.location;function N(){K=J();R=M?K:H(P.href,"?");T=false;L=null}this.isTransitioning=function(){return T};var V=this;this.pollLocation=function(){if(!M){try{var W=H(P.href,"?")}catch(Z){M=true}}var Y=J();if(T&&K===Y){if(M||W===L){N();D()}else{var X=this;setTimeout(function(){X.pollLocation.call(X)},E);return }}else{if(K===Y&&(M||R===W)){}else{if(K!==Y){K=Y;T=true;L=Y;Q.src=S+"?"+L;M=false;var X=this;setTimeout(function(){X.pollLocation.call(X)},E);return }else{if(!M){location.href="#"+P.search.substring(1);N();D()}}}}var X=this;setTimeout(function(){X.pollLocation.call(X)},E)};N();var U=this;setTimeout(function(){U.pollLocation.call(U)},E)}$(function(){if(I){return }else{I=true}if(("onhashchange" in window)&&!$.browser.msie){$(window).bind("hashchange",D)}else{if(document.addEventListener){C=J();setInterval(A,E)}else{if(document.attachEvent){F=new G()}}}})})();(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}});(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}});floatWidget={_active:[],getOpenActive:function(){var A=this._active[this._active.length-1];if(!A){return }if(!A.$container||A.$container.is(":hidden")){return }return A},closeActive:function(A){var B=this.getOpenActive();if(!B){return }if(!A){if(B.cancel){B.cancel()}else{B.close()}}if(A){if(B.accept){B.accept()}else{B.close()}}},setEscapeEnterHandler:function(){var A=this;$(document).keyup(function(C){var B=C.which;if(B!=27&&B!=13){return }C.preventDefault();A.closeActive(B==13)})},activePush:function(A){this._active.push(A)},activePop:function(C){for(var B=0;B<this._active.length;B++){var A=this._active[B];if(A===C){this._active.splice(B,1);break}}}};$(function(){floatWidget.setEscapeEnterHandler()});floatWidgetMixin={hideIfClickOutsideHandler:function(A){if(!this.isOpen()){return }var B=A.target;while(B.tagName!="BODY"&&B!=this.$container[0]&&B!=this.element[0]){B=B.parentNode}if(B!=this.$container[0]&&B!=this.element[0]&&!this.insideSelector(A)){this.cancel?this.cancel():this.close()}},setHideIfClickOutside:function(A){if(!this.boundHideIfClickOutsideHandler){this.boundHideIfClickOutsideHandler=$.proxy(this,"hideIfClickOutsideHandler")}$(document.body)[A?"bind":"unbind"]("click",this.boundHideIfClickOutsideHandler)},insideSelector:function(A){var B=this.$container.offset();B.right=B.left+this.$container.outerWidth();B.bottom=B.top+this.$container.outerHeight();return A.pageY<B.bottom&&A.pageY>B.top&&A.pageX<B.right&&A.pageX>B.left}};(function(B){B.Widget.prototype.readTemplate=function(H){if(window.WIDGET_TEMPLATES&&WIDGET_TEMPLATES[H]){this.template=WIDGET_TEMPLATES[H];return }var F=document.getElementById("template-"+H).innerHTML;var E=B.trim(F).split(/@@/);var G={};for(var D=0;D<E.length;D++){E[D]=E[D].split("\n");var C=B.trim(E[D].shift());G[C]=E[D].join("\n")}this.template=G};var A=B.fn.val;B.fn.val=function(){if(this.length&&this[0].tagName!="INPUT"){if(!arguments.length){if(this.length&&B(this[0]).data("getValue")){return B(this[0]).data("getValue")()}}if(arguments.length==1&&!B.isFunction(arguments[0])){for(var C=0;C<this.length;C++){if(!B(this[C]).data("setValue")){A.apply(B(this[C]),arguments)}else{B(this[C]).data("setValue")(arguments[0])}}return this}}return A.apply(this,arguments)};B.widget("ui.tourWidget",B.extend({_create:function(){this.readTemplate(this.option("template"));var C=this;this.$result=B("<div/>").appendTo(this.element).click(function(D){C.isOpen()?C.close():C.open();D.preventDefault()});this.element.data("getValue",B.proxy(this,"getValue"));this.element.data("setValue",B.proxy(this,"setValue"));this.setHideIfClickOutside(true)},renderResultValue:function(){this.$result.html(this.template.text.replace("%title%",this.getValueAsText(this.value)))},getValueAsText:function(){},renderContainer:function(){},isOpen:function(){return this.element.hasClass("active")},open:function(){this.renderContainer();this.element.addClass("active");floatWidget.activePush(this)},close:function(){this.element.removeClass("active");floatWidget.activePop(this)},getValue:function(){return this.value}},floatWidgetMixin))})(jQuery);(function(A){A.widget("ui.tourListWidget",A.ui.tourWidget,{_create:function(){A.ui.tourWidget.prototype._create.apply(this,arguments);this.itemTemplate=this.option("itemTemplate")||"item";this.setOpts(this.option("opts"),this.option("optGroups"));this.setValue(this.option("value"))},setValue:function(){},bindContainerHandlers:function(){},renderContainerItem:function(B){var C=this.optsOrder[B];var D=this.opts[C];return this.template[this.itemTemplate].replace("%title%",D).replace("%value%",C)},renderContainer:function(){if(this.$container){return }this.$container=A("<div/>").appendTo(this.element).addClass("container");var C=[];for(var D=0;D<this.optsOrder.length;D++){var E=this.optsOrder[D];if(E.length){var F=this.opts[E];if(this.optGroups[E]){C.push(this.template.optGroup.replace("%title%",this.optGroups[E]))}C.push(this.renderContainerItem(D))}}var B=this.template.body.replace("%options%",C.join("\n"));this.$container.html(B);if(C.length>9){A("ul",this.$container).addClass("scroll")}this.$containerValue=A(".widget-value",this.$container);this.bindContainerHandlers()},setOpts:function(C,D){this.opts={};this.optsOrder=[];for(var B in C){this.opts[B.substr(1)]=C[B];this.optsOrder.push(B.substr(1))}this.optGroups=D||{};if(this.$container){this.$container.remove();this.$container=null}},getOpts:function(){var C={};for(var B=0;B<this.optsOrder.length;B++){var D=this.optsOrder[B];var E=this.opts[D];C["_"+D]=E}return{opts:C,optGroups:this.optGroups}}})})(jQuery);(function(A){A.widget("ui.tourCheckList",A.ui.tourListWidget,{open:function(){A.ui.tourListWidget.prototype.open.apply(this);this.renderContainerValue()},accept:function(){this.close();this.element.trigger("select",this.getValue())},cancel:function(){this.accept()},onInputChange:function(B){if(B.target.checked){this.value[B.currentTarget.value]=true}else{delete this.value[B.currentTarget.value]}this.renderContainerValue();this.renderResultValue()},bindContainerHandlers:function(){var B=this;this.$container.delegate(".widget-apply, .widget-toggle","click",function(C){B.accept();return false}).delegate("input","click",A.proxy(this,"onInputChange")).delegate("li","mouseover",function(C){A(this).addClass("hover")}).delegate("li","mouseout",function(C){A(this).removeClass("hover")})},renderContainerValue:function(){var B=this.value;A("input",this.$container).each(function(){this.checked=B[this.value]});this.$containerValue.html(this.getValueAsText(this.value))},getValue:function(){var C=[];for(var B in this.value){this.value[B]&&C.push(B)}return C},getValueAsText:function(D){var C=0;for(var B in D){C++}return C},removeValue:function(B){var C=A(this.getValue()).not(function(){return this==B});this.setValue(C)},setValue:function(C){var B=this;var D={};A.each(C,function(F,E){if(B.opts[E]){D[E]=true}});this.value=D;this.renderResultValue();this.element.trigger("select",this.getValue())}})})(jQuery);(function(A){A.widget("ui.resortCheckList",A.ui.tourCheckList,{_create:function(){if(this.option("mini")){this._allResortsVpad=this.option("_allResortsVpad")}A.ui.tourCheckList.prototype._create.apply(this,arguments)},getValueAsText:function(D){var C=0;for(var B in D){C++}if(!this.option("mini")){if(C==0){return"Все курорты"}if(C==1){return"Выбран 1 курорт"}if(C<=4){return"Выбрано "+C+" курорта"}return"Выбрано "+C+" курортов"}else{A("#select-resort-preposition").html(C?"в":"во");if(C==0){return"все курорты"}if(C==1){for(var B in D){}return this._allResortsVpad[B]}if(C<=4){return C+" курорта"}return C+" курортов"}}})})(jQuery);(function(A){A.widget("ui.tourSelectList",A.ui.tourListWidget,{open:function(){A.ui.tourListWidget.prototype.open.apply(this);this.renderContainerValue()},accept:function(B){this.close();this.setValue(B)},bindContainerHandlers:function(){var B=this;this.$container.delegate(".widget-toggle","click",function(C){B.close();C.preventDefault()}).delegate("li","click",A.proxy(this,"onItemClick")).delegate("li","hover",A.proxy(this,"onItemHover"))},onItemHover:function(B){if(!B.currentTarget.getAttribute("val")){return }A(B.currentTarget).toggleClass("hover")},onItemClick:function(B){if(!B.currentTarget.getAttribute("val")){return }A('[val="'+this.value+'"]',this.$container).removeClass("check");this.accept(B.currentTarget.getAttribute("val"))},renderContainerValue:function(){this.$containerValue.html(this.getValueAsText(this.value));A('[val="'+this.value+'"]',this.$container).addClass("check")},getValueAsText:function(B){return this.opts[B]},setValue:function(B){if(this.opts[B]===undefined&&this.optsOrder.length){B=this.optsOrder[0]}this.value=B;this.renderResultValue();this.element.trigger("select",this.value)}})})(jQuery);(function(A){A.widget("ui.tourSelectGroupList",A.ui.tourSelectList,{renderContainerItem:function(C){var D=this.optsOrder[C];var E=this.opts[D];var B=this.option("optClasses")[D];if(B){return this.template["item-with-class"].replace("%title%",E).replace("%value%",D).replace("%class%",B)}else{return this.template["item"].replace("%title%",E).replace("%value%",D)}}})})(jQuery);(function(A){A.widget("ui.tourSelectAge",A.ui.tourSelectList,{getValueAsText:function(B){return this.opts[B]==0?"до года":this.opts[B]+" "+_getNumerableStringRu(+this.opts[B],"год","года","лет")},renderContainerItem:function(B){var C=this.optsOrder[B];var D=this.opts[C]==0?"до года":this.opts[C];return this.template.item.replace("%title%",D).replace("%value%",C)}})})(jQuery);(function(A){A.widget("ui.tourCosts",A.ui.tourWidget,{_create:function(){this.readTemplate(this.option("template"));this.element.html(this.template.any);this.element.delegate(".widget-open","click",A.proxy(this,"open"));this.element.delegate(".widget-reset","click",A.proxy(this,"reset"));this.element.data("getValue",A.proxy(this,"getValue"))},getValue:function(){var B={};A("input:text",this.element).each(function(){if(+this.value){B[this.getAttribute("data-name")]=this.value}});return B},reset:function(){this.element.html(this.template.any);this.option("priceFrom",0);this.option("priceTo",0);return false},getFrom:function(){return +A("#"+this.fieldPrefix+"from").val()},getTo:function(){return +A("#"+this.fieldPrefix+"to").val()},setFrom:function(B){if(+B<=0||!+B){B=""}A("#"+this.fieldPrefix+"from").val(B)},setTo:function(B){if(!+B){B=""}A("#"+this.fieldPrefix+"to").val(B)},fieldPrefix:"hotel-select-costs-input-",open:function(){var B=this;this.element.html(this.template.control);var D=this.fieldPrefix;A("#"+D+"from").focus();this.setFrom(this.option("priceFrom"));this.setTo(this.option("priceTo"));var C={to:function(){if(!B.getTo()){B.setTo(0);return }if(B.getTo()<B.getFrom()){B.setFrom(B.getTo()-100)}},from:function(){if(B.getFrom()<=0||!B.getFrom()){B.setFrom(0)}if(B.getFrom()>B.getTo()&&B.getTo()){B.setTo(B.getFrom()+100)}}};A("#"+D+"from").bind({blur:C.from});A("#"+D+"to").bind({blur:C.to});A("input",this.element).bind("keydown",function(E){if(E.keyCode==13){try{C[this.id.replace(D,"")]()}catch(E){window.console&&console.log(E)}A(this).trigger("submit")}});return false}})})(jQuery);(function(A){A.widget("ui.tourMeals",A.ui.tourSelectList,{renderContainer:function(){this.$container&&this.$container.remove();this.$container=null;A.ui.tourSelectList.prototype.renderContainer.apply(this,arguments)},renderContainerValue:function(){A.ui.tourSelectList.prototype.renderContainerValue.apply(this,arguments);A(".widget-tooltip").html(this.option("tooltips")[this.value])},onItemHover:function(B){A.ui.tourSelectList.prototype.onItemHover.apply(this,arguments);A(".widget-tooltip").html(A(B.currentTarget).attr("data-tooltip"))},renderContainerItem:function(B){var E=this.optsOrder[B];var F=this.opts[E];var D=this.option("tooltips")[E];var C=strip_tags(this.option("tooltips")[E]);return this.template.item.replace("%title%",F).replace("%value%",E).replace("%tooltip%",D).replace("%tagtitle%",C)},updateTooltip:function(B,C){this.option("tooltips")[B]=C}})})(jQuery);(function(A){A.widget("ui.tourSelectHotel",A.ui.tourWidget,{_create:function(){A.ui.tourWidget.prototype._create.apply(this,arguments);var C=this;this._isOpen=false;this.$container=this.element;C.hotels={};C.hotelsCache={};C.hotelIds={};C.filteredIds={};C.value={};C.$formResort=this.option("resortWidget");C.$formCountry=this.option("countryWidget");C.$formStars=this.option("starsWidget");C.favourites=this.option("favouriteHotels");C.show_favourites=false;var E=this.option("value");var B=[];if(E){B=E.split(/,/)}for(var D=0;D<B.length;D++){C.value[B[D]]=true}this.element.data("getValue",A.proxy(C,"getValue"))},isOpen:function(){return this._isOpen},removeSelected:function(B){delete this.value[B];this.element.trigger("select",this.getValue())},clearSelected:function(){this.value={};this.element.trigger("select",this.getValue())},applySelected:function(){this.element.trigger("select",this.getValue())},getHotel:function(C){if(this.hotelsCache["_"+C]){return this.hotelsCache["_"+C]}var B=this.hotels[this.getCountry()];return B?B["_"+C]:false},getValue:function(){var C=[];for(var B in this.value){C.push(B)}return C},getCountry:function(){var B=this.$formCountry.val();if(B.charAt(B.length-1)=="_"){B=B.substr(0,B.length-1)}return B},fillHotels:function(B,E){this.hotels[E]={};this.filteredIds[E]=[];this.hotelIds[E]=[];var C;for(var D in B){C=D.substr(1);this.hotels[E][D]=B[D];this.filteredIds[E].push(C);this.hotelIds[E].push(C)}},open:function(){var I=this;if(this._isOpen){return }this._isOpen=true;this.element.html(this.template.base);A("a.close",this.element).click(A.proxy(this,"close"));var H=A("#select-hotel-filter-regions");I.$my_selresort=H;H.resortCheckList({template:I.$formResort.resortCheckList("option","template"),opts:I.$formResort.resortCheckList("getOpts").opts,value:I.$formResort.val()}).bind("select",A.proxy(I,"filter"));var F=A("#select-hotel-filter-class"),J=I.$formStars.tourSelectList("option","opts");I.$my_selstars=F;delete J._6;F.tourSelectList({template:I.$formStars.tourSelectList("option","template"),opts:J,value:0}).bind("select",A.proxy(I,"filter"));I.$my_inpname=A("#select_hotel_name_input").bind("keyup",A.proxy(I,"filter"));this._hotelItemHeight=23;this._hotelsList=A("#hotel-list-div");var B=I.getCountry();if(!I.hotels[B]){I._hotelsList.html('<div class="wait">Загрузка отелей...</div>');I.hotels[B]="loading";A.ajax({url:"/ajax/loadDialogHotels/"+B+"/",success:function(K){I.fillHotels(K,B);I.filter()},error:function(L,K,M){window.console&&console.log(M)},dataType:"json",timeout:60000})}else{I.fillHotels(I.hotels[B],B);I.filter()}A("#select-hotel-apply-and-close").bind("click",function(){I.close();return false});var G="#link-show-me-only-favorite-hotels",D="#link-show-me-all-hotels",E="#link-what-are-favorite-hotels";A(G).bind("click",function(M){var L=0;for(var K in I.favourites){L++}if(!L){A("#help-you-have-no-favorite-hotels").fadeIn(function(){var N;N=function(){A("#help-you-have-no-favorite-hotels").fadeOut();A(document.body).unbind("click",N);return false};A(document.body).bind("click",N)});M.preventDefault();return }I.show_favourites=true;A(G).hide();A(E).hide();A(D).show();I.filter();return false});A(D).bind("click",function(){I.show_favourites=false;A(G).show();A(E).show();A(D).hide();I.filter();return false});A(E).bind("click",function(K){A("#help-what-are-favorite-hotels").fadeIn(function(){var L;L=function(){A("#help-what-are-favorite-hotels").fadeOut();A(document.body).unbind("click",L);return false};A(document.body).bind("click",L)});K.preventDefault()});var C=A.browser.msie&&A.browser.version<=7?0:300;setTimeout(function(){floatWidget.activePush(I)},C);if(C){this.element.fadeIn(C);A("#select_hotel_tint").css({opacity:0.8}).fadeIn(C)}else{A([this.element[0],A("#select_hotel_tint")[0]]).show()}},_handleClick:function(E){var D=!!this.value[E];if(D){delete this.value[E]}else{this.value[E]=true}var C=0;for(var B in this.value){C++}if(C>200){delete this.value[E];alert("Извините, наш поиск не поддерживает возможность выбора больше 200 отелей");return false}return true},displayHotels:function(){var C=this;if(!this._isOpen){return }var B=0;var D=(this._hotelItemHeight*this._getItemsNum());if(!document.getElementById("hotels-wrapper")){this._hotelsList.html('<div id="hotels-wrapper" style="height: '+D+'px; overflow: hidden;"></div>').bind("scroll",A.proxy(this,"_hotelWrapperScrollHandler")).delegate("input","change",function(E){if(!C._handleClick(A(this).parents("[data-id]").attr("data-id"))){this.checked=false}}).delegate("li","mouseover",function(){if(C.lastHoveredId&&document.getElementById("select_hotel_"+C.lastHoveredId)){A(document.getElementById("select_hotel_"+C.lastHoveredId)).removeClass("hover")}C.lastHoveredId=this.getAttribute("data-id");A(this).addClass("hover")})}else{A("#hotels-wrapper").css("height",D+"px")}this._hotelWrapperScrollHandler()},getNameFilter:function(){return this.$my_inpname.val().toLowerCase()},filter:function(){var H=this.$my_selresort.val(),F=parseInt(this.$my_selstars.val()),C=this.getNameFilter(),G=this.getCountry();var B=[],L=this.hotelIds[G],J=this.hotels[G];var M,D,E;if(C.length){this.nameMatchRegexp=new RegExp(preg_quote(C),"gi");this.nameReplaceFunc=function(N){return"<strong>"+N+"</strong>"}}for(var K=0;K<L.length;K++){D=L[K];M=J["_"+D];if(H.length){E=false;for(var I=0;I<H.length;I++){if(M.REGION==H[I]){E=true}}if(!E){continue}}if(F&&M.SSTAR!=F){continue}if(C&&M.NAME.toLowerCase().indexOf(C)<0&&(!M.RUS_NAME||M.RUS_NAME&&M.RUS_NAME.toLowerCase().indexOf(C)<0)){continue}if(this.show_favourites&&!this.favourites[D]){continue}B.push(D)}this.filteredIds[G]=B;this.displayHotels()},_itemHTMLForIndex:function(B){var E=this.getCountry(),F=this.filteredIds[E][B],D=this.hotels[E]["_"+F];var C=(D.NAME||D.RUS_NAME);if(this.getNameFilter().length){C=C.replace(this.nameMatchRegexp,this.nameReplaceFunc)}return this.template.item.replace(/%id%/g,F).replace("%hotel_url%",D.URL).replace("%checked%",this.value[F]?'checked="checked"':"").replace("%name%",C).replace("%star%",D.STAR).replace("%region_name%",D.REGION_NAME).replace("%classes%",(this.favourites[F]?"love":"")+(F==this.lastHoveredId?" hover":""))},_getItemsNum:function(){return this.filteredIds[this.getCountry()].length},_hotelWrapperScrollHandler:function(){var B=this;if(B._recentTimeout){clearTimeout(B._recentTimeout);B._recentTimeout=null}B._recentTimeout=setTimeout(function(){var H=new Date();var K=A("#hotels-wrapper");if(!K.length){return }var C=K[0].parentNode.scrollTop,F=B._hotelItemHeight;var J=Math.max(0,Math.floor(C/F)-20);var D=Math.ceil(A(K[0].parentNode).height()/F)+40;var G=Math.min(B._getItemsNum()-1,J+D);var I=['<ul style="padding-top: '+(J*F)+'px;">'];for(var E=J;E<=G;E++){I.push(B._itemHTMLForIndex(E))}I.push("</ul>");K[0].innerHTML=(I.join(""));B._lastRenderTime=(new Date()).getTime()-H.getTime();B._recentTimeout=null},B._lastRenderTime||0)},close:function(){var B=this;this._isOpen=false;this.applySelected();var C=[this.element[0],A("#select_hotel_tint")[0]];if(A.browser.msie&&A.browser.version<=7){A(C).hide();floatWidget.activePop(B)}else{A(C).fadeOut(300,function(){floatWidget.activePop(B)})}}})})(jQuery);(function(A){A.widget("ui.tourResortList",{update:function(){if(!this.$resortCheckList.resortCheckList("getValue").length){this.element.addClass("hidden");return }this.element.removeClass("hidden");if(A("#you-are-searching-best-hotels").is(":visible")){this.element.addClass("extend-select-second")}else{this.element.removeClass("extend-select-second")}this.render()},lazyInit:function(){if(this.initialized){return }var B=this;A(this.element).delegate("._region_link","click",function(){B.$resortCheckList.resortCheckList("removeValue",A(this).attr("val"));return false});A(this.element).delegate(".add","click",function(){B.$resortCheckList.resortCheckList("open");return false});A(this.element).delegate(".clear","click",function(){B.$resortCheckList.resortCheckList("setValue",[]);return false});this.initialized=true},render:function(){this.lazyInit();var B=[],E=this.$resortCheckList.resortCheckList("getValue");for(var D=0;D<E.length;D++){B.push(this.template.link.replace("%value%",E[D]).replace("%title%",this.allResorts[E[D]]))}var C=this.template.control.replace("%links%",B.join(" ")).replace("%title%",this.$resortCheckList.resortCheckList("getValueAsText",E)+":");this.element.html(C)},_create:function(){this.readTemplate(this.option("template"));this.$resortCheckList=this.option("resortCheckList");this.allResorts=this.option("allResorts");var B=this;this.$resortCheckList.bind("select",function(){B.update()});B.update()}})})(jQuery);(function(A){A.widget("ui.tourHotelList",{update:function(){if(!this.$selectHotel.val().length){this.element.addClass("hidden");return }this.element.removeClass("hidden");this.render()},lazyInit:function(){if(this.initialized){return }var B=this;A(this.element).delegate(".del","click",function(){B.$selectHotel.tourSelectHotel("removeSelected",A(this).attr("val"));return false});A(this.element).delegate(".add","click",function(){B.$selectHotel.tourSelectHotel("open");return false});A(this.element).delegate(".clear","click",function(){B.$selectHotel.tourSelectHotel("clearSelected");return false});this.initialized=true},render:function(){this.lazyInit();var D=this.$selectHotel.val();var G=[];for(var C=0;C<D.length;C++){if(this.hotels[D[C]]){continue}var E=this.$selectHotel.tourSelectHotel("getHotel",D[C]);if(E){this.hotels[D[C]]=E}else{G.push(D[C])}}var B=this;if(G.length){var F=A("#select-country").val();A.ajax({url:"/ajax/loadDialogHotels/"+F+"/"+G.join(",")+"/",dataType:"json",timeout:60000,success:function(I){for(var H in I){B.hotels[H.substr(1)]=I[H]}B.doRender()},error:function(I,H,J){window.console&&console.error(J)}});return }else{this.doRender()}},doRender:function(){var B=[],F=this.$selectHotel.val();for(var D=0;D<F.length;D++){if(D>10){B.push(this.template["..."]);break}var G=this.hotels[F[D]];var E=+G.SSTAR+1;var H=G.NAME+" "+(E<=5?E+"*":"HV");B.push(this.template.link.replace(/%value%/g,F[D]).replace(/%title%/g,H).replace(/%url%/g,G.URL))}var C=this.template.control.replace("%links%",B.join(" ")).replace("%title%","Выбранные отели: ");this.element.html(C)},_create:function(){this.readTemplate(this.option("template"));this.$selectHotel=this.option("selectHotel");this.hotels={};var B=this;this.$selectHotel.bind("select",function(){B.update()});B.update()}})})(jQuery);(function(A){A.widget("ui.presetWidget",{_create:function(){this.element.data("getValue",A.proxy(this,"getValue"))},getValue:function(){if(this.element[0].tagName=="INPUT"){return this.element[0].value}else{var B={};A("input",this.element).each(function(){var C=A(this).data("name");if(!C){return }B[C]=this.value});return B}}})})(jQuery);var testmeout=null;var publisher=function(A){_extends={_name:"",_subscribers:{},subscribe:function(C,B){if(!$.isArray(this._subscribers[C])){this._subscribers[C]=new Array()}this._subscribers[C].push(B)},_publish:function(B,D){var E=["*",B],C=this;$.each(E,function(G,F){if($.isArray(C._subscribers[F])){$.each(C._subscribers[F],function(I,H){if(!$.isFunction(H._notify)){return }H._notify(C,B,D)})}})}};$.each(_extends,function(B,C){if(!A[B]){A[B]=C}});return A},Publisher=function(){publisher(this)};var subscriber=function(A){_extends={_name:"",_subscribe_handlers:{},_notify:function(E,B,D){var F=["*",B],C=this;$.each(F,function(H,G){var G=E._name+"."+G;if($.isArray(C._subscribe_handlers[G])){$.each(C._subscribe_handlers[G],function(I,J){J.call(C,B,D)})}})},addSubscribeHandler:function(E,B,C){if(!$.isFunction(C)||!$.isFunction(E.subscribe)){throw"smthng went wrong";return }var D=E._name+"."+B;if(!$.isArray(this._subscribe_handlers[D])){this._subscribe_handlers[D]=new Array()}this._subscribe_handlers[D].push(C);E.subscribe(B,this)},removeSubscribeHandler:function(C,B){delete this._subscribe_handlers[B];C.unsubscribe(B,this)}};$.each(_extends,function(B,C){if(!A[B]){A[B]=C}});return A},Subscriber=function(){subscriber(this)};$.widget("ui.formWidgetBase",{_value:null,_name:"",_enabled:true,_create:function(){publisher(this);subscriber(this);this._value=(this.options.defaultValue===undefined)?null:this.options.defaultValue;this._name=this.options.name||null},asPublisher:function(){return this},value:function(){if(!this._enabled){return -1}if(arguments.length){if(this._value!=arguments[0]){this._value=arguments[0];this._publish("valueChange",this._value);this.element.trigger("select",this._value)}return }return this._value},enabled:function(){if(arguments.length){this._enabled=arguments[0];this._publish("stateChange",this._enabled?"enabled":"disabled");return this.element}return this._enabled}});$.widget("ui.formWidgetCollapsable",$.extend({},$.ui.formWidgetBase.prototype,{_frozen:false,_create:function(){this.options.defaultValue=this.element.attr("value");$.ui.formWidgetBase.prototype._create.apply(this,arguments);var A=this.element,B=this.options,C=this;B.getParent=$.isFunction(B.getParent)?B.getParent:function(){return A.closest("div")};B.activeClass=(typeof (B.activeClass)!="undefined")?B.activeClass:"active";B.selectedClass=(typeof (B.selectedClass)!="undefined")?B.selectedClass:"check";B.getLinks=$.isFunction(B.getLinks)?B.getLinks:function(){return B.getParent.call(C).find("a.selected")};B.hide=$.isFunction(B.hide)?B.hide:function(){B.getParent.call(C).removeClass(B.activeClass)};B.show=$.isFunction(B.show)?B.show:function(){B.getParent.call(C).addClass(B.activeClass)};B.getValue=B.getValue||function(F){return F.attr("value")};B.getInternal=B.getInternal||function(){return B.getParent.call(C).find("ul")};B.onInternalClick=$.isFunction(B.onInternalClick)?B.onInternalClick:function(F){if(!C._enabled){return }C.freeze();var G=$(F.target),I=G.closest("li");if(I.length&&!I.hasClass(B.selectedClass)){var H=B.getValue.call(C,I);C.unfreeze();C.value(H);I.parent().find("li").removeClass(B.selectedClass);I.addClass(B.selectedClass);C._setLabel(I.html());C._hide()}};B.setLabel=$.isFunction(B.setLabel)?B.setLabel:function(G){var F;if(F=B.getLinks.call(C)){F.children("strong").html(G)}};B.setValue=B.setValue||function(F,G){C.value(F);B.setLabel.call(C,G)};B.externalSetValue=B.externalSetValue||function(F){$.each(B.getInternal.call(this).find("li"),function(H,G){G=$(G);if(F==B.getValue.call(C,G)){C.value(F);B.setLabel.call(C,G.html());return false}})};var E=B.getParent.call(this,A),D=B.getLinks.call(C);E.click(function(F){B.onInternalClick.call(C,F)});D.click(function(F){if(!C._enabled){return }if(E.hasClass(B.activeClass)){C._hide.call(C)}else{C._show.call(C)}});$(document).click(function(F){C._hide();C.unfreeze()});C.addSubscribeHandler(C,"stateChange",function(F,G){if(G=="disabled"){B.getParent.call(C).addClass("disabled")}else{if(G=="enabled"){B.getParent.call(C).removeClass("disabled")}}})},freeze:function(){this._frozen=true},unfreeze:function(){this._frozen=false},_setLabel:function(A){if(!this._frozen){this.options.setLabel.call(this,A)}},_hide:function(){if(!this._frozen){this.options.hide.call(this)}},_show:function(){if(!this._frozen){this.options.show.call(this)}},externalSetValue:function(A){this.options.externalSetValue.call(this,A)}}));(function(A){A.widget("ui.calendar",{options:{minDate:null,maxDate:null,monthLabels:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],dayLabels:["Пн","Вт","Ср","Чт","Пт","Сб","Вс"],daysPlate:"",onSelect:null,onHoverIn:null,onHoverOut:null,onDisplay:null,currentDate:null,calendarClass:"b-calendar",monthSimultaneously:2,readOnly:false,animation:false,monthScrollerDiff:1,disabledClass:"disabled",todayClass:"current_date",activeDateClass:"to_date",parityDateClass:"from_date",intermediateClass:"selected_dates",parityDate:null},_parityDate:null,_getDay:function(B){var C=B.getDay();return(--C)<0?(C+7):C},_strToDate:function(G){if(G instanceof Date){return G}var F=/(\d{4})\-(\d{1,2})\-(\d{1,2})/.exec(G);var B=new Date();if(F&&F.length==4){var E=parseInt(F[1],10),D=parseInt(F[2],10),C=parseInt(F[3],10);B.setFullYear(E);B.setMonth(D-1,1);B.setDate(C)}else{var F=/(\d{1,2})\.(\d{1,2})\.(\d{4})/.exec(G);if(F&&F.length==4){var E=parseInt(F[3],10),D=parseInt(F[2],10),C=parseInt(F[1],10);B.setFullYear(E);B.setMonth(D-1,1);B.setDate(C)}}B.setHours(0);B.setMinutes(0);B.setSeconds(0);B.setMilliseconds(0);return B},_getLastDayOfMonth:function(C){if(!(C instanceof Date)){return null}var D=C.getMonth(),B=new C.constructor(C);for(var E=28;E<=31;E++){B.setDate(E+1);if(B.getMonth()!=D){return E}}return null},_constructMonthDiv:function(T,X){var H=this.element,a=this.options,R=this;var V=A("<div />").addClass("month");var W=R._getDay(T);var Y="<h3>"+a.monthLabels[parseInt(T.getMonth())]+"</h3>";Y+=a.daysPlate;Y+="<ul>";var G=null;var F=T.getFullYear(),M=T.getMonth()+1;var P=false,O=false,J=false;if(a.minDate){var K=R._strToDate(a.minDate),C=K.getFullYear(),D=K.getMonth()+1;if(C==F&&D==M){P=true;var N=K.getDate()}else{if(C>F||(C==F&&D>M)){J=true}}}if(a.maxDate){var S=R._strToDate(a.maxDate),B=S.getFullYear(),Z=S.getMonth()+1;if(B==F&&Z==M){O=true;var U=S.getDate()}else{if(B<F||(B==F&&Z<M)){J=true}}}if((X instanceof Date)&&((X.getMonth()+1)==M)&&(X.getFullYear()==F)){G=parseInt(X.getDate(),10)}var I=new Date();var L=null;if((I.getFullYear()==F)&&((I.getMonth()+1)==M)){L=I.getDate()}var S=parseInt(R._getLastDayOfMonth(T))+W;for(var E=0;E<S;E++){var Q=((E-W)<0)?"":(1+E-W);_class="_c ";if(Q===G){_class+=a.activeDateClass}else{if(Q===L){_class+=a.todayClass}else{if(Q===""||J||(P&&parseInt(Q,10)<N)||(O&&parseInt(Q,10)>U)){_class+=a.disabledClass}}}Y+="<li";Y+=' class="'+_class+'"';Y+=(Q!="")?' date="'+F+"-"+M+"-"+Q+'"':"";Y+=">";Y+=Q;Y+="</li>"}Y+="</ul>";V.html(Y);return V},_fillContent:function(M,L,D){var I=this.element,B=this.options,K=this;var H=I.find("div.month");var E=[];for(var G=0;G<B.monthSimultaneously;G++){var F=new Date(M.getFullYear(),M.getMonth(),1,0,0,0,0);F.setMonth(F.getMonth()+G);var J=K._constructMonthDiv(F,L);J.attr("month",F.getMonth()+1);J.hide();E.push(J);I.append(J)}if(B.animation&&typeof (D)!="undefined"){var C=-50;if(D<0){C*=-1}H.eq(0).animate({marginLeft:C+"px"},100,"linear",function(){H.remove();I.find("div.month").fadeIn()})}else{H.remove();I.find("div.month").show()}var F=new Date(M.getFullYear(),M.getMonth(),1,0,0,0,0);if(F<this._strToDate(this.options.minDate)){A(".prev",this.element).addClass("disabled")}else{A(".prev",this.element).removeClass("disabled")}K._redrawSelected();if(typeof (B.onDisplay)=="function"){B.onDisplay.call(K)}},_selectMonth:function(B){this.options._active_date.setMonth(this.options._active_date.getMonth()+B);this._fillContent(this.options._active_date,this.options._current_date,B)},_redrawSelected:function(){if(!this.options.parityDate){return }var U=this.options._current_date,M=this.options.parityDate,N=null,G=null,I=new Date(),K=this.element.find(".month").find("li[date]"),J=0,R=0,F="",E="",S=this.element.find(".month"),C=S.eq(0),B=S.eq(1);K.removeClass(this.options.intermediateClass);K.removeClass(this.options.parityDateClass);K.removeClass(this.options.activeDateClass);if(U<M){N=U;G=M;F=this.options.activeDateClass;E=this.options.parityDateClass}else{if(U>=M){N=M;G=U;F=this.options.parityDateClass;E=this.options.activeDateClass}}var P=false;S.each(function(W,X){var V=A(X).attr("month")-1;P=P||N.getMonth()<=V||G.getMonth()>=V});if(!P){return }var Q=true,O=true;if(N.getMonth()<(C.attr("month")-1)){N=new N.constructor(N);N.setMonth(C.attr("month")-1);N.setDate(1);Q=false}if(G.getMonth()>(B.attr("month")-1)){G=new G.constructor(G);G.setMonth(B.attr("month")-1);G.setDate(this._getLastDayOfMonth(G));O=false}var T=N.getFullYear()+"-"+(N.getMonth()+1)+"-"+N.getDate(),D=G.getFullYear()+"-"+(G.getMonth()+1)+"-"+G.getDate(),H=K.filter("[date='"+T+"']"),L=K.filter("[date='"+D+"']");J=(G-N)/(1000*24*3600);R=N.getDate()-1;if(J&&H.closest(".month").attr("month")==L.closest(".month").attr("month")&&C.attr("month")!=L.closest(".month").attr("month")){R+=C.find("li[date]").length}if(Q){K.eq(R).addClass(F)}while(J>=0){K.eq(R++).addClass(this.options.intermediateClass);J--}if(O){K.eq(R-1).addClass(E)}},_create:function(){var B=this.element,D=this.options,E=this;this.options._current_date=E._strToDate(D.currentDate);if(D.parityDate&&!(D.parityDate instanceof Date)){D.parityDate=E._strToDate(D.parityDate)}var C=A('<a href="#" class="prev"/>');var F=A('<a href="#" class="next"/>');B.addClass(D.calendarClass).append(C).append(F);this.options._active_date=new Date(this.options._current_date.getFullYear(),this.options._current_date.getMonth(),this.options._current_date.getDate(),0,0,0);F.click(function(G){G.preventDefault();G.stopPropagation();if(A(this).hasClass("disabled")){return }E._selectMonth(E.options.monthScrollerDiff)});C.click(function(G){G.preventDefault();G.stopPropagation();if(A(this).hasClass("disabled")){return }E._selectMonth(-1*E.options.monthScrollerDiff)});this.goNextMonth=function(){E._selectMonth(1)};this.goPrevMonth=function(){E._selectMonth(-1)};this.options.onSelectStack=[];if(typeof (D.onSelect)=="function"){this.options.onSelectStack.push(D.onSelect)}B.click(function(G){var J=A(G.target);if(!J.filter("li:not(."+D.disabledClass+")").length){return }if(D.readOnly){return }var H=E._strToDate(J.attr("date"));E.options._current_date=H;A("li."+D.activeDateClass,B).removeClass(D.activeDateClass);J.addClass(D.activeDateClass);if(E.options.onSelectStack.length){for(var I=0;I<E.options.onSelectStack.length;I++){E.options.onSelectStack[I].call(J,H)}}E.redraw()});E._fillContent(E.options._active_date,E.options._current_date)},setMinDate:function(B){this.options.minDate=B;var D=this._strToDate(B);if(D instanceof Date&&D>this.options._current_date){this.options._active_date=this.options._current_date=D;if(this.options.onSelectStack.length){for(var C=0;C<this.options.onSelectStack.length;C++){this.options.onSelectStack[C].call(this.element,this.options._current_date)}}}this._fillContent(this.options._active_date,this.options._current_date)},setMaxDate:function(B){this.options.maxDate=B;var D=this._strToDate(B);if(D instanceof Date&&D<this.options._current_date){this.options._active_date=this.options._current_date=new Date(D.getFullYear(),D.getMonth(),D.getDate());if(this.options.onSelectStack.length){for(var C=0;C<this.options.onSelectStack.length;C++){this.options.onSelectStack[C].call(this.element,this.options._current_date)}}}this._fillContent(this.options._active_date,this.options._current_date)},moveDateUp:function(B){B=this._strToDate(B);if(B instanceof Date&&B>this.options._current_date){this.options._active_date=this.options._current_date=new Date(B.getFullYear(),B.getMonth(),B.getDate());if(this.options.onSelectStack.length){for(var C=0;C<this.options.onSelectStack.length;C++){this.options.onSelectStack[C].call(this.element,this.options._current_date)}}}this._fillContent(this.options._active_date,this.options._current_date)},moveDateDown:function(B){B=this._strToDate(B);if(B instanceof Date&&B<this.options._current_date){this.options._active_date=this.options._current_date=new Date(B.getFullYear(),B.getMonth(),B.getDate());if(this.options.onSelectStack.length){for(var C=0;C<this.options.onSelectStack.length;C++){this.options.onSelectStack[C].call(this.element,this.options._current_date)}}}this._fillContent(this.options._active_date,this.options._current_date)},setDate:function(B){B=this._strToDate(B);this.options._active_date=this.options._current_date=new Date(B.getFullYear(),B.getMonth(),B.getDate());if(this.options.onSelectStack.length){for(var C=0;C<this.options.onSelectStack.length;C++){this.options.onSelectStack[C].call(this.element,this.options._current_date)}}this._fillContent(this.options._active_date,this.options._current_date)},setParityDate:function(B){this.options.parityDate=this._strToDate(B)},addEventOnSelect:function(B){if(typeof (B)=="function"){this.options.onSelectStack.push(B)}},redraw:function(){this.options._active_date=new Date(this.options._current_date.getFullYear(),this.options._current_date.getMonth(),this.options._current_date.getDate());this._fillContent(this.options._active_date,this.options._current_date)},goNextMonth:function(){this._selectMonth(1)}})})(jQuery);$.widget("ui.formWidgetCalendar",$.extend({},$.ui.formWidgetCollapsable.prototype,{_calendar:null,_create:function(){var A=this.element,B=this.options,C=this;B.onInternalClick=B.onInternalClick||function(E){C.freeze();if($(E.target).filter("li:not(."+B.disabledClass+"), a.calendar_close, a.calendar_close i").length){C.unfreeze();C._hide()}};B.pretext=B.pretext||"";B.getLabel=B.getLabel||function(E){var H=E.getFullYear(),G=E.getMonth()+1,F=E.getDate();return"<strong>"+B.pretext+F+" "+_monthLabelsShortRp[G-1]+"</strong>"};B.getValue=B.getValue||function(E){var H=E.getFullYear(),G=E.getMonth()+1,F=E.getDate();return(F<10?"0"+F:F)+"."+(G<10?"0"+G:G)+"."+H};$.ui.formWidgetCollapsable.prototype._create.apply(this,arguments);B.disabledClass=B.disabledClass||"none";B.todayClass=B.todayClass||"current_date";B.intermediateClass=B.intermediateClass||"selected_dates";this.value(B.currentDate);var D={onSelect:function(E){C.value(E)},currentDate:C.value(),minDate:B.minDate,maxDate:B.maxDate,disabledClass:B.disabledClass,todayClass:B.todayClass,activeDateClass:B.activeDateClass,parityDateClass:B.parityDateClass,intermediateClass:B.intermediateClass,parityDate:B.parityDate||C.value(),daysPlate:'<span>Пн</span><span>Вт</span><span>Ср</span><span>Чт</span><span>Пт</span><span class="day_off">Сб</span><span class="day_off">Вс</span>'};this._calendar=$("div.calendar",B.getParent.call(C)).calendar(D)},value:function(B){var A=this.options;if(B){if(typeof B=="string"){B=B.split(".");B=new Date(B[2],B[1]-1,B[0])}$.ui.formWidgetCollapsable.prototype.value.call(this,A.getValue(B));A.setLabel(A.getLabel.call(this,B));return this.element}return this._value},moveDateDown:function(A){this._calendar.calendar("setParityDate",A).calendar("moveDateDown",A)},moveDateUp:function(A){this._calendar.calendar("setParityDate",A).calendar("moveDateUp",A)}}));(function(A){A.widget("ui.tourForm",{selectCity:function(B){A(B).tourSelectList("accept",this.getParamValue("city"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.city.options,value:this.getParamValue("city")})},selectRoom:function(B){A(B).tourSelectList("accept",this.getParamValue("room"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.room.options,value:this.getParamValue("room")})},getValue:function(){var B=this;var C={};A(this.controls).each(function(){var E=A(this).data("getValue")?A(this).data("getValue")():A(this).val();var D=this.getAttribute("data-name");if(D!="hotels"&&!A(this).hasClass("preset")){if(A(this).is(":hidden")){return }}if(!D){return }C[D]=E});return C},serialize:function(F){var E=this.getValue();var D=[];for(var C in E){var G=E[C];if(G===true){G="1"}else{if(G===false){G=""}}if(A.isArray(G)){D.push(C+"="+G.join(","))}else{if(typeof G=="object"){for(var B in G){D.push(B+"="+G[B])}}else{G+="";if(G.charAt(G.length-1)=="_"){G=G.substr(0,G.length-1)}D.push(C+"="+G)}}}return D.join("&")},selectResort:function(D){var C=this;function B(G){G+="";if(G.charAt(G.length-1)=="_"){G=G.substr(0,G.length-1)}return G}function E(J){var I=C.formData._countryResortMap[J];var H={};for(var G=0;G<I.length;G++){H["_"+I[G]]=C.formData._allResorts[I[G]]}return H}var F={template:"tourCheckList",opts:E(B(A("#select-country").val())),value:this.getParamValue("resort",true)};if(this.option("mini")){F.mini=true;F._allResortsVpad=this.formData._allResortsVpad}A(D).resortCheckList("accept",this.getParamValue("resort",true));A(D).resortCheckList(F);A("#select-country").bind("select",function(H,G){A(D).resortCheckList("setOpts",E(B(G))).resortCheckList("setValue",[])});A("#select-hotel").bind("select",function(){if(A(this).val().length){A(D).val([])}})},selectCountry:function(B){A(B).tourSelectList("accept",this.getParamValue("country"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.country.options,optGroups:this.formData.country.optGroups,value:this.getParamValue("country")})},selectDurationFrom:function(B){A(B).tourSelectList("accept",this.getParamValue("durationFrom"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.durationFrom.options,value:this.getParamValue("durationFrom")})},selectDurationTo:function(D){var E=A(D),C=A("#select-durationFrom");A(D).tourSelectList("accept",this.getParamValue("durationTo"));A(D).tourSelectList({template:"tourSelectList",opts:this.formData.durationTo.options,value:this.getParamValue("durationTo")});var B=this;C.bind("select",function(){if(+C.val()>+E.val()){E.val(C.val())}});E.bind("select",function(){if(+C.val()>+E.val()){C.val(E.val())}})},selectStars:function(B){A(B).tourSelectList("accept",this.getParamValue("stars"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.stars.options,value:this.getParamValue("stars")})},roomSize1Child:function(B){function C(D){switch(D){case"4":case"6":case"8":A(B).show();break;default:A(B).hide()}}A("#select-room").bind("select",function(E,D){C(D)});C(A("#select-room").data("getValue")())},getPeopleNum:function(){return this.formData.room.peopleCounts[A("#select-room").val()]},selectPriceType:function(G){var D=this;var C=A("#hotel-select-costs");var F=this.getParamValue("priceType")||"all";A("#price-people-all").attr("checked",F=="all");A("#price-people-person").attr("checked",F=="person");function B(){if(A("#price-people-all").attr("checked")){return"all"}else{return"person"}}A(G).data("getValue",B);function E(){if(A("#select-room").val()==2){A(G).hide()}else{A(G).show()}}A("#select-room").bind("select",E);E();A("#price-people-all,#price-people-person").click(function(){if(B()==F){return }var I=D.getPeopleNum();if(B()=="person"){var J=Math.floor(C.tourCosts("getFrom")/I);var H=Math.floor(C.tourCosts("getTo")/I);C.tourCosts("setFrom",J);C.tourCosts("setTo",H)}else{C.tourCosts("setFrom",C.tourCosts("getFrom")*I);C.tourCosts("setTo",C.tourCosts("getTo")*I)}F=B()})},hotelSelectCosts:function(D){var B=+this.getParamValue("priceFrom"),C=+this.getParamValue("priceTo");A(D).tourCosts({template:"tourCosts",priceFrom:B,priceTo:C});if(B>0||C>0){A(D).tourCosts("open")}},roomSize2Children:function(B){function C(D){switch(D){case"5":case"7":case"10":A(B).show();break;default:A(B).hide()}}A("#select-room").bind("select",function(E,D){C(D)});C(A("#select-room").data("getValue")())},selectRoom1Child1:function(B){A(B).tourSelectAge("accept",this.getParamValue("child1"));A(B).tourSelectAge({template:"tourSelectList",opts:this.formData.child1.options,value:this.getParamValue("child1")})},selectRoom2Child1:function(B){A(B).tourSelectAge("accept",this.getParamValue("child1"));A(B).tourSelectAge({template:"tourSelectList",opts:this.formData.child1.options,value:this.getParamValue("child1")})},selectRoom2Child2:function(B){A(B).tourSelectAge("accept",this.getParamValue("child2"));A(B).tourSelectAge({template:"tourSelectList",opts:this.formData.child2.options,value:this.getParamValue("child2")})},selectBestHotelsNum:function(B){A(B).tourSelectList("accept",this.getParamValue("bestHotelsNum"));A(B).tourSelectList({template:"tourSelectList",opts:this.formData.bestHotelsNum.options,value:this.getParamValue("bestHotelsNum")})},onlyBestHotelsCheckbox:function(B){function C(D){if(D){A("#you-are-searching-best-hotels").show();A("#selected-resort-list").addClass("extend-select-second")}else{A("#you-are-searching-best-hotels").hide();A("#selected-resort-list").removeClass("extend-select-second")}}B.checked=!!this.getParamValue("bestHotels");C(B.checked);A(B).bind("select",function(){C(this.checked)});A(B).click(function(){A(this).trigger("select",this.checked?"1":"")});A(B).data("getValue",function(){return B.checked?"1":""});A("#select-hotel").bind("select",function(){if(A(this).val()&&A(this).val().length){B.checked=false;C(B.checked)}})},youAreSearchingBestHotels:function(B){A("#cancel-search-best-hotels-lnk").click(function(C){A("#only-best-hotels-checkbox").attr("checked","").trigger("select");C.preventDefault()})},hotelClassAndBetterCheckbox:function(B){function C(D){if(+D&&D!=4&&D!=5&&D!=6){A(B).show()}else{A(B).hide()}}A("#select-stars").bind("select",function(E,D){C(D)});C(A("#select-stars").val());A("input",B).attr("checked",this.getParamValue("starsBetter"));A(B).data("getValue",function(){return A("input",B).attr("checked")})},hotelMealsAndBetterCheckbox:function(B){function C(D){if(+D&&D!=6){A(B).show()}else{A(B).hide()}}A("#select-meals").bind("select",function(E,D){C(D)});C(A("#select-meals").val());A("input",B).attr("checked",this.getParamValue("mealsBetter"));A(B).data("getValue",function(){return A("input",B).attr("checked")})},selectMeals:function(C){A(C).tourMeals("accept",this.getParamValue("meals"));A(C).tourMeals({template:"tourMeals",opts:this.formData.meals.options,value:this.getParamValue("meals"),tooltips:this.formData.meals.tooltips});var B=this;A("#select-country").bind("select",function(G,F){F=parseInt(F);var D=A(C).val();if(D){if(!B.formData._mealActuality[F]||!B.formData._mealActuality[F][D]){A(C).val(0)}}var H="<span> (В этой стране этот тип питания не встречается)</span>";for(var E in B.formData.meals.tooltips){if(E==0){continue}if(!B.formData._mealActuality[F]||!B.formData._mealActuality[F][E]){A(C).tourMeals("updateTooltip",E,B.formData.meals.tooltips[E]+H)}else{A(C).tourMeals("updateTooltip",E,B.formData.meals.tooltips[E])}}})},parseDate:function(D){if(D instanceof Date){return D}if(typeof (D)!="string"){return null}var C=D.split(/\./g);var B=new Date(C[2],C[1]-1,C[0]);if(!B||!B.getTime||!B.getTime()){return false}return B},_selectDepartureShowBubble:function(E){var C=A("#bubble-error-departure"),F=A("#bubble-error-departure-tail");F.removeClass("tail-bl").removeClass("tail-br");if(E=="from"){F.addClass("tail-bl")}if(E=="to"){F.addClass("tail-br")}C.fadeIn();var B;var D=function(){C.fadeOut();A(document.body).unbind("click",D);try{clearTimeout(B)}catch(G){}};B=setTimeout(D,4000);setTimeout(function(){A(document.body).click(D)},0)},selectDeparture:function(F){var N=this;var D=new Date(),M=new Date();M.setFullYear(M.getFullYear()+1);D=new Date(D.getFullYear(),D.getMonth(),D.getDate());M=new Date(M.getFullYear(),M.getMonth(),M.getDate(),23,59,59);function E(O){return sprintf("%02d.%02d.%04d",O.getDate(),O.getMonth()+1,O.getFullYear())}var C=this.parseDate(this.getParamValue("departureFrom")),B=this.parseDate(this.getParamValue("departureTo"));if(!C||C<D){C=this.parseDate(this.selectedData.departureFrom)}if(!B||B<D){B=this.parseDate(this.selectedData.departureTo)}if(C>M){C=this.max_date}if(B>M){B=this.max_date}A(F).tourCalendar("accept",C);A(F).tourCalendar("accept",B);var J=A("#select-departure-from").tourCalendar({value:C,minDate:D,maxDate:M,neighbourId:"select-departure-to",calendarId:"calendar-departure-from",template:"tourCalendar"}),I=A("#select-departure-to").tourCalendar({value:B,minDate:D,maxDate:M,neighbourId:"select-departure-from",calendarId:"calendar-departure-to",template:"tourCalendar"});function K(){return J.val()}function L(){return I.val()}A(F).data("getValue",function(){var O={};O[J.attr("data-name")]=E(K());if(I.length){O[I.attr("data-name")]=E(L())}return O});if(I.length){function H(){if(K()>L()){I.val(K())}if(L().getTime()-K().getTime()>30*86400000){I.val(new Date(K().getTime()+30*86400000));N._selectDepartureShowBubble("to")}}function G(){if(K()>L()){J.val(L())}if(L().getTime()-K().getTime()>30*86400000){J.val(new Date(L().getTime()-30*86400000));N._selectDepartureShowBubble("from")}}J.bind("select",H);I.bind("select",G);G()}},selectHotel:function(C){var B=this;A(C).tourSelectHotel("accept",this.getParamValue("hotels"));A(C).tourSelectHotel({template:"tourSelectHotel",value:this.getParamValue("hotels"),resortWidget:A("#select-resort"),countryWidget:A("#select-country"),starsWidget:A("#select-stars"),favouriteHotels:this.selectedData.favouriteHotels});function E(F){A(C).tourSelectHotel("clearSelected");F&&F.preventDefault()}A("#select_concrete_hotel_lnk,#select-hotels-link").click(function(F){A(C).tourSelectHotel("open");F.preventDefault()});A("#clear_and_select_concrete_hotel").click(E);function D(){var H=B.selectedData.favouriteHotels&&A(B.selectedData.favouriteHotels).length;A("#search-favorite-hotels-div")[H?"show":"hide"]();var G=A(C).val();if(G.length){var F=_getNumerableStringRu(G.length,"Выбран","Выбрано","Выбрано")+" "+G.length+" "+_getNumerableStringRu(G.length,"отель","отеля","отелей");A("#select-hotels-value").html(F);A("#select-stars-div").hide();A("#search-hotels-div").hide();A("#hotels-selected-div").show()}else{A("#select-stars-div").show();A("#search-hotels-div").show();A("#hotels-selected-div").hide()}}A(C).bind("select",D);D();A("#select-country").bind("select",E);A("#select-resort").bind("select",function(){if(A(this).val().length){E()}})},toursearchFormSubmit:function(C){var B=this;A(C).click(function(){B.element.trigger("submit",this)})},parseSerialized:function(B){return parseSerializedHash(B)},parseHash:function(C){var B=this;if(C.length>5&&C.substr(0,4)=="tsf="){A.ajax({url:"/ajax/convertTourUrl/?hash="+escape(C.substr(4))+"&referer="+escape(document.referrer),success:function(E){window.location.replace("#"+E);window.location.reload()},error:function(F,E,G){alert("Извините, поиск не удался. Пожалуйста, попробуйте поискать ещё раз");window.console&&console.log(G);window.location.hash="";window.location.reload()},dataType:"text",timeout:5000});return false}if(C.substring(0,"/back".length)=="/back"){this.hash={};return true}B.hash=B.parseSerialized(C);if(B.hash.departureFrom&&!B.hash.departureTo){var D=B.hash.departureFrom.split(".");D=new Date(D[2],D[1]-1,D[0]);D.setDate(D.getDate()+7);B.hash.departureTo=D.getDate()+"."+(D.getMonth()+1)+"."+D.getFullYear()}if(B.hash.durationFrom&&!B.hash.durationTo){B.hash.durationTo=+B.hash.durationFrom+7}return true},createPreset:function(B){A(B).presetWidget()},selectedResortList:function(B){A(B).tourResortList({allResorts:this.formData._allResorts,resortCheckList:A("#select-resort"),template:"resortList"})},selectedHotelList:function(B){A(B).tourHotelList({selectHotel:A("#select-hotel"),template:"hotelList"})},getParamValue:function(I,F){var B=false;if(I=="country"){B=true}if(I=="meals"&&this.option("hotel")){B=true}if(I=="resort"||I=="hotels"){B=true}var D=this.selectedData[I],E=this.hash[I],C=this.savedParams[I];if(C!==undefined&&(I=="departureFrom"||I=="departureTo")){var H=this.parseDate(C);var G=new Date();G=new Date(G.getFullYear(),G.getMonth(),G.getDate());if(!H||H<G){B=true}}if(this.hash.city&&(I=="priceFrom"||I=="priceTo"||I=="bestHotels")){B=true}if(E!==undefined){if(F){return E.split(",")}else{return E}}if(!B&&C!==undefined){if(F){return C.split(",")}else{return C}}return D},refresh:function(B){this.selectedData=this.parseHash(B);this._prepareControls()},_create:function(){if(!this.parseHash(this.option("hash"))){this.element.sleep();return }this.formData=this.option("formData");this.selectedData=this.option("selectedData");this.savedParams=this.parseSerialized(window.LAST_SEARCH_PARAMS||"");this._prepareControls()},_prepareControls:function(){function G(J){return J.replace(/(\-\w)/g,function(K){return K.toUpperCase().replace("-","")})}var B=this;var F=["select-city","select-room","room-size-1-child","select-room-1-child1","room-size-2-children","select-room-2-child1","select-room-2-child2","select-country","select-resort","select-price-type","select-departure","select-durationFrom","select-durationTo","select-stars","hotel-class-and-better-checkbox","select-meals","hotel-meals-and-better-checkbox","hotel-select-costs","select-hotel","select-best-hotels-num","only-best-hotels-checkbox","you-are-searching-best-hotels","toursearch-form-submit","selected-resort-list","selected-hotel-list"];this.controls=[];for(var C=0;C<F.length;C++){var I=F[C];var D=document.getElementById(I);if(!D){continue}if(A(D).hasClass("preset")){B.createPreset(D)}else{var H=G(I);try{B[H]&&B[H](D)}catch(E){if(window.console){console.log(H);console.log(E)}}}this.controls.push(D)}}})})(jQuery);(function(A){A.widget("ui.tourResult",{totalNum:4,ratingsHTMLForHotel:function(E){var D=this.ratings[E];if(!D){return false}var C=this.ratingsTpl;for(var B in D){C=C.replace("%"+B+"%",D[B]||"")}C=C.replace("%responds%",D.marks_count+" "+_getNumerableStringRu(D.marks_count,"отзыву","отзывам","отзывам"));return C},displayResultsFunc:function(S){if(!this.results.length){return }var O=this;var F=document.getElementById("tour_results");var P=A("#select-price-type"),T,U;if(A("#result-price-for-all:checked").length){T="all"}else{if(A("#result-price-for-person:checked").length){T="person"}else{if(P.length){T=P.val()}else{T="all"}}}U=T=="all"?1:1/O.peopleNum;var R=0;var C=O.results_template;var E=0;if(!S){O.results.sort(O.sortFunc);if(!O.last_shown_idx){E=O.perpage-1}else{E=O.last_shown_idx}}else{E=O.perpage+O.last_shown_idx}E=Math.min(O.results.length-1,Math.max(O.perpage-1,E));var L=tmpl(O.itemTemplate);var K=[],X;for(R=0;R<=E;R++){X=O.results[R];X.res_price=X.res_price_sngl*U;X.res_price_rur=X.res_price_rur_sngl*U;X.local_mnemo=O.local_mnemo;X.local_mult=O.local_mult;if(X.operator_provider_mnemo){var Q=A("#show-"+X.operator_provider_mnemo);if(Q.length&&!Q[0].checked){continue}}K.push(L(X))}O.last_shown_idx=E;C=C.replace(/%tour_results%/g,K.join("\n"));A(F).html(C);if(O.peopleNum==1){A("#result-price-people-count-form").hide()}else{A("#result-price-people-count-form").show()}A("#more-results-btn").bind("click",function(Y){O.displayResultsFunc(true);return false});A(".raitings").bind({mouseenter:function(){var Z=this.getAttribute("data-slug"),b=this.getAttribute("data-hotel-id");var a=A("#wrapper-"+Z);var Y=O.ratingsHTMLForHotel(b);if(Y!==false){a.html(Y).addClass("active")}},mouseleave:function(Z){var Y=this.getAttribute("data-slug");A("#wrapper-"+Y).removeClass("active").html("")}});A("td.hotel-best").children("a").hover(function(){A(this).siblings("div.hint").show()},function(){A(this).siblings("div.hint").hide()});var N=F.getElementsByTagName("tr");var D=!!this.option("hotelResult");for(R=0;R<N.length;R++){if(R%2==1){N[R].className+=" odd"}}if(D&&N.length){N[0].className+=" first";N[N.length-1].className+=" last"}A(".hotel_link").click(function(){this.href+="#/back/http://"+window.location.host+window.location.pathname+"#"+A.hash()});if(F.style.display!="block"){F.style.display="block"}var M=document.getElementById("tour-results-sort");var J=M.getElementsByTagName("dd");for(R=0;R<J.length;R++){var W=J[R],G=A(W);G.removeClass("active");if(W.getAttribute("data-order")==O.curr_sort){G.addClass("active");A(W.firstChild).bind("click",function(){return false})}else{A(W.firstChild).bind("click",function(Y){O.curr_sort=this.parentNode.getAttribute("data-order");O.sortFunc=O.sortFuncs[O.curr_sort];O.results_displayed=false;setTimeout(function(){O.displayResultsFunc(false)},1);return false})}}var I=document.getElementById("tour-results-perpage");var B=I.getElementsByTagName("dd");for(R=0;R<B.length;R++){var V=B[R],H=A(V);H.removeClass("active");if(V.firstChild.innerHTML==O.perpage){H.addClass("active");A(V.firstChild).bind("click",function(){return false})}else{A(V.firstChild).bind("click",function(Y){O.perpage=parseInt(this.innerHTML);O.results_displayed=false;O.last_shown_idx=0;setTimeout(function(){O.displayResultsFunc(false)},1);return false})}}A("#result-price-for-all").attr("checked",T=="all");A("#result-price-for-person").attr("checked",T=="person");A("#result-price-for-all,#result-price-for-person").click(function(){O.displayResultsFunc(false)});if(A.browser.msie&&A.browser.version<=6){A("#more-results").hide()}else{A("#more-results").css("display",O.results.length>O.last_shown_idx+1?"":"none")}},sortFuncs:{price:function(C,B){if(C.price!=B.price){return C.price-B.price}else{return C.date-B.date}},date:function(C,B){if(C.date!=B.date){return C.date-B.date}else{return C.price-B.price}},hotel_rating:function(C,B){return((C.res_hotel_avg_rating==B.res_hotel_avg_rating)?C.price-B.price:((C.res_hotel_avg_rating>B.res_hotel_avg_rating)?-1:1))}},updateProgress:function(){if(this.in_pause){return }var B=this;var F=document.getElementById("percents");var D=parseInt(F.innerHTML),E=D;D=Math.min(100,Math.max(Math.ceil(B.currNum*100/B.totalNum),D+1));if(D==100){clearInterval(B.updateProgressInterval);B.updateProgressInterval=null}else{if(D-E>1){clearInterval(B.updateProgressInterval);var C=(new Date().getTime()-B.beginDate);var G=Math.floor((B.totalTime-C)/(100-D));B.updateProgressInterval=setInterval(A.proxy(B,"updateProgress"),G)}}B.actualPercent=D},smoothTransitionFunc:function(B){return(1-Math.cos(B/Math.PI))/2},updateProgressAnimation:function(){if(this.in_pause){return }var H=document.getElementById("percents"),C=document.getElementById("progress");var D=7.5;var I=5;var F=1/D;if(this.drawnPercent<this.actualPercent){var B=1;var G=this.actualPercent-this.drawnPercent;if(G>10){B=G/10;if(!this.introAnimationStarted){B*=1/D;this.animationMade=B;this.introAnimationStarted=true}else{if(!this.introAnimationComplete){B*=Math.max(F,this.smoothTransitionFunc(this.animationMade/I));this.animationMade+=B;if(this.animationMade>=I){this.introAnimationComplete=true}}}}else{this.introAnimationStarted=false;this.introAnimationComplete=false}if(G<I){B=Math.max(F,this.smoothTransitionFunc(G/I))}var E=Math.min(100,this.drawnPercent+B,this.actualPercent);C.style.width=(60+Math.floor(E*D))+"px";H.innerHTML=Math.floor(E);this.drawnPercent=E;if(E==100&&!this.skip_final_animation){A("#search_progress").fadeOut(function(){A("#search_result_hint").fadeIn()})}}},isInvalidHash:function(){if(A.hash().length>0&&A.hash().length<10){return true}if(A.hash().substr(0,4)=="tsf="){return true}return false},hidden_css:{position:"absolute",top:"-100500px",left:"-100500px",visibility:"hidden"},processPackedItems:function(G){var F=G.keys,E=G.result;for(var D=0;D<E.length;D++){var C={};for(var B=0;B<F.length;B++){C[F[B]]=E[D][B]}this.results.push(C)}if(this.results_displayed&&this.results.length>this.last_shown_idx+1){A("#more-results").css("display","block")}},performSearchWithVid:function(){var B=this;setUserVid(function(){B.performSearch()})},performSearch:function(){var B=this;if(this.isInvalidHash()){return }this._setHash();try{B.iframe&&A(B.iframe).remove()}catch(H){}var D=document.createElement("iframe");A(D).css(this.hidden_css);B.results_template="";B.results=[];var F=A("#debug-results");if(F.length){F.show();var E={};A("input[type=checkbox]",F).each(function(){E[this.id]=this.checked});if(!B.debugHTML){B.debugHTML=F.html()}else{F.html(B.debugHTML)}A("input[type=checkbox]",F).each(function(){this.checked=E[this.id];A(this).click(function(){B.displayResultsFunc(false)})})}B.results_displayed=false;B.sortFunc=B.sortFuncs.price;B.curr_sort="price";B.perpage=A.browser.msie&&A.browser.version<=7?20:50;B.last_shown_idx=0;A("#pause-or-continue-search").unbind().bind("click",function(){if(B.in_pause){B.continueSearch()}else{B.pauseSearch()}return false});B.paramsId=null;B.local_mnemo="RUR";B.local_mult=1;B.currNum=0;B.beginDate=new Date().getTime();B.totalTime=120000;B.updateProgressInterval=setInterval(A.proxy(B,"updateProgress"),B.totalTime/100);A("#percents").html("0");B.actualPercent=0;B.drawnPercent=-0.0001;B.skip_final_animation=false;B.updateProgressAnimationInterval=setInterval(A.proxy(B,"updateProgressAnimation"),5);B.updateProgressAnimation();A("#search_progress").show();B.pendingDisplayResults=[];B.ratings={};window.tourResultDisplayFunc=function(K,N){if(B.in_pause){B.pendingDisplayResults.push(Array.prototype.slice.call(arguments));return }var J=document.getElementById("tour_results");if(K=="items"){B.processPackedItems(N)}else{if(K=="hotel-ratings"){for(var L in N){B.ratings[L]=N[L]}}else{if(K=="show"){B.currNum++;B.updateProgress();if(N){var Q=A("#"+N.operator_name+"-wait");Q.removeClass("waitmsg").html(N.time+" сек ("+N.results+" рез-тов)");A("#"+N.operator_name+"-inp").val(N.url);var O=[];if(N.original_operators){O=[];for(var I in N.original_operators){O.push('<a href="/system/operatorInfo/'+I+'/" target="_blank" onclick="window.open(this.href, &quot;operator_info&quot;, &quot;height=320,width=480&quot;); return false;">'+N.original_operators[I]+"</a>")}A("#"+N.operator_name+"-original-operators").html(O.join(", "))}if(N.operators){O=[];for(var I in N.operators){O.push(N.operators[I]+" ("+I+")")}A("#"+N.operator_name+"-operators").html(O.join(", "))}var P=A("#"+N.operator_name+"-error");if(N.error){P.show().html(N.error)}else{P.hide()}}if(B.results.length){B.displayResultsFunc(false)}}else{if(K=="finish"){if(B.results.length){B.displayResultsFunc(false);B.logStats()}else{B.noToursFound()}B.updHistory()}else{if(K=="error"){B.errorOccured()}else{if(K=="result-template"){B.results_template=N}else{if(K=="item-template"){B.itemTemplate=N}else{if(K=="query"){if(unescape(N)!=unescape(B.last_executed_query)){window.location.reload()}}else{if(K=="params-id"){try{clearTimeout(B.paramsWaitTimeout)}catch(M){}B.paramsId=N;A(".params-id").html(B.paramsId)}else{if(K=="hotel-rating-template"){B.ratingsTpl=N}else{if(K=="date"){A("#debug-date").html(Math.floor((new Date().getTime()-new Date(N).getTime())/60000)+" минут назад")}else{if(K=="local-currency"){B.local_mnemo=N.local_mnemo;B.local_mult=N.local_mult}}}}}}}}}}}}};var G=this._formHash();if(this.option("hotelResult")){G+="&hotelResult=true"}G+="&callback=tourResultDisplayFunc";if(this.option("managerHash")){G="bbsessionhash="+this.option("managerHash")+"&"+G}B.last_executed_query=G;B.peopleNum=this.element.tourForm("getPeopleNum");var C=B.option("searchUrl")+"?"+G;D.src=C;B.iframe=D;document.body.appendChild(D);B.paramsWaitTimeout=setTimeout(function(){B.errorOccured()},10000)},errorOccured:function(){var B=this,C=document.getElementById("tour_results");C.style.display="none";B.skip_final_animation=true;B.cancelSearch();A("#tour_unavailable_details")[B.paramsId?"show":"hide"]();document.getElementById("tour_unavailable").style.display="block";A(".params-id").html(B.paramsId);window.tourResultDisplayFunc=function(){}},noToursFound:function(){var M=this;M.skip_final_animation=true;M.cancelSearch();var C=this.element.tourForm("getValue");var L={price:"увеличить цену",region:"добавить больше курортов",dateInterval:"расширить диапазон дат вылета",starsBetter:"поставить галочку «и выше» для класса отеля",mealsBetter:"поставить галочку «и выше» для питания",hotel:"выбрать больше отелей"};var N=[];var J=200;if(C.priceType=="all"){J*=this.element.tourForm("getPeopleNum")}if(C.price&&+C.price.priceTo&&+C.price.priceTo<=J){N.push("price")}if(C.resort&&C.resort.length==1){N.push("region")}var B=C.departure.departureTo.split(/\./g);var E=new Date(B[2],B[1]-1,B[0]);var D=C.departure.departureFrom.split(/\./g);var K=new Date(D[2],D[1]-1,D[0]);if(E.getTime()-K.getTime()<5*86400000){N.push("dateInterval")}if(+C.stars&&!C.starsBetter){N.push("starsBetter")}if(+C.meals&&!C.mealsBetter){N.push("mealsBetter")}if(C.hotels&&C.hotels.length&&!this.option("hotelResult")){N.push("hotel")}if(N.length>3){N=[N[0],N[1],N[2]]}var G="";if(!N.length){G="поменять даты вылета"}else{var I=[];for(var H=0;H<N.length;H++){I.push(L[N[H]]);if(H<N.length-2){I.push(", ")}else{if(H==N.length-2){I.push(" и ")}}}G=I.join("")}document.getElementById("tour-try-to-change").innerHTML=G;document.getElementById("no_tours_found").style.display="block";var F=A("#search_request_btn");if(!F.data("origHref")){F.data("origHref",F.attr("href"))}F.attr("href",F.data("origHref")+"#"+A.hash())},stopSearch:function(){var B=this;B.continueSearch(true);B.currNum=B.totalNum;B.updateProgress();B.drawnPercent=99.9;B.updateProgressAnimation();try{clearTimeout(B.paramsWaitTimeout)}catch(C){}},cancelSearch:function(){var B=this;B.stopSearch();document.getElementById("no_tours_found").style.display="none";document.getElementById("tour_unavailable").style.display="none";A("#tour_results").hide().html("");A("#search_progress").hide();A("#search_result_hint").hide()},pauseSearch:function(){this.in_pause=true;A("#search_progress").addClass("search-progress-paused");A("#pause-or-continue-search").html("продолжить")},continueSearch:function(D){this.in_pause=false;A("#search_progress").removeClass("search-progress-paused");A("#pause-or-continue-search").html("приостановить");if(D!==true){for(var B=0;B<this.pendingDisplayResults.length;B++){var C=this.pendingDisplayResults[B];window.tourResultDisplayFunc(C[0],C[1])}this.pendingDisplayResults=[]}},logStats:function(){var B={},G={};for(var F=0;F<this.results.length;F++){var E=this.results[F];if(E.hotel_id){B[E.hotel_id]=true}G[E.ohotel_id]=true}var H=[],D=[];for(var C in B){H.push(C)}for(var C in G){D.push(C)}A.ajax({url:"/upd_pick_hotel_stat.js?uniq="+Math.random()+"&hotels="+H.join(",")+"&ohotels="+D.join(",")})},updHistory:function(){window.init_search_history&&init_search_history()},firstTime:true,search:function(C){var B=this;if(!C||C=="click"){this.new_hash=this._formHash();this._setHash();if(A.browser.msie&&A.browser.version<=7&&!B.firstTime){window.location.reload()}}if(C=="hash"){if(!this.new_hash||this.new_hash.length&&this.new_hash!=A.hash()){if(A.browser.msie&&A.browser.version<=7){}else{window.location.reload()}}return }if(this.needs_cancelling){B.skip_final_animation=true;this.cancelSearch();B.skip_final_animation=false;this.performSearchWithVid()}else{iewrap(A.proxy(this,"performSearchWithVid"));this.needs_cancelling=true}B.firstTime=false},_formHash:function(){return this.element.tourForm("serialize")},_setHash:function(){var B="#"+this._formHash();if(window.history&&history.replaceState){history.replaceState(null,null,B)}else{window.location.replace(B)}},shouldSearch:function(){var B=A.hash();if(!B.length||this.isInvalidHash()){return false}if(B.indexOf("action=set-default")>-1){return false}return true},_create:function(){var B=this;this.element.bind("submit",function(){B.search("click")});A(document).bind("hashchange",function(){B.search("hash")})}})})(jQuery);(function(A){A.widget("ui.tourResultSubmitter",{search:function(){var B=this.element.tourForm("serialize");var C=this.option("toursUrl")+"#"+B;if(A.browser.msie&&A.browser.version<=7){setTimeout(function(){window.location.href=C},100)}else{window.location.href=C}},_create:function(){this.searchFunc=A.proxy(this,"search");this.element.bind("submit",this.searchFunc)},_destroy:function(){this.element.unbind("submit",this.searchFunc)}})})(jQuery);(function(A){A.widget("ui.tourFormSwitcher",{_create:function(){this.params=this.option("params");this.additional_params=this.option("additional_params");this.beforeInit=this.option("beforeInit");this.first=this.option("first");this.second=this.option("second");this.firstInit=true;this.current=this.second;this["switch"](true)},"switch":function(E){var D=this;this.current=this.first==this.current?this.second:this.first;var C=A("#toursearch-form-short-div");var B=function(){D.firstInit=false;C.tourForm("destroy");C.html(WIDGET_TEMPLATES[D.current].base);A("#select-hotel").tourSelectHotel("destroy");D.beforeInit();var F=A.extend(D.params,D.additional_params[D.current]);C.tourForm(F).tourResultSubmitter({toursUrl:D.option("submit_url")});A("#toggle-form").click(function(){D["switch"]();return false});if(!E){A(this).slideDown(function(){A(this).css("zoom","1")})}};if(!D.firstInit){D.params.hash=C.tourForm("serialize")}if(!E){C.slideUp(B)}else{B()}},formData:function(){return this.params.formData}})})(jQuery);(function(A){A.widget("ui.newCalendar",A.ui.tourWidget,{monthLabels:["","Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],dayLabels:["Пн","Вт","Ср","Чт","Пт","Сб","Вс"],_create:function(){this.readTemplate(this.option("template")||"newCalendar");this.element.data("getValue",A.proxy(this,"getValue"));this.element.data("setValue",A.proxy(this,"setValue"));this.value=this.option("value");this.otherDate=null;var C=this.option("minDate"),D=this.option("maxDate"),B=this.value;this.option("minDate",new Date(C.getFullYear(),C.getMonth(),C.getDate()));this.option("maxDate",new Date(D.getFullYear(),D.getMonth(),D.getDate()));this.value=new Date(B.getFullYear(),B.getMonth(),B.getDate());if(!this.option("noAutoHide")){this.setHideIfClickOutside(true)}},setOtherDate:function(B){this.otherDate=new Date(B.getFullYear(),B.getMonth(),B.getDate());this.renderContainer()},renderContainer:function(){var R=this;this.$container=this.element;var I=this.option("minDate"),L=this.option("maxDate");var D=this.value.getMonth(),E=this.value.getFullYear();this.$container.html(this.template.body);if(!this.currMonth){this.currMonth=(D==I.getMonth()&&E==I.getFullYear())?this.value.getMonth()+1:this.value.getMonth();this.currYear=this.value.getFullYear()}var C=this.currMonth+1,b=this.currYear;if(C>12){C-=12;b++}var K=new Date(new Date(b,C-1,1).getTime()-86400000).getDate();var a=C+1,F=b;if(a>12){a-=12;F++}var V=new Date(new Date(F,a-1,1).getTime()-86400000).getDate();var X={left:{year:this.currMonth==0?this.currYear-1:this.currYear,month:this.currMonth==0?12:this.currMonth,lastDate:K},right:{year:b,month:C,lastDate:V}};var B=0;for(var T in {left:true,right:true}){var M=X[T].year,Z=X[T].month,N=X[T].lastDate;var J=new Date(M,Z-1,1).getDay();if(J==0){J=6}else{J-=1}var S=[];for(var U=1-J;U<=N;U++){var W=false,Q="";if(U>0){Q=new Date(M,Z-1,U);if(Q<I||Q>L){W=true}}var G=Q.getTime?Q.getTime():0;var H=this.value.getTime();var O=this.otherDate?this.otherDate.getTime():H;var P;if(W){P="none fake "+T}else{if(H==G){P="current_date"}else{if((H<O&&H<G&&O>=G)||(H>O&&H>G&&O<=G)){P="scope"}else{if(U>0){P=""}else{P="none"}}}}var Y=this.template.date_el.replace("%n%",U>0?U:"").replace("%add_classes%",P).replace("%value%",Q.toString());S.push(Y)}A(".widget_dates",this.$container).eq(B).html(S.join("")).delegate("li","click",function(){if(A(this).hasClass("none")){return }R.value=new Date(A(this).attr("data-value"));R.element.trigger("select");R.close()});A(".widget_month_name",this.$container).eq(B).html(this.template.date_title.replace("%month%",this.monthLabels[Z]).replace("%year%",M));B++}A(".prev",this.$container).click(function(c){R.prevMonth();return false});A(".next",this.$container).click(function(c){R.nextMonth();return false});this.disableButtons()},setValue:function(B){this.value=B;this.currMonth=null;this.renderContainer()},canPrev:function(){return this.currYear*12+this.currMonth>this.option("minDate").getFullYear()*12+this.option("minDate").getMonth()+1},canNext:function(){return this.currYear*12+this.currMonth+1<this.option("maxDate").getFullYear()*12+this.option("maxDate").getMonth()+1},nextMonth:function(){if(!this.canNext()){return }this.currMonth++;if(this.currMonth>12){this.currMonth-=12;this.currYear++}this.renderContainer()},prevMonth:function(){if(!this.canPrev()){return }this.currMonth--;if(this.currMonth<1){this.currMonth+=12;this.currYear--}this.renderContainer()},disableButtons:function(){var C=this.canPrev();A(".prev",this.$container)[C?"removeClass":"addClass"]("disabled");var B=this.canNext();A(".next",this.$container)[B?"removeClass":"addClass"]("disabled")}})})(jQuery);(function(A){A.widget("ui.tourCalendar",A.ui.tourWidget,{monthLabels:["","января","февраля","марта","апреля","мая","июня","июля","августа","сентября","октября","ноября","декабря"],dayLabels:["","воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],_create:function(){A.ui.tourWidget.prototype._create.apply(this,arguments);if(this.option("neighbourId")){this.$neighbour=A("#"+this.option("neighbourId"))}else{this.$neighbour=null}this.setValue(this.option("value"))},setValue:function(C){var D=C;if(!D instanceof Date){var B=D.split(/\./g);D=new Date(B[2],B[1]-1,B[0])}this.value=D;this.renderResultValue();this.element.trigger("select");if(this.$container){this.$container.val(C)}},getValueAsText:function(){var B=this.value;return B.getDate()+" "+this.monthLabels[B.getMonth()+1]},getDayValueAsText:function(){var B=this.value;return this.dayLabels[B.getDay()+1]},renderResultValue:function(){this.$result.html(this.template.text.replace("%title%",this.getValueAsText(this.value)).replace("%day%",this.getDayValueAsText(this.value)));if(this.value.getDay()==0||this.value.getDay()==6){this.$result.addClass("cal-weekend")}else{this.$result.removeClass("cal-weekend")}},open:function(){A.ui.tourWidget.prototype.open.apply(this,arguments);if(this.$neighbour&&this.$neighbour.length){this.$container.newCalendar("setOtherDate",this.$neighbour.val())}this.$container.newCalendar("open")},close:function(){A.ui.tourWidget.prototype.close.apply(this,arguments);this.$container.newCalendar("close")},renderContainer:function(){if(this.$container){return }var B=this;this.$container=A("#"+this.option("calendarId"));var C=this.$container;C.newCalendar({value:this.value,minDate:this.option("minDate")||(new Date()),maxDate:this.option("maxDate")||(new Date(new Date().getMilliseconds()+365*86400000)),noAutoHide:true,template:"calendar"}).bind("select",function(){B.setValue(C.val());B.close()})}})})(jQuery);(function(A){A.widget("ui.historySelectList",A.ui.tourListWidget,{_create:function(){A.ui.tourListWidget.prototype._create.apply(this,arguments);this.dataSource=this.option("dataSource");this.bodyTemplate=this.option("bodyTemplate")||"body";this.checkEmpty()},open:function(){if(!this.empty){A.ui.tourListWidget.prototype.open.apply(this)}},renderResultValue:function(){this.$result.html(this.element.children(".item"))},renderContainerItem:function(B){},renderContainer:function(){if(this.$container){this.$container.remove()}this.$container=A("<ul/>").addClass("ui-popup-body").appendTo(this.element);var C=this.prepareOpts();var D=this.template[this.bodyTemplate]||this.template.body;var B=D.replace("%options%",C.join("\n"));this.$container.html(B);this.bindContainerHandlers()},prepareOpts:function(){var B=[];for(var C=0;C<this.optsOrder.length;C++){var D=this.optsOrder[C];if(this.optGroups[D]){B.push(this.template.optGroup.replace("%title%",this.optGroups[D]))}B.push(this.renderContainerItem(C))}return B},bindContainerHandlers:function(){this.$container.delegate("li","click",A.proxy(this,"onItemClick"))},onItemClick:function(B){if(A(B.currentTarget).hasClass("selectable")){this.close()}},setValue:function(B){this.renderResultValue();this.element.trigger("select")},renderHistoryTime:function(D){var G=["янв.","фев.","марта","апр.","мая","июня","июля","авг.","сен.","окт.","нояб.","дек."];var E=new Date(D*1000);var F=new Date();var C=F.getTime()-E.getTime();var B=new Date(C);if(C<60000){return"только что"}else{if(C<3600000){return sprintf("%s минут%s назад",B.getMinutes(),_getNumerableStringRu(B.getMinutes(),"у","ы",""))}else{if(C<14400000){return sprintf("%s час%s назад",B.getUTCHours(),_getNumerableStringRu(B.getUTCHours(),"","а","ов"))}else{if(F.getDate()-E.getDate()==0){return sprintf("сегодня в %s:%02d",E.getHours(),E.getMinutes())}else{if(F.getDate()-E.getDate()==1){return sprintf("вчера в %s:%02d",E.getHours(),E.getMinutes())}else{return sprintf("%s %s %s в %s:%02d",E.getDate(),G[E.getMonth()],E.getFullYear(),E.getHours(),E.getMinutes())}}}}}},setOpts:function(C,D){this.opts={};this.optsOrder=[];for(var B in C){this.opts[B]=C[B];this.optsOrder.push(B)}this.optGroups=D||{};if(this.$container){this.$container.remove();this.$container=null}},refreshOpts:function(){if(this.dataSource){A.ajax({url:"http://"+this.dataSource,dataType:"jsonp"})}},resetOpts:function(D){this.opts={};this.optsOrder=[];var C=0;for(var B in D){if(D[B].data){C++}this.opts[B]=D[B];this.optsOrder.push(B)}this.checkEmpty()},checkEmpty:function(){this.empty=true;for(var B in this.opts){if(this.opts[B].data){this.empty=false;break}}if(this.empty){this.element.find(".item").addClass("disabled")}else{this.element.find(".item").removeClass("disabled")}}});A.widget("ui.hotelHistorySelectList",A.ui.historySelectList,{prepareOpts:function(){var B=[];var D=null;for(var C=0;C<this.optsOrder.length;C++){var F=this.optsOrder[C];var E=this.opts[F];if(E.data&&E.data.REGION!=D){if(E.data.REGION_URL!=undefined){B.push(this.template.optGroupLinked.replace("%title%",sprintf("%s, %s",E.data.COUNTRY_NAME,E.data.REGION_NAME)).replace("%url%",E.data.REGION_URL))}else{B.push(this.template.optGroup.replace("%title%",sprintf("%s, %s",E.data.COUNTRY_NAME,E.data.REGION_NAME)))}D=E.data.REGION}B.push(this.renderContainerItem(C))}return B},renderContainerItem:function(E){var D=this.optsOrder[E];var B=this.opts[D];if(!B.data){return }var H=B.data.NAME;var F=B.data.STAR;var C=B.data.URL;var G=this.renderHistoryTime(B.time);return this.template.hotelItem.replace("%title%",H).replace("%star%",F).replace("%url%",C).replace("%time%",G)}});A.widget("ui.searchHistorySelectList",A.ui.historySelectList,{renderContainerItem:function(D){var C=this.optsOrder[D];var B=this.opts[C];if(!B.data){return }var F=B.data;var E=this.renderHistoryTime(B.time);return this.template.searchItem.replace("%title%",F).replace("%url%",C).replace("%time%",E)}})})(jQuery)
