function ForgotPassController()
{
	var AJAX_SUBMIT_PAGE		= "/ajax/forgotpass.php";
	var TYPE_USERNAME			= "username";
	var TYPE_EMAIL				= "email";
	
	var username = null;
	var email = null;
	var in_progress = false;
	var buttons = new Array();
	var request_type = null;
	
	this.RetrieveUsername = function()
	{
		if(in_progress)
		{
			return(false);
		}
	
		username_element = document.getElementById("forgot_username");
		if(username_element.value.length == 0)
		{
			alert("Please enter your username.");
			username_element.focus();
			return;
		}
		
		SendRequest(TYPE_USERNAME);
	}
	
	this.RetrieveEmail = function()
	{
		if(in_progress)
		{
			return(false);
		}
	
		email_element = document.getElementById("forgot_email");
		if(email_element.value.length == 0)
		{
			alert("Please enter your e-mail address.");
			email_element.focus();
			return;
		}
		
		SendRequest(TYPE_EMAIL);
	}
	
	function SendRequest(type)
	{
		var params = new Array();
		params[type] = document.getElementById("forgot_" + type).value;

		StartAnimation(type);
		request_type = type;
		
		var ajax = new AjaxRequest(AJAX_SUBMIT_PAGE);
		ajax.Send(params, HandleResponse, HandleError);
	}
	
	function HandleResponse(response)
	{
		var msg = "Success!  An e-mail containing your login information has been sent to you and should arrive within a few minutes.\n\n";
		msg += "If you don't receive the e-mail, check that your spam filter is allowing mail from g-bot@newgrounds.com.\n\n";
		msg += "If you continue having login problems, contact wade@newgrounds.com for help.";
		alert(msg);
	
		StopAnimation(request_type);
	}
	
	function HandleError()
	{
		StopAnimation(request_type);
	}
	
	function StartAnimation(type)
	{
		in_progress = true;
		document.getElementById("statusbar_" + type).style.display = "";
		GetButton(type).Disable("Sending");
	}
	
	function StopAnimation(type)
	{
		in_progress = false;
		document.getElementById("statusbar_" + type).style.display = "none";
		GetButton(type).Enable();
	}
	
	function GetButton(type)
	{
		if(typeof buttons[type] == "undefined")
		{
			buttons[type] = new Button("submitbutton_" + type);
		}
		
		return(buttons[type]);
	}
}
