var contactFormHasBeenActivated = false;
var contactFormHasBeenSubmitted = false;

window.onload = function()
{
	if ( $("form_contact") )
	{
		$("form_contact").onsubmit = function()
		{
			if ( $F("textarea_contact") )
			{
				$("input_submit").disabled = "disabled";
				$("textarea_contact").disabled = "disabled";
				$("input_submit").value = "Please wait while we submit your information.";
				submitContactForm("/cgi-bin/contact.cgi");
			}
			else
			{
				alert( "Please enter some text." );
				$("textarea_contact").focus();
			}
			return false;
		}
	}
}

function submitContactForm(go_url)
{
	try
	{
		if ( go_url )
		{
			var xmlHttp = new Ajax.Request(go_url, {method: "get", 
								parameters:Form.serialize(document.forms[0]), 
								onComplete:function()
			{
				$("form_contact").innerHTML = "<p>Thank you! Your information has been submitted.</p>";
					onFailure:function()
					{
						$("form_contact").innerHTML = "<p>An error has occurred. Please try again later.</p>";
					}
			}
			});
			contactFormHasBeenSubmitted = true;
		}
	}
	catch ( err )
	{
		alert( "An error has occurred. Please try again later." ) ;
	}
}

function activateContactForm( someA )
{
	if ( ! contactFormHasBeenActivated )
	{
		contactFormHasBeenActivated = true;
		new Effect.BlindDown('form_contact');
	}
	else if ( contactFormHasBeenSubmitted )
		alert( "You have already submitted your information!\n\nPlease reload the page if you need to submit additional information." );
	else
		$("textarea_contact").focus();
}

