var email_filter	= /^([\w\d_\.\-])+(\@(([\w\d\-])+\.)+([\w\d]{2,4})+)?$/;

window.addEvent('domready', function(e){
	if($('form_login')){
		$('form_login').addEvent('submit', function(e){
			new Event(e).stop();
			if (!this.u_email.value.match(email_filter)){
				alert('Введен некорректный email');
				return;
			}
			if (this.u_pwd.value == ''){
				alert('Введите пароль');
				return;
			}
			
			ajaxLoader.show('Авторизация...');
			new Request.JSON({
				url: this.action,
				method: 'post',
				onSuccess: function(resp, text){
					ajaxLoader.hide();
					if(resp.error){
						alert(resp.error);
						return;
					}
					document.location.href = resp.gourl ? resp.gourl : '/';
				}
			}).send(this);
		});
	}
});