(function(b,a){if(!a){a=window.Lego={}}a.messages=a.messages||{};a.message=function(d,c){return a.params.locale=="ru"?c:(a.messages[d]||c)}})(jQuery,window.Lego);(function(b,a){a.block["b-head-tabs"]=function(e){var h=b(this),f=h.next(".b-head-search"),c=f.find(".b-search .b-input input:first"),i=f.find(".advanced"),l=(i.attr("href")||"").replace(/([?&])text=[^&]*/g,""),g=b.map(document.location.search.substr(1).split("&"),function(o){var p=o.split("=");return p[0]=="noreask"?p[1]:""}).join(""),n=(function(){var o={www:"yandsearch",news:"yandsearch?rpt=nnews&grhow=clutop",yaca:"yandsearch?rpt=rs2",market:"search.xml?clid=%clid%&cvredirect=1",blogs:"search.xml?ft=blog",maps:"",auto:"search.xml"};o.images=o.www;o.adresa=o.video=o.slovari=o.auto;g&&b.each(o,function(p){o[p]=o[p]+j(o[p])+"noreask="+g});return o})(),m=b.grep(b.map(h.find(":not(strong)>a.b-head-tabs__link:not([href$=yandex.ru/all])"),function(p){var o=p.host.split(".")[0];return{node:b(p),clid:(b(p).attr("search").match(/[&?]clid=(\d+)/)||[])[1],service:o,url:n[o]}}),function(o){return typeof o.url!="undefined"}),d={www:505,search:521,images:526}[a.params.id]||527,k;setInterval((function(){var o=encodeURIComponent(b.trim(c.val())||e["default"]);if(k===o){return arguments.callee}k=o;if(!!i.length){i.attr("href",l+(!!o?j(l)+"text="+o:""))}b.each(m,function(){var p=!!o?(this.service=="market"?this.url.replace("%clid%",d):this.url)+j(this.url)+"text="+o:this.service=="market"?"?clid="+d+"&cvredirect=1":"",q=this.node[0];q.href=q.protocol+"//"+q.host+"/"+p+((this.clid&&this.service!="market"&&!(this.service=="www"&&!!o))?j(p)+"clid="+this.clid:"")});return arguments.callee})(),200);function j(o){return o.indexOf("?")!=-1?"&":"?"}}})(jQuery,window.Lego);(function(b,a){a.block["b-dropdown"]=function(i){var g=b(this),d=g.find(".b-dropdown__list"),c=b('<div class="b-dropdown__popup"><iframe class="b-dropdown__iframe" frameborder="0" src="javascript:\'<body style=\\\'background:none;overflow:hidden\\\'>\'"></iframe></div>'),h=d.clone(true).addClass("b-dropdown__list_clone").hide(),f=false,e=(function(){if(f){return}c.css("visibility","hidden").before(d).hide();h.hide();f=true});d.before(c);c.after(h);e();b(document).keydown(function(j){if(j.keyCode==27&&!(j.metaKey||j.ctrlKey||j.altKey||j.shiftKey)){e()}}).click(function(j){if(!b(j.target).is(".b-dropdown *")){e()}}).bind("popupsClose.lego",e);b(this).find(".b-dropdown__or").click(function(j){j.preventDefault();if(g.hasClass("b-dropdown_disabled")){g.trigger("popupDisabled.lego");return}if(f){b(document).trigger("popupsClose.lego");var k=b.Event("popupOpen.lego");g.trigger(k);if(!k.isDefaultPrevented()){h.css("display","");c.append(d).css("visibility","");if(i.direction=="up"){h.css("top",h.offset().top-h.height());c.css("top",(b(window).scrollTop()+22)-c.offset().top-c.height())}c.css("display","");f=false}}else{e()}})}})(jQuery,window.Lego);(function(b,a){a.block["b-head-user"]=function(){var c=b(this);if(a.params.login!=""){b.getJSON("//pass.yandex.ru/services?callback=?",{locale:a.params.locale,login:"yes"},function(f){if(!f||!f.services){return}var d=f.login||a.params.login;var e='<div class="g-js b-dropdown" onclick="return {name:\'b-dropdown\'}"><ul class="b-dropdown__list"><li class="b-dropdown__item b-dropdown__visible"><a href="http://i.yandex.ru" class="b-dropdown__or"><span class="b-pseudo-link"><b class="b-user"><b class="b-user__first-letter">'+d.substring(0,1)+"</b>"+d.substring(1)+"</b></span></span></a></li>";b.each(f.services,function(){e+='<li class="b-dropdown__item">';if(a.params.id==this.id&&a.params.index){e+="<strong>"+this.title+"</strong>"}else{e+='<a class="b-dropdown__link"href="'+this.url+'"onmousedown="Lego.ch(\''+a.params.id+".login.myservices."+this.id+"',this)\">"+this.title+"</a>"}e+="</li>"});e+='<li class="b-dropdown__item b-dropdown__line"><a href="//passport.yandex.ru/">'+a.message("b-head-userinfo.user:passport","Паспорт")+"</a></li>";e+='<li class="b-dropdown__item"><a href="//passport.yandex.ru/passport?mode=changepass&retpath=http://i.yandex.ru/">'+a.message("b-head-userinfo.user:change-password","Сменить пароль")+"</a></li>";e+="</ul></div>";c.find(".b-user").replaceWith(e);a.blockInit(c,".b-dropdown")})}}})(jQuery,window.Lego);(function(b,a){a.block["b-hint-input"]=function(){var i=b(this),e=b("#"+i.attr("for")),g=function(){i.hide()},d=function(){i.show()},c=function(){h||e.val()?g():d()},h=false;e.focus(function(){h=true;c()}).blur(function(){h=false;c()}).bind("change mouseover",c);i.click(function(){e.focus()});e.change();var f=e.val();(function(){if(e.val()!=f){b(e).trigger("change");f=e.val()}setTimeout(arguments.callee,200)})()}})(jQuery,window.Lego);(function(b,a){a.block["b-auth"]=function(h){var e=b(this),d=false,f=b('<input type="hidden" name="timestamp"/>');e.append(f).submit(function(){if(d){return false}f.val(new Date().getTime())});var c=e.find("input[name=login], input[name=passwd]"),g=e.find("input[type=submit]");c.change(function(){d=false;c.each(function(){if(!b.trim(b(this).val())){d=true}});g.attr("disabled",d)});c.change()}})(jQuery,window.Lego);(function(b,a){a.block["b-auth-domik_popup"]=function(h){var e=b(this),d;b(".b-head-userinfo__entry .b-pseudo-link").click(function(){c();return false});function c(j){if(!d){g()}var i="&from="+a.params["passport-msg"]+"&retpath="+encodeURIComponent(j||a.params.retpath);d.attr("action",a.params["passport-host"]+"/passport?mode=auth"+i).find(".b-auth-domik__register .b-auth-domik__link").attr("href",a.params["passport-host"]+"/passport?mode="+(h.regMode||"register")+i);b(document).bind("keyup.b-auth-domik",function(k){if(k.keyCode==27){f()}}).bind("click.b-auth-domik",function(k){if(b(k.target).parents().andSelf().index(d)==-1||b(k.target).is("input[type=button]")){f()}});!d.hasClass("b-auth-domik_popup-50-50")&&window.scrollTo(0,0);d.show().find("input[name=login]").focus();b(document).trigger("show.b-auth-domik_popup")}function f(){b(document).unbind(".b-auth-domik");d.hide()}function g(){d=b('<form class="'+e.attr("class").replace("g-hidden","")+'" method="post"><i class="b-auth-domik__roof"></i><table class="b-auth-domik__shadow"><tr><td class="b-auth-domik__shadow__lt">&nbsp;</td><td class="b-auth-domik__shadow__t"></td><td class="b-auth-domik__shadow__rt">&nbsp;</td></tr><tr><td class="b-auth-domik__shadow__l">&nbsp;</td><td class="b-auth-domik__shadow__m"><div class="b-auth-domik__form"><div class="b-auth-domik__title">'+h.title+'</div><div class="b-auth-domik__username"><label for="b-auth-domik_popup-username" class="b-hint-input g-js" onclick="return {name:\'b-hint-input\'}">'+a.message("b-auth:login","логин")+'</label><div class="b-input"><input class="b-input__text" id="b-auth-domik_popup-username" name="login" tabindex="11"/></div></div><div class="b-auth-domik__password"><label for="b-auth-domik_popup-password" class="b-hint-input g-js" onclick="return {name:\'b-hint-input\'}">'+a.message("b-auth:password","пароль")+'</label><div class="b-input"><input class="b-input__text" id="b-auth-domik_popup-password" name="passwd" type="password" tabindex="11"/></div></div><div class="b-auth-domik__permanent"><input class="b-auth-domik__check" id="b-auth-domik_popup-permanent" name="twoweeks" type="checkbox" value="yes" tabindex="11"/><label for="b-auth-domik_popup-permanent">'+a.message("b-auth:permanent","Запомнить меня")+'</label> <span class="b-auth-domik__help">(<a class="b-auth-domik__link" href="http://help.yandex.ru/passport/?id=922493" tabindex="12">'+a.message("b-auth:help","что&nbsp;это")+'</a>)</span></div><div class="b-auth-domik__button"><input class="b-auth-domik__submit" type="submit" value="'+a.message("b-auth:logon","Войти")+'" tabindex="11"/><input class="b-auth-domik__submit" type="button" value="'+a.message("b-auth:cancel","Отмена")+'" tabindex="11"/></div><div class="b-auth-domik__register"><a class="b-auth-domik__link" href="" tabindex="11">'+(h.register||a.message("b-auth:register","Зарегистрироваться"))+'</a></div><div class="b-auth-domik__remember"><a class="b-auth-domik__remind" href="'+a.params["passport-host"]+'/passport?mode=remember" tabindex="11">'+a.message("b-auth:remember","Напомнить пароль")+'</a></div></div></td><td class="b-auth-domik__shadow__r">&nbsp;</td></tr><tr><td class="b-auth-domik__shadow__lb">&nbsp;</td><td class="b-auth-domik__shadow__b"></td><td class="b-auth-domik__shadow__rb">&nbsp;</td></tr></table><iframe class="b-popup-under"></iframe></form>');if(a.block["b-auth"]){a.block["b-auth"].call(d)}b("body").append(d);a.blockInit(d)}arguments.callee.login=c}})(jQuery,window.Lego);(function(b,a){a.block["b-search__input"]=function(c){var d=b(this);if(c.focus||d.data("lego:focused")){if(!d.data("lego:focused")){setTimeout(function(){d.focus()},0);d.data("lego:focused",true)}if(!!window.history.length&&!b.trim(d.val())){d.bind("keydown",function(f){if(f.keyCode==8){return window.history.back()}d.unbind("keydown",arguments.callee)})}d.blur(function(){d.data("lego:focused",false)})}}})(jQuery,window.Lego);(function(b,a){a.block["b-vmenu"]=function(){b(">.item>.switcher>.b-pseudo-link , >.item>.switcher>.switcher-icon",this).click(function(){var c=b(this).parents(".switcher:first");c.toggleClass("switcher-on");c.find("img").attr("alt",c.hasClass("switcher-on")?"-":"+");b(".b-vmenu:first",b(this).parents(".item:first")).toggleClass("g-hidden")})}})(jQuery,window.Lego);(function(b,a){a.block["b-feedback"]=function(){var d=this;var c=b(".b-feedback-form .comment");b(">.question>.b-pseudo-link",this).click(function(){b(".b-feedback-form").toggleClass("g-hidden");c.focus()});b("#feedback").submit(function(){var e=c.val();if(e!=""){b.post("/block/b-feedback/send.xml",b(this).serialize(),function(g){var f=g.getElementsByTagName("send-form-ok");if(f.length>0){d.addClass("b-feedback_ok");c.get(0).value=""}})}return false})}})(jQuery,window.Lego);