/*
	Ensure all fields are filled out and valid.  Submit ajax.
*/

function SubmitInfoForm()
{
	if (document.QuoteForm.Name.value.trim().length <= 1 || document.QuoteForm.Name.value.trim().length > 50)
	{
		FocusOnField(document.QuoteForm.Name);
		ShowPopup("ERROR", "Please enter your name (up to 50 characters).");
		return false;
	}
	else if (!IsValidEmail(document.QuoteForm.Email.value) || document.QuoteForm.Email.value.trim().length > 50)
	{
		FocusOnField(document.QuoteForm.Email);
		ShowPopup("ERROR", "Please enter a valid e-mail address (up to 50 characters).");
		return false;
	}
	else if (document.QuoteForm.Phone.value.trim().length <= 1 || document.QuoteForm.Phone.value.trim().length > 50)
	{
		FocusOnField(document.QuoteForm.Phone);
		ShowPopup("ERROR", "Please enter your phone number (up to 50 characters).");
		return false;
	}
	else if (document.QuoteForm.Message.value.trim().length <= 1 || document.QuoteForm.Message.value.trim().length > 250)
	{
		FocusOnField(document.QuoteForm.Message);
		ShowPopup("ERROR", "Please enter your message (up to 250 characters).");
		return false;
	}
	else if (document.QuoteForm.Captcha.value.trim().length <= 1 || document.QuoteForm.Captcha.value.trim().length > 10)
	{
		FocusOnField(document.QuoteForm.Captcha);
		ShowPopup("ERROR", "Please enter the value from the image above.");
		return false;
	}
	
	Parameters =	"&Name=" + document.QuoteForm.Name.value +
			"&Email=" + document.QuoteForm.Email.value +
			"&Website=" + document.QuoteForm.Website.value +
			"&Phone=" + document.QuoteForm.Phone.value +
			"&Message=" + document.QuoteForm.Message.value +
			"&Captcha=" + document.QuoteForm.Captcha.value;

	AjaxCall("POST", "ajax-submit-info-form.php", "SubmitInfoForm=1" + Parameters, "AfterSubmitInfoForm", true);
}


function AfterSubmitInfoForm(xml, text)
{
	if (text == "")
	{
		//Do this for Google goal tracking.
		//pageTracker._trackPageview("/submit_info_form.html");
		
		ShowPopup("Success", "Thank you, the form has been submitted!  We will be in contact with you shortly.");
	}
	else
		ShowPopup("ERROR", text);
}

