﻿// для регистрации: вбиваем логин в поле для мыла
function copy_login(lang) {
	$("#EMAIL").attr({value: $("#LOGIN").attr("value")});
	if (document.regform["REGISTER[PASSWORD]"].value != document.regform["REGISTER[PASSWORD_CONFIRM]"].value)	
		{
			if (lang == 'ru') alert("Неверное подтверждение пароля");
			if (lang == 'en') alert("Wrong password confirmation");
			return false;
		}
	else
		return true;
}

function show_login_form() {
	close_user_forms();
	$("#at_bitrix").show();
	$("#authorization_links").css({backgroundColor: "transparent"});
	
}

function show_register_form() {
	close_user_forms();
	$("#registration").show();
	$("#authorization_links").css({backgroundColor: "transparent"});
}

function show_password_form() {
	close_user_forms();
	$("#forgot_password_div").show();
	$("#authorization_links").css({backgroundColor: "transparent"});
}

function close_user_forms() {
	$("#registration").hide();
	$("#forgot_password_div").hide();
	$("#at_bitrix").hide();
	//$("#authorization_links").css({backgroundColor: "#383756"});
}

function restore_password() {
	$("#forgot_password_error").hide();
	$("#forgot_password_success").hide();
	$("#send_account_info").attr("disabled","disabled");
	$.post("/password_restore.php", { email: $("#USER_EMAIL").attr("value") },
	function(data){
    	if (data.reply) $("#forgot_password_success").show();
		else {
			$("#forgot_password_error").show();
			$("#send_account_info").attr("disabled","");
		}
  	}, "json");
}
