<?PHP include('header.php');?>
<span class='top-bl-s-verh'>Добро пожаловать на <?=$sitename?>!</span>
<div class='menucenter-top1'>
<table class='profile' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 0;'>
<tr><td class='value1'>
Для входа в свой аккаунт на <span class='seosprint'><?=$sitename?></span>, 
введите ваш регистрационный e-mail, пароль и проверочный код с картинки. 
</td></tr>
</table>
<div id="echologinres" class='value11'></div>
<div id="login_form">
<form>
<table class='profile' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 0;'>
 <tr>
  <td width="45%"><b>Ваш E-mail</b></td>
  <td class="value"><input type="text" id="logemail" maxlength="50" onkeyup="return valid_inp('logemail');" value="<? if(isset($_COOKIE["us_em"]) && check_email($_COOKIE["us_em"])){ echo check_email($_COOKIE["us_em"]);} ?>" style="width: 170px;" /></td>
 </tr>
 <tr>
  <td width="45%"><b>Ваш Пароль</b></td>
  <td class="value"><input type="password" id="logpassword" maxlength="40" onkeyup="return valid_inp('logpassword');" value="<? if(isset($_COOKIE["us_pass"])){ echo uc($_COOKIE["us_pass"]);} ?>" style="width: 170px;" /> <input type="checkbox" checked="" onclick="savecook('save_my');"> Запомнить </td>
 </tr>
</table> 
<center><div class="captcha"><img src="capcha/login_img.php" id="code1" /></br><input type="text" id="codes_l" maxlength="3" value="" style="width: 60px; text-transform: uppercase;" autocomplete="off" /></div></center><br />
<center>
<input id='save_my' type='hidden' value='1'>
<div id="loading_login" style="display:none;text-align:center;margin-bottom:15px;"><img src="img/login_loader.gif"></div>
<a class='button-green' onclick="login();" style="cursor:pointer;">Войти в аккаунт</a>
</center>
</form>
</div>


<div id="restore_form" style="display:none;">
<form>
<table class='profile' width='100%' border='0' cellpadding='0' cellspacing='0' style='margin-bottom: 0;'>
 <tr>
  <td width="45%"><b>Ваш E-mail</b></td>
  <td class="value"><input type="text" id="email" maxlength="50" onkeyup="return valid_inp('email');" value="" style="width: 170px;" /></td>
 </tr>
</table>
<center><div class="captcha"><img src="capcha/res_img.php" id="code2" /></br><input type="text" id="codes_r" maxlength="3" value="" style="width: 60px; text-transform: uppercase;" autocomplete="off"/></div></center><br />
<center><a class='button-green' onclick="restorepass();" style="cursor:pointer;">Отправить</a></center>
</form>
</div>
<script>
function s_h_restore(bname) {
$("#echologinres").html("");
if (document.getElementById("restore_form").style.display == 'none') {
document.getElementById("restore_form").style.display = '';
document.getElementById("login_form").style.display = 'none';
$("#s_h_r_btn").html("Авторизация");
}else{
document.getElementById("restore_form").style.display = 'none';
document.getElementById("login_form").style.display = '';
$("#s_h_r_btn").html("Востановить пароль");
}
return false;
}
function savecook(x) { if (document.getElementById(x).value == 1){document.getElementById(x).value = 0}else {document.getElementById(x).value = 1} }
//Авторизация
function login(){
setInterval('problem_connect();', 12000);
var logemail = $.trim($('#logemail').val());
var logpassword = $.trim($('#logpassword').val());
var codes_l = $.trim($('#codes_l').val());
var save = $.trim($('#save_my').val());
$('#echologinres').html('');
if (logemail == ''){ $('#echologinres').html("<?=$infstart?><div class='l1'>Вы не указали e-mail для входа</div><?=$infend?>"); }
else if(logpassword == ''){ $('#echologinres').html("<?=$infstart?><div class='l1'>Вы не указали пароль для входа</div><?=$infend?>"); }
else if(codes_l == ''){ $('#echologinres').html("<?=$infstart?><div class='l1'>Ошибка ввода кода</div><?=$infend?>"); }
else{
$('#loading_login').show();
$.ajax({
type: 'POST',
url: 'ajax/login.php',
data: { 'func': "login", 'logemail': logemail, 'logpassword': logpassword, 'codes_l': codes_l, 'save' : save },
beforeSend: function(){ },
success: function(data){ 
if(data == 1) {
document.location.href = "/profile.html";
} else {
$('#loading_login').hide();
$('#echologinres').html("<?=$infstart?>"+data+"<?=$infend?>");return false;}
}
});
return false;
}
}
function problem_connect(){ $('#loading_login').hide(); $('#echologinres').html("<?=$infstart?>Проблемы с авторизацией. <br/> Попробуйте обновить кеш браузера нажав CTRL+F5 или перезапустите его.<?=$infend?>"); }
function refresh_on(_element_id) {
var element = document.getElementById(_element_id);  
if(element){  
element.src = element.src + '?' + (new Date()).getMilliseconds()  
}  
}
function valid_inp(input) {
var in_name = $.trim($('#'+input).val());
var re = /а|б|в|г|д|е|ё|ж|з|и|й|к|л|м|н|о|п|р|с|т|у|ф|х|ц|ч|ш|щ|ъ|ы|ь|э|ю|я|і|!|#|$|%|<|>|/gi;
if (re.test(in_name)) {in_name = in_name.replace(re, ''); $('#'+input).val(in_name);}}
function restorepass(){
var email = $.trim($('#email').val());
var codes_r = $.trim($('#codes_r').val());
if(email == ''){ $('#echologinres').html("<?=$infstart?><div class='l1'>Вы не указали e-mail</div><?=$infend?>"); }
else{
$.ajax({
type: 'POST',
url: 'ajax/login.php',
data: { 'func' : 'res_pass', 'email' : email, 'codes_r': codes_r },
success: function(data){
$('#echologinres').html("<?=$infstart?>"+data+"<?=$infend?>");
 return false; }
});
}
}
</script>
</div><br /><center><button onclick="s_h_restore();" class='button-green' id="s_h_r_btn">Востановить пароль</button></center>
<?PHP include('footer.php');?>