var validator = new Validator();
var rpc = new Loader('forgot/');

specific_init = function ()
{
	new Forgotten();
}

var Forgotten = function ()
{
	var email = $('forgot_email');
	var error = $('forgot_errors');
	
	var init = function ()
	{
		$('forgot_send_btn').observe('click', SendInstructions);
	};
	
	var SendInstructions = function ()
	{
		var rules = new Array(
			{'input':email,'rule':validator.Email,'error_box':error,'error_msg':'Please enter a valid email address, (e.g. john@doe.com)'}
		);
		
		
		if(validator.Validate(rules))
		{
			var params = 'email='+email.value;
			var sent = rpc.Get('send', params, true);
			
			if(sent.error != null)
			{
				error.update('<br />There was a problem ... please try again.');
				return;
			}
			
			error.update('<br />'+sent.msg);
		}
	};
	
	init();
};