var timer_check_id="",timer_auth_enter_sms_repeat_id="",timer_error=5000,timer_check=300000,auth_ok=false,auth_last=false,auth_term=0,auth_form="",auth_form_visible=false,auth_data_last="",auth_started=false,auth_warning_show=true,auth_phone="",auth_password="",auth_city="",auth_name="",auth_email="",auth_payer="",auth_subject="",auth_agency="",auth_days="",auth_days_wrn="",auth_days_vip="",auth_asns="",auth_sms="",auth_user="",auth_user_comment="",auth_page="",auth_dolg="",auth_free="",auth_pid="",auth_sms_repeat=false,window_focused=true,mouse_entered=false,restored_keys=false;function auth(){if(typeof scroll_unfreeze==='function')scroll_unfreeze();if(auth_asn=="")auth_contract_click();else if(auth_ok)auth_prolo_click();else auth_enter_click();return false;}function auth_refresh(is_search){if(auth_last==auth_ok)return false;if(typeof sales_auth_refresh==='function')sales_auth_refresh();if(typeof agencys_auth_refresh==='function')agencys_auth_refresh();if(typeof phones_auth_refresh==='function')phones_auth_refresh();if(is_search!==undefined&&is_search)if(typeof search_auth_refresh==='function')search_auth_refresh();auth_last=auth_ok;}function auth_load_unit(){$('#auth-unit-content').parent('tr').hide();$('#auth-unit-load').show()}function auth_load_form(){if(auth_form=="enter")auth_enter_form_load();if(auth_form=="prolo")auth_prolo_form_load();if(auth_form=="config")auth_config_form_load();if(auth_form=="register")auth_register_form_load();if(auth_form=="warning")auth_warning_form_load();return false;}function auth_open(form){auth_form=form;if(typeof scroll_unfreeze==='function')scroll_unfreeze();if(!auth_form_visible){if(typeof variant_visible!=="undefined"&&variant_visible)variant_hide();if(typeof photo_view_visible!=="undefined"&&photo_view_visible)photo_view_hide();if(typeof onmap_view_visible!=="undefined"&&onmap_view_visible)onmap_view_hide();if(typeof print_view_visible!=="undefined"&&print_view_visible)print_view_hide();if(typeof duples_view_visible!=="undefined"&&duples_view_visible)duples_view_hide();$('#auth-content').hide();$('#auth-load').hide();if($(window).scrollTop()>0){$('html,body').animate({'scrollTop':0},'fast',function(){$('#auth').fadeIn(200,function(){$('#auth-load').show();auth_load_form()})})}else{$('html,body').animate({'scrollTop':0},'fast');$('#auth').fadeIn(200,function(){$('#auth-load').show();auth_load_form()})}auth_form_visible=true;}else{if($(window).scrollTop()>0)$('html,body').animate({'scrollTop':0},'fast');auth_load_form()}return false;}function auth_cancel(){clearTimeout(timer_auth_enter_sms_repeat_id);$('#auth').fadeOut(200,function(){$('#auth-load').hide();$('#auth-content').html('')});auth_form_visible=false;return false;}function auth_close_click(){auth_cancel();ga_event('Вход:Закрытие окна');return false;}function auth_back_click(){clearTimeout(timer_auth_enter_sms_repeat_id);$('html,body').animate({'scrollTop':0},'fast');$('#auth-unit-title').html('Вход в систему');auth_load_unit();auth_enter_form_load();return false;}function auth_input_save(){if($('#auth-login-,#auth-phone').length==1)auth_phone=$('#auth-login-,#auth-phone').val();if($('#auth-password,#auth-code').length==1)auth_password=$('#auth-password,#auth-code').val();if($('#auth-city').length==1)auth_city=$('#auth-city').val();if($('#auth-name').length==1)auth_name=$('#auth-name').val();if($('#auth-email').length==1)auth_email=$('#auth-email').val();if($('#auth-payer').length==1)auth_payer=$('#auth-payer').val();if($('#auth-agency').length==1)auth_agency=$('#auth-agency').val();if($('#auth-term').length==1)auth_term=$('#auth-term').val();if($('#auth-asns').length==1)auth_asns=$('#auth-asns').val();if($('#auth-sms').length==1)auth_sms=$('#auth-sms').val();if($('#auth-agency-yes,#auth-agency-no').length>0)auth_subject=($('#auth-agency-yes').hasClass('auth-switch-select'))?1:0;return false;}function auth_input_ready(){if(auth_phone!="")$('#auth-login-,#auth-phone').val(auth_phone);if(auth_password!="")$('#auth-password,#auth-code').val(auth_password);if(auth_city!="")$('#auth-city').val(auth_city).find('option[value='+auth_city+']').attr('selected','selected');if(auth_name!="")$('#auth-name').val(auth_name);if(auth_email!=""&&auth_email!="@")$('#auth-email').val(auth_email);if(auth_payer!="")$('#auth-payer').val(auth_payer);if(auth_agency!="")$('#auth-agency').val(auth_agency);if(auth_term!=""){$('#auth-term').val(auth_term);try{calcPrice()}catch(e){}}if(auth_asns!=""){$('#auth-asns').val(auth_asns);try{calcPrice()}catch(e){}}auth_register_agency_switch(auth_subject);$('.auth-input,.auth-password,.auth-select').each(function(){if($(this).val()=="")$(this).val($(this).attr('default'));if($(this).val()==""||$(this).val()==$(this).attr('default'))$(this).removeClass('auth-error').removeClass('auth-normal').addClass('auth-default');else $(this).removeClass('auth-error').removeClass('auth-default').addClass('auth-normal')}).focus(function(){if($(this).val()==""||$(this).val()==$(this).attr('default'))$(this).val('');else $(this).select();$(this).removeClass('auth-error').addClass('auth-normal');$('#'+$(this).attr('id')+'-tooltip').delay(500).fadeIn(500)}).blur(function(){if($(this).val()=="")$(this).val($(this).attr('default'));if($(this).val()==""||$(this).val()==$(this).attr('default'))$(this).removeClass('auth-error').removeClass('auth-normal').addClass('auth-default');else $(this).removeClass('auth-error').removeClass('auth-default').addClass('auth-normal');$('#'+$(this).attr('id')+'-tooltip').fadeOut(200)}).change(function(){if($(this).val()=="")$(this).val($(this).attr('default'));if($(this).val()==""||$(this).val()==$(this).attr('default'))$(this).removeClass('auth-error').removeClass('auth-normal').addClass('auth-default');else $(this).removeClass('auth-error').removeClass('auth-default').addClass('auth-normal')}).keydown(function(e){});return false;}function auth_input_error(input,scrolltop){var $input=$(input);$input.removeClass('auth-error');if($input.val()==""||$input.val()==$input.attr('default')||(input=='#auth-password'&&$input.val().length!=8)){if(scrolltop===true)$('html,body').animate({'scrollTop':$input.offset().top-topline_height-10},100);$input.switchClass('auth-default','auth-error',100,function(){$(this).switchClass('auth-error','auth-default',500,function(){$(this).focus()})});return true;}return false;}function auth_switch_select(button){var $button=$(button);$button.removeClass('auth-error');if($button.hasClass('auth-switch-select'))return true;return false;}function auth_enter_click(){auth_load_unit();auth_open('enter');ga_event('Вход:Открытие окна');return false;}function auth_enter_form_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_enter'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-load').hide();$('#auth-content').html(data).fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_form_load,timer_error)});return false;}function auth_enter(){if(auth_input_error('#auth-password')||auth_input_error('#auth-city'))return false;auth_load_unit();auth_enter_check();return false;}function auth_enter_check(){auth_input_save();auth_restore_keys();$.ajaxSetup({crossDomain:true,xhrFields:{withCredentials:true}});$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'enter',code:auth_password,city:auth_city}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_check,timer_error)});return false;}function auth_enter_phone(){if(auth_input_error('#auth-phone'))return false;auth_load_unit();auth_enter_phone_check();return false;}function auth_enter_phone_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'enter',code:auth_password,city:auth_city,phone:auth_phone,repeat:auth_sms_repeat}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_phone_check,timer_error)});auth_sms_repeat=false;return false;}function auth_enter_name(){if(auth_input_error('#auth-name'))return false;auth_load_unit();auth_enter_name_check();return false;}function auth_enter_name_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'enter',phone:auth_phone,code:auth_password,city:auth_city,name:auth_name,repeat:auth_sms_repeat}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_name_check,timer_error)});auth_sms_repeat=false;return false;}function auth_enter_email(){auth_load_unit();auth_enter_email_check();return false;}function auth_enter_email_check(){auth_input_save();auth_restore_keys();if(auth_email==""||auth_email==$('#auth-email').attr('default'))auth_email="@";$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'enter',phone:auth_phone,code:auth_password,city:auth_city,name:auth_name,email:auth_email,repeat:auth_sms_repeat}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_email_check,timer_error)});auth_sms_repeat=false;return false;}function auth_enter_sms(){clearTimeout(timer_auth_enter_sms_repeat_id);if(auth_input_error('#auth-sms'))return false;auth_load_unit();auth_enter_sms_check();return false;}function auth_enter_sms_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'enter',phone:auth_phone,code:auth_password,city:auth_city,name:auth_name,email:auth_email,sms:auth_sms}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_enter_sms_check,timer_error)});return false;}function auth_enter_sms_repeat(){clearTimeout(timer_auth_enter_sms_repeat_id);$('#auth-sms-repeat').html('Повторить');return false;}function auth_enter_sms_repeat_click(){auth_load_unit();auth_sms_repeat=true;auth_enter_name_check();return false;}function auth_enter_back(form){clearTimeout(timer_auth_enter_sms_repeat_id);auth_load_unit();switch(form){case 'code':auth_back_click();break;case 'phone':auth_enter_check();break;case 'name':auth_enter_phone_check();break;case 'email':auth_enter_name_check();break;case 'sms':auth_enter_email_check();break;case 'done':auth_enter_sms_check();break;}return false;}function auth_contract_click(){auth_load_unit();auth_open('register');ga_event('Вход:Подключение');return false;}function auth_register_form_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_register'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-load').hide();$('#auth-content').html(data).fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_form_load,timer_error)});return false;}function auth_register_click(){$('html,body').animate({'scrollTop':0},'fast');$('#auth-unit-title').html('Вход в систему| Регистрация');auth_load_unit();auth_register_load();ga_event('Вход:Регистрация');return false;}function auth_register_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_load,timer_error)});return false;}function auth_register(){if(auth_input_error('#auth-city')||auth_input_error('#auth-term')||auth_input_error('#auth-asns'))return false;auth_load_unit();auth_register_check();return false;}function auth_register_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register',city:auth_city,term:auth_term,asns:auth_asns}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_restore_check,timer_error)});return false;}function auth_register_user(){if(auth_input_error('#auth-phone')||auth_input_error('#auth-payer'))return false;auth_load_unit();auth_register_user_check();return false;}function auth_register_user_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register',city:auth_city,term:auth_term,asns:auth_asns,phone:auth_phone,payer:auth_payer}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_user_check,timer_error)});return false;}function auth_register_email(){auth_load_unit();auth_register_email_check();return false;}function auth_register_email_check(){auth_input_save();auth_restore_keys();if(auth_email==""||auth_email==$('#auth-email').attr('default'))auth_email="@";$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register',city:auth_city,term:auth_term,asns:auth_asns,phone:auth_phone,payer:auth_payer,email:auth_email}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_email_check,timer_error)});return false;}function auth_register_agency(){if(!auth_switch_select('#auth-agency-yes')&&!auth_switch_select('#auth-agency-no')){$('#auth-agency-yes,#auth-agency-no').switchClass('auth-switch-default','auth-switch-error',100,function(){$(this).switchClass('auth-switch-error','auth-switch-default',500)});return false;}if($('#auth-agency-yes').hasClass('auth-switch-select')&&auth_input_error('#auth-agency'))return false;auth_load_unit();auth_register_agency_check();return false;}function auth_register_agency_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register',city:auth_city,term:auth_term,asns:auth_asns,phone:auth_phone,payer:auth_payer,email:auth_email,subject:auth_subject,agency:auth_agency}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_agency_check,timer_error)});return false;}function auth_register_sms(){if(auth_input_error('#auth-sms'))return false;auth_load_unit();auth_register_sms_check();return false;}function auth_register_sms_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'register',city:auth_city,term:auth_term,asns:auth_asns,phone:auth_phone,payer:auth_payer,email:auth_email,subject:auth_subject,agency:auth_agency,sms:auth_sms}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_sms_check,timer_error)});return false;}function auth_register_demo(pid){auth_load_unit();auth_pid=pid;auth_register_demo_check();return false;}function auth_register_demo_check(){if(auth_pid=="")return false;$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'demo',pid:auth_pid}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_register_demo_check,timer_error)});return false;}function auth_register_back(form){auth_load_unit();if(form==1)auth_register_user_check();else if(form==2)auth_register_email_check();else if(form==3)auth_register_agency_check();else auth_register_check();return false;}function auth_register_agency_switch(switch_index){switch(switch_index){case 0:$('#auth-agency-yes').removeClass('auth-switch-select');$('#auth-agency-no').addClass('auth-switch-select');$('#auth-agency').closest('tr').css('visibility','hidden');break;case 1:$('#auth-agency-yes').addClass('auth-switch-select');$('#auth-agency-no').removeClass('auth-switch-select');$('#auth-agency').closest('tr').css('visibility','visible');break;default:$('#auth-agency-yes').removeClass('auth-switch-select');$('#auth-agency-no').removeClass('auth-switch-select');$('#auth-agency').closest('tr').css('visibility','hidden')}return false;}function auth_demo_click(){auth_load_unit();$('#auth-content').hide();$('#auth-load').show();$('#auth').show();$('html,body').animate({'scrollTop':0},'fast',function(){window.location=protocol+domain+((isDebug)?'/dbg':'')+'/demo';});ga_event('Вход:Демо-доступ');return false;}function auth_restore_click(){$('html,body').animate({'scrollTop':0},'fast');auth_load_unit();auth_restore_form_load();ga_event('Вход:Забыли код');return false;}function auth_restore_form_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_restore'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_restore_form_load,timer_error)});return false;}function auth_restore(){if(auth_input_error('#auth-phone')||auth_input_error('#auth-city'))return false;auth_load_unit();auth_restore_check();return false;}function auth_restore_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'restore',phone:auth_phone,city:auth_city}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_restore_check,timer_error)});return false;}function auth_done_click(city){auth_close_click();auth_refresh(false);if(web_city!=city||window.location.pathname!="/db/search"){$('#topline-city').val(city).find('option[value='+city+']').attr('selected','selected');topCityMouseDown()}if(typeof search_cache_clear==='function')search_cache_clear()}function auth_check(){auth_check_load();return false;}function auth_check_load(){clearTimeout(timer_check_id);if(!document_active()&&auth_data_last!=""){timer_check_id=setTimeout(auth_check_load,2000);return false;}auth_restore_keys();$.post(ajax_url,{version:web_version,session:((typeof web_session!=="undefined")?web_session:''),page:'auth',unit:'check',url:window.location.host+window.location.pathname,started:auth_started}).done(function(data){if(data==site403){if(web_banned)return data='';else webReload()}if(data!=''&&data!='-'&&data!=auth_data_last){auth_data_last=data;$('.toplineAuth').html(data).fadeIn(500)}timer_check_id=setTimeout(auth_check_load,timer_check);auth_refresh(true)}).fail(function(){timer_check_id=setTimeout(auth_check_load,timer_error)});return false;}function auth_exit_click(){auth_exit();ga_event('Выход');return false;}function auth_exit(){auth_exit_load();return false;}function auth_exit_load(){auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'exit'}).done(function(data){if(data==site403)return console.log(data);if(data!=''&&data!='-'&&data!=auth_data_last){auth_data_last=data;$('.toplineAuth').hide().html(data).fadeIn(500)}if(auth_form_visible)auth_close_click();auth_refresh(false)}).fail(function(){setTimeout(auth_exit_load,timer_error)});return false;}function auth_prolo_blink(){$('.auth-prolo-warn').animate({'opacity':0.2},200,function(){$(this).animate({'opacity':'1.0'},400,function(){setTimeout(auth_prolo_blink,500)})})}function auth_prolo_click(){auth_load_unit();auth_open('prolo');ga_event('Вход:Продление');return false;}function auth_prolo_form_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_prolo'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-load').hide();$('#auth-content').html(data).fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_prolo_form_load,timer_error)});return false;}function auth_prolo_pay(){if(auth_input_error('#auth-term'))return false;auth_load_unit();auth_prolo_pay_check();return false;}function auth_prolo_pay_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'prolo',term:auth_term}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_prolo_pay_check,timer_error)});return false;}function auth_config_clear(){auth_name="";auth_email="";auth_subject="";auth_agency="";return false;}function auth_config_click(){auth_load_unit();auth_open('config');ga_event('Вход:Настройка');return false;}function auth_config_form_load(){auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_config'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-load').hide();$('#auth-content').html(data).fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_form_load,timer_error)});return false;}function auth_config_save(){if(auth_input_error('#auth-name'))return false;if(!auth_switch_select('#auth-agency-yes')&&!auth_switch_select('#auth-agency-no')){$('#auth-agency-yes,#auth-agency-no').switchClass('auth-switch-default','auth-switch-error',100,function(){$(this).switchClass('auth-switch-error','auth-switch-default',500)});return false;}if($('#auth-agency-yes').hasClass('auth-switch-select')&&auth_input_error('#auth-agency'))return false;auth_load_unit();auth_config_save_check();return false;}function auth_config_save_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',name:auth_name,subject:auth_subject,agency:auth_agency,save:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_save_check,timer_error)});return false;}function auth_config_asns(){auth_load_unit();if(!auth_form_visible){auth_open('config');setTimeout(auth_config_asns_timer,1000)}else auth_config_asns_load();ga_event('Вход:Просмотр списка ПК');return false;}function auth_config_asns_timer(){auth_load_unit();if(auth_form_visible)auth_config_asns();return false;}function auth_config_asns_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',asns:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_asns_load,timer_error)});return false;}function auth_config_asns_add(){auth_load_unit();if(!auth_form_visible){auth_open('config');setTimeout(auth_config_asns_add_timer,1000)}else auth_config_asns_add_check();return false;}function auth_config_asns_add_timer(){auth_load_unit();if(auth_form_visible)auth_config_asns_add();return false;}function auth_config_asns_add_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',asns:1,add:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_asns_add_check,timer_error)});return false;}function auth_config_asns_pay(){auth_config_asns_pay_check();return false;}function auth_config_asns_pay_check(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',asns:auth_asns,pay:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_asns_pay_check,timer_error)});return false;}function auth_config_asns_del(asn){$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',del:asn}).done(function(data){if(data==site403)return console.log(data)}).fail(function(){});return false;}function auth_config_asns_rst(asn){$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',rst:asn}).done(function(data){if(data==site403)return console.log(data)}).fail(function(){});return false;}function auth_config_acts(){auth_load_unit();if(!auth_form_visible){auth_open('config');setTimeout(auth_config_acts_timer,1000)}else auth_config_acts_load();ga_event('Вход:Просмотр актов');return false;}function auth_config_acts_timer(){auth_load_unit();if(auth_form_visible)auth_config_acts();return false;}function auth_config_acts_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',acts:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_acts_load,timer_error)});return false;}function auth_config_exit(){auth_load_unit();auth_config_exit_load();ga_event('Выход:Подтверждение');return false;}function auth_config_exit_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'config',exit:1}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-unit-load').hide();$('#auth-unit-content').html(data).parent('tr').fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_config_exit_load,timer_error)});return false;}function auth_help_click(){auth_help_load();ga_event('Вход:Справка');return false;}function auth_help_load(){auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'help'}).done(function(data){if(data==site403)return console.log(data);if(data!='')$('#auth-help').html(data).outerWidth($('#auth-form').outerWidth()).outerHeight($('#auth-form').outerHeight()).fadeIn(500)});return false;}function auth_help_close(){$('#auth-help').fadeOut(200);return false;}function auth_tariff_click(){if(auth_input_error('#auth-city'))return false;auth_tariff_load();ga_event('Вход:Тариф');return false;}function auth_tariff_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'tariff',city:auth_city}).done(function(data){if(data==site403)return console.log(data);if(data!='')$('#auth-help').html(data).outerWidth($('#auth-form').outerWidth()).outerHeight($('#auth-form').outerHeight()).fadeIn(500)});return false;}function auth_tariff_close(){$('#auth-help').fadeOut(200);return false;}function auth_privacy_click(){ga_event('Вход:Политика конфиденциальности');return true;}function auth_oferta_click(){ga_event('Вход:Договор-оферта');return true;}function auth_warning(){auth_load_unit();auth_open('warning');return false;}function auth_warning_form_load(){auth_input_save();auth_restore_keys();$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'form_warning'}).done(function(data){if(data==site403)return console.log(data);if(data!=''){$('#auth-load').hide();$('#auth-content').html(data).fadeIn(200);auth_input_ready()}else auth_cancel()}).fail(function(){setTimeout(auth_warning_form_load,timer_error)});return false;}function auth_context(){$('#topline,#auth').bind('contextmenu',function(e){return false;});return false;}function auth_start(){if(auth_started)return false;auth_started=true;if(auth_ok&&auth_warning_show&&(auth_dolg||auth_days<=auth_days_wrn||(auth_days>=auth_days_vip-5&&auth_days=0||auth_page.indexOf('/free')>=0))auth_enter_click();if(isDebug)console.log('auth | user:'+auth_user+' | comment:'+auth_user_comment+' | auth_days:'+auth_days+' | auth_dolg:'+auth_dolg+' | auth_free:'+auth_free);return false;}function window_blur(){window_focused=false;}function window_focus(){window_focused=true;}function mouse_leave(){mouse_entered=false;}function window_enter(){mouse_entered=true;}function document_active(){return(window_focused||mouse_entered)}$(document).ready(function(){$(document).ready(function(){$(window).keydown(function(e){if(auth_form_visible){if(e.keyCode==13){if($("input:focus").length>0)$("input:focus").blur();$('.auth-button').click()}if(e.keyCode==27){if($("input:focus").length>0)$("input:focus").blur();else auth_close_click();e.stopImmediatePropagation();return false;}}}).blur(function(){window_blur()}).focus(function(){window_focus()});$(document).mouseleave(function(){mouse_leave()}).mouseenter(function(){window_enter()});if(!is_mobile){auth_check();auth_context()}})});function auth_check_storage(key,timer){try{if(window.localStorage){var cookie=getCookie(key),storage=localStorage.getItem(key);if((cookie==""||cookie==null)&&(storage!=""&&storage!=null))setCookie(key,storage,timer,"/",domain);else if((storage==""||storage==null)&&(cookie!=""&&cookie!=null))localStorage.setItem(key,cookie);else if(storage!=""&&storage!=null&&storage!=cookie)setCookie(key,storage,timer,"/",domain)}}catch(e){}return false;}function auth_restore_keys(){if(restored_keys)return false;auth_check_storage('asn',30*12);if(typeof web_code!=="undefined"&&web_code!="")auth_check_storage('token-'+web_code,30*12);restored_keys=true;return false;}function auth_backup_key(key,value){try{if(window.localStorage)localStorage.setItem(key,value);auth_check_storage(key,30*12)}catch(e){}return false;}auth_restore_keys();var document_hidden,document_visibilityChange;if(typeof document.hidden!=="undefined"){document_hidden="hidden";document_visibilityChange="visibilitychange";}else if(typeof document.mozHidden!=="undefined"){document_hidden="mozHidden";document_visibilityChange="mozvisibilitychange";}else if(typeof document.msHidden!=="undefined"){document_hidden="msHidden";document_visibilityChange="msvisibilitychange";}else if(typeof document.webkitHidden!=="undefined"){document_hidden="webkitHidden";document_visibilityChange="webkitvisibilitychange";}function document_handleVisibilityChange(){if(document[document_hidden])window_blur();else window_focus()}document.addEventListener(document_visibilityChange,document_handleVisibilityChange,false);window.onbeforeunload=function(event){unload(event)};function unload(event){window_blur();if(is_mobile)var web_version=mob_version,web_session=mob_session;$.post(ajax_url,{version:web_version,session:web_session,page:'auth',unit:'bye'}).done(function(data){}).fail(function(){});setCookie("online",'',-1,"/",domain);ga_event('Закрытие страницы');return true;}