(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 g=b(this),f=g.next(".b-head-search"),c=f.find(".b-search .b-input input:first"),h=f.find(".advanced"),k=(h.attr("href")||"").replace(/([?&])text=[^&]*/g,""),m=(function(){var n={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"};n.images=n.www;n.adresa=n.video=n.slovari=n.auto;return n})(),l=b.grep(b.map(g.find(":not(strong)>a.b-head-tabs__link:not([href$=yandex.ru/all])"),function(o){var n=o.host.split(".")[0];return{node:b(o),clid:(b(o).attr("search").match(/[&?]clid=(\d+)/)||[])[1],service:n,url:m[n]}}),function(n){return typeof n.url!="undefined"}),d={www:505,search:521,images:526}[a.params.id]||527,j;setInterval((function(){var n=encodeURIComponent(b.trim(c.val())||e["default"]);if(j===n){return arguments.callee}j=n;if(!!h.length){h.attr("href",k+(!!n?i(k)+"text="+n:""))}b.each(l,function(){var o=!!n?(this.service=="market"?this.url.replace("%clid%",d):this.url)+i(this.url)+"text="+n:this.service=="market"?"?clid="+d+"&cvredirect=1":"",p=this.node[0];p.href=p.protocol+"//"+p.host+"/"+o+((this.clid&&this.service!="market"&&!(this.service=="www"&&!!n))?i(o)+"clid="+this.clid:"")});return arguments.callee})(),200);function i(n){return n.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()+25);c.css("top",c.offset().top-c.height()+25)}c.css("display","");f=false}}else{e()}})}})(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")){d.focus();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-search__sample"]=function(g){var f=b(this),e=f.closest("form"),d=e.find("input[name='"+(g["for"]||"text")+"']"),c;f.find(".b-pseudo-link").click(function(h){d.data("b-suggest",false).focus().attr("value",g.text||b(h.target).text());c=e.find("input[name='nl']");if(g.nl&&!c.length){c=b('<input type="hidden" name="nl" value="1"/>').insertAfter(d)}b(document).trigger("popupsClose.lego");setTimeout(function(){d.removeData("b-suggest")},0);return false})}})(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 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(g){var d;b(".b-head-userinfo__entry .b-pseudo-link").click(function(){c();return false});function c(){if(!d){f()}b(document).bind("keyup.b-auth-domik",function(h){if(h.keyCode==27){e()}}).bind("click.b-auth-domik",function(h){if(b(h.target).parents().andSelf().index(d)==-1||b(h.target).is("input[type=button]")){e()}});window.scrollTo(0,0);d.show().find("input[name=login]").focus();b(document).trigger("show.b-auth-domik_popup")}function e(){b(document).unbind(".b-auth-domik");d.hide()}function f(){var h="&amp;msg="+a.params["passport-msg"]+"&amp;retpath="+encodeURIComponent(a.params.retpath);d=b('<form class="b-auth-domik b-auth-domik_popup" action="'+a.params["passport-host"]+"/passport?mode=auth"+h+'" 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">'+g.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="'+a.params["passport-host"]+"/passport?mode=register"+h+'" tabindex="11">'+(g.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);