var email_filter	= /^([\w\d_\.\-])+(\@(([\w\d\-])+\.)+([\w\d]{2,4})+)?$/;
window.addEvent('domready', function(e){
	$('login_form').addEvent('submit', function(e){
		new Event(e).stop();
		if (!this.login.value.match(email_filter)){
			alert('Введен некорректный email')
			return;
		}
		if (this.pwd.value == ''){
			alert('Введите пароль')
			return;
		}
		
		new Request.JSON({
			url: this.action,
			method: 'post',
			onSuccess: function (resp){
				if(resp.error){
					alert(resp.error == 1 ? 'Аккаунта с введенными данными не существует' : resp.error );
					return;
				}
				document.location.href = '/';
			}
		}).send(this);
	});
});