var loginHTTP=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try{loginHTTP=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{loginHTTP=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){loginHTTP=false;}} @end @*/ if (!loginHTTP && typeof XMLHttpRequest!='undefined') {loginHTTP = new XMLHttpRequest();} function SetC(name, value, path) {if(name!=null && name!=''){document.cookie=name+'='+escape(value)+';path='+path+';expires=Fri, 31 Dec 2010 23:59:59 GMT;';return true;}else{return false;}} function GetC(name) {var cstr=document.cookie;var index=cstr.indexOf(name+'=');if (index==-1) {return null;}index=cstr.indexOf('=',index)+1;var endstr=cstr.indexOf(';',index);if (endstr==-1) {endstr=cstr.length;}return unescape(cstr.substring(index,endstr));} function DelC(name, path) {var today=new Date();var expire=new Date();expire.setTime(today.getTime()-3600000*24*365);document.cookie=name+'='+'value=;expires='+expire.toGMTString()+';path='+path;} function encodestr(str) { var trans = []; for (var i = 0x410; i <= 0x44F; i++) trans[i] = i - 0x350; trans[0x401] = 0xA8; trans[0x451] = 0xB8; var ret = []; for (var i = 0; i < str.length; i++) { var n = str.charCodeAt(i); if (typeof trans[n] != 'undefined') n = trans[n]; if (n <= 0xFF) ret.push(n); } var esc = escape(String.fromCharCode.apply(null, ret)); esc = esc.toString().replace(/\+/g, "%2B"); return esc; } function auth(login,pass){ try{ SetC('lastlogin', login, '/'); }catch(e){} if (login=='') { alert('Укажите логин'); return false; } if (pass=='') { alert('Укажите пароль'); return false; } var datas = 'login='+encodestr(login)+'&pass='+encodestr(pass); var URL = "/idkid"; try { loginHTTP.abort(); loginHTTP.open("POST", URL, false); loginHTTP.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); loginHTTP.setRequestHeader('Content-length', datas.length); loginHTTP.setRequestHeader('Connection', 'close'); loginHTTP.send(datas); var response = loginHTTP.responseText; if (response == '-1') { alert('Пользователь с указанным логином не найден.'); } else if (response == '-2'||response=='0') { alert('Неправильный логин или пароль.'); } else if (response == '-3') { alert('Пользователь не был активирован. Проверьте свою почту на наличие письма с кодом активации.'); } else if (response == '-4') { alert('Пользователь заблокирован. Обратитесь к администратору.'); } else if (response == '1') { document.location.href = document.location.href; } else { //alert('В процессе авторизации произошла неизвестная ошибка с кодом '+response+'. Повторите попытку позже или обратитесь к администратору.'); alert('Неправильный логин или пароль.'); } } catch (err) { alert('Сервер авторизации недоступен. Попробуйте повторить попытку позже.'); } return false; } function logout(){ var datas = 'login=&pass='; var URL = "/idkid"; try { loginHTTP.abort(); loginHTTP.open("POST", URL, false); loginHTTP.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); loginHTTP.setRequestHeader('Content-length', datas.length); loginHTTP.setRequestHeader('Connection', 'close'); loginHTTP.send(datas); document.location.href = document.location.href; } catch (err) { document.location.href = document.location.href; } return false; } function open_login_form(){ if (navigator.cookieEnabled){ var cookies = getCookie("login"); } dis = document.getElementById('login_form').style.display; if (dis == 'none'){ document.getElementById('login_form').style.display = ''; document.getElementById('voiti-viiti').innerHTML='Закрыть'; document.getElementById('vhod').style.width='74px'; document.getElementById('login').focus(); if (cookies != null){ document.getElementById('login').value = cookies; } }else{ document.getElementById('login_form').style.display = 'none'; document.getElementById('voiti-viiti').innerHTML='Войти'; document.getElementById('vhod').style.width='74px'; } } function getCookie(name) { var cookie = " " + document.cookie; var search = " " + name + "="; var setStr = null; var offset = 0; var end = 0; if (cookie.length > 0) { offset = cookie.indexOf(search); if (offset != -1) { offset += search.length; end = cookie.indexOf(";", offset) if (end == -1) { end = cookie.length; } setStr = unescape(cookie.substring(offset, end)); } } return(setStr); }