
function checkLogin() {

	if(!$("#auth_email").val()) { $("#auth_email").focus(); return false; }

	if(email_not_valid.test($("#auth_email").val()) || !email_valid.test($("#auth_email").val())) {
		$("#notice").html(img_error + lang.signin.wrong_email);
		$("#notice").fadeIn(200);
		$("#auth_email").select();
		$("#auth_email").focus();
		return false;
	} else {
		$("#notice").hide();
	}

	if(!$("#auth_password").val()) { $("#auth_password").focus(); return false; }

	$("#notice").html(wait_message);
	$("#notice").show();

	$.ajax({
		type: "POST",
		url: "/" + language + "/engine/signin.php",
		data: "type=ajax&email=" + $("#auth_email").val() + "&password_type=md5&password_hash=" + $.md5($("#auth_password").val()) + "&location=" + $("#location").val(),
		success: function(msg) {
			if(msg == "ok") {
				$("#password_hash").val($.md5($("#auth_password").val()));
				$("#password_type").val("md5");
				$("#auth_password").val("");
				$("#auth_form").submit();
			} else {
				if(msg == "not confirmed") {
					var message = img_ok + lang.signin.validate;
				} else if(msg == "banned") {
					var message = img_error + lang.signin.blocked;
				} else {
					var message = img_error + lang.signin.wrong;
				}

				$("#notice").hide();
				$("#notice").html(message);
				$("#notice").fadeIn(200);

				if(msg != "banned") {
					$("#auth_email").select();
					$("#auth_email").focus();
				}
			}
		}
	});

	return false;
}
