$(document).ready(function() {
	//Forgot
	$('#forgot_submit').bind("click", function(event) {
		event.preventDefault();
		
		$("#forgot_email_error").html('');
		$("#forgot_status").html('');
		
		var email = $("#forgot_email").val();
	
		var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
	
		if(email.length <= 0 || email == 'myname@example.com') {
			$("#forgot_email_error").html('enter an email address').addClass('error_message');
			$("#forgot_email").focus();
			return false;
		} 
		
		if(!re.test(email)) {
			$("#forgot_email_error").html('invalid email');
			$('#forgot_email').focus();
			return false;
		}
		
		_lag.hover_box('#loading');
		$.post("/includes/forgot.php", {
			'email': email
			}, function(data) {
				if(data == 'success') {				
					_lag.hover_box('#forgot_msg');
					setTimeout(function(){window.location.reload();}, 2000);
				} else {
					$(_lag.target).html(_lag.temp);
					$('#hover_box').css({'display' : 'none'});
					$('#modal-overlay').css({'display' : 'none'});
					_lag.popped = false;
					$("#forgot_status").html(data);
				}
		});

		return false;
	});
});
