function BBSPoster()
{
	var AJAX_SUBMIT_PAGE 		= "/ajax/makebbspost.php";
	var IMAGE_UPLOAD_NAME 		= "bbsimage";
	var ACCEPTED_FILE_EXTENSIONS	= new Array("jpg", "jpeg", "gif");

	var submit_button = new Button("postbutton");

	// Include our code for image uploading and make it public
	this.ImageUploader = new FileUploadController(IMAGE_UPLOAD_NAME, 1, ACCEPTED_FILE_EXTENSIONS);

	var logged_in = IsSoftLoggedIn();
	var is_response;
	var has_agreed = true;

	this.Save = function()
	{
		// First make sure an image upload isn't currently in progress
		if(this.ImageUploader.UploadInProgress())
		{
			alert("Please wait for your image upload to finish.");
			return;
		}

		// Check whether this is a response to an existing thread, or a new thread altogether.
		is_response = document.getElementById("thread_id").value.length > 0;

		// We'll start all the way up here with our params.
		var params = new Array();

		var agreement_element = document.getElementById("agreement");
		if((agreement_element) && (agreement_element.type == "checkbox"))
		{
			has_agreed = agreement_element.checked;
			params["has_agreed"] = agreement_element.value;
		}

		if(!(logged_in))
		{
			var username_element = document.getElementById("username");
			if(username_element.value.length == 0)
			{
				alert("You must enter your username!");
				username_element.focus();
				return;
			}

			var password_element = document.getElementById("userpass");
			if(password_element.value.length == 0)
			{
				alert("You must enter your password!");
				password_element.focus();
				return;
			}
		}

		var subject_element = document.getElementById("subject");
		if(!(is_response))
		{
			if(subject_element.value.length < 3)
			{
				alert("You must enter a subject, of at least three characters in length.");
				subject_element.focus();
				return;
			}
		}

		var body_element = document.getElementById("body");
		if(body_element.value.length == 0)
		{
			alert("You must enter some text!");
			body_element.focus();
			return;
		}

		if(!(has_agreed))
		{
			alert("You must agree to the terms and conditions of posting!");
			agreement_element.focus();
			return;
		}

		StartStatusAnimation();
		//return;

		if(!(logged_in))
		{
			params["username"] = username_element.value;
			params["userpass"] = password_element.value;
		}

		params["subject"] = subject_element.value;
		params["forum_id"] = document.getElementById("forum_id").value;
		params["thread_id"] = document.getElementById("thread_id").value;
		params["icon_id"] = document.getElementById("icon").value;
		params["body"] = document.getElementById("body").value;

		// See if this includes an image
		var upload_id = document.getElementById(IMAGE_UPLOAD_NAME + "_temp_upload_id").value;
		if(upload_id != "")
		{
			// Yep, they attached an image
			params["upload_id"] = upload_id;
		}
		else if(document.getElementById(IMAGE_UPLOAD_NAME + "_delete").value == 1)
		{
			params["delete_image"] = 1;
		}

		var userkey_element = document.getElementById("userkey");
		if(userkey_element)
		{
			params["userkey"] = userkey_element.value;
		}

		var ajax = new AjaxRequest(AJAX_SUBMIT_PAGE);
		ajax.Send(params, HandlePostSave, HandleErrorCleanup);
	}

	function StartStatusAnimation()
	{
		document.getElementById("statusbar").style.display = "block";
		var button_str = (is_response ? "Submitting Response" : "Posting Thread");
		submit_button.Disable(button_str);
	}

	function StopStatusAnimation()
	{
		document.getElementById("statusbar").style.display = "none";
		submit_button.Enable();
	}

	function HandlePostSave(response)
	{
		window.location.href = response.GetField("post_url");
	}

	function HandleErrorCleanup()
	{
		StopStatusAnimation();
	}
}