var _____WB$wombat$assign$function_____=function(t){return self._wb_wombat&&self._wb_wombat.local_init&&self._wb_wombat.local_init(t)||self[t]};self.__WB_pmw||(self.__WB_pmw=function(t){return this.__WB_source=t,this});{let t=_____WB$wombat$assign$function_____("window"),e=(_____WB$wombat$assign$function_____("self"),_____WB$wombat$assign$function_____("document"));_____WB$wombat$assign$function_____("location"),_____WB$wombat$assign$function_____("top"),_____WB$wombat$assign$function_____("parent"),_____WB$wombat$assign$function_____("frames"),_____WB$wombat$assign$function_____("opener");$(e).ready((function(){if(($("#_lang").change((function(){$(this).parents("form").eq(0).submit()})),$("#prettyLogin").on("hidden",(function(){$(this).find("[type=text]").val(""),$(this).find("[type=password]").val(""),$(this).find(".error_mark").hide(),$(this).find(".error").hide()})),$("#prettyLogin #login_button").click((function(){var t=$(this).parents("form").eq(0),a=t.find("[name=login]").val(),n=t.find("[name=password]").val(),i=t.find("[name=rememberme]").prop("checked"),o=t.find(".error");return o.hide(),i=i?1:0,""==a||""==n?o.show():$.getJSON(estate_folder+"/js/ajax.php?action=ajax_login",{login:a,password:n,rememberme:i},(function(t){"Authorized"==t.response.body?e.location.href=e.location.href:o.show()})),!1})),$("#prettyLogin #confirm_code").click((function(){var t=$(this).parents("form").eq(0),e=t.find("input[name=sms_code]").val(),a=t.find(".error");return a.html(""),$.ajax({type:"post",url:estate_folder+"/js/ajax.php?action=ajax_activate_sms",data:"activation_code="+e,success:function(t){console.log(t),"wrong_sms_code"==t?a.append($("<p>Неверный код активации</p>")).show():($("#prettyLogin").modal("hide"),$("#prettyRegisterOk").modal("show"))}}),!1})),$("#prettyLogin #register_button").click((function(){var t=!1,e=$(this).parents("form").eq(0),a=e.find(".error"),n=e.find(".error_mark");e.find("div.el:has(span.required)");n.hide(),a.text("").hide(),e.find("div.el:has(span.required)").each((function(){var e=$(this).find("input");"checkbox"!=e.attr("type")||e.prop("checked")?"checkbox"!=e.attr("type")&&""==e.val()&&(t=!0,$(this).find(".error_mark").show()):(t=!0,$(this).find(".error_mark").show())}));var i=e.find("input[name=login]").val();if(""!=i){found=i.match(/^([a-zA-Z0-9-_@\.]*)$/i),null===found&&(t=!0,a.append($("<p>Логин может содержать только латинские буквы, цифры, подчеркивание, тире</p>")).show())}var o=e.find("input[name=newpass]").val(),s=e.find("input[name=newpass_retype]").val();o&&s&&""!=o&&""!=s&&o!=s&&(t=!0,a.append($("<p>Пароли не совпадают</p>")).show(),e.find("input[name=newpass]").nextAll(".error_mark").eq(0).show(),e.find("input[name=newpass_retype]").nextAll(".error_mark").eq(0).show());var r=e.find("input[name=email]").val();if(""==r||SitebillCore.isValidEmail(r)||(t=!0,a.append($("<p>Укажите правильный email</p>")).show()),!t){var _=[];e.find("div.el").each((function(){$(this).find("input").each((function(){_.push($(this).attr("name")+"="+$(this).val())})),$(this).find("select").each((function(){_.push($(this).attr("name")+"="+$(this).val())})),$(this).find("textarea").each((function(){_.push($(this).attr("name")+"="+$(this).val())}))})),$.ajax({type:"post",url:estate_folder+"/js/ajax.php?action=ajax_register",data:_.join("&"),success:function(t){"confirm_sms_code"==t?($("#register_1").hide(),$("#confirm_sms_code_block").show(),$("#confirm_sms_code_block").css("display","block")):"ok"!=t?a.append($("<p>"+t+"</p>")).show():($("#prettyLogin").modal("hide"),$("#prettyRegisterOk").modal("show"))}})}return!1})),$("#prettyRegisterOk .let_me_login").click((function(){$("#prettyRegisterOk").modal("hide"),$('#prettyLogin a[href="#profile"]').tab("show"),$("#prettyLogin").modal("show")})),$("#search_forms_tabs").length>0)&&0==$("#search_forms_tabs li.active").length){var a=$("#search_forms_tabs li:first"),n=a.find("a").attr("href").replace("#","");a.addClass("active"),$("#"+n).addClass("active")}var i=$(t).height();$("#prettyLogin .tab-content").css({"max-height":.55*i+"px"}),$(e).on("click","a.fav-add",(function(t){var e=$(this),a=e.attr("alt");a&&$.ajax({url:estate_folder+"/js/ajax.php?action=add_to_favorites",data:"id="+a,type:"POST",dataType:"json",success:function(t){if("OK"==t.response.body){var a=$("#favorites_count");a.length>0&&a.text(new Number($("#favorites_count").text())+1),e.removeClass("fav-add").addClass("fav-rem")}},error:function(t,e,a){}}),t.preventDefaults()})),$(e).on("click","a.fav-rem",(function(t){var e=$(this),a=e.attr("alt");a&&$.ajax({url:estate_folder+"/js/ajax.php?action=remove_from_favorites",data:"id="+a,type:"POST",dataType:"json",success:function(t){if("OK"==t.response.body){var a=$("#favorites_count");a.length>0&&a.text(new Number($("#favorites_count").text())-1),e.removeClass("fav-rem").addClass("fav-add")}},error:function(t,e,a){}}),t.preventDefaults()}))}))}