function doField(field, def)
{
	if(field.value == '')
		field.value = def;
	else if(field.value == def)
		field.value = '';
}


function TryToSubmitContactForm()
{
	//1.	Ensure entered all mandatory fields
	//2.	Submit form via AJAX
	//	  This continues in AfterTryToSubmitContactForm()
	//3.	Show message box
	
	//1.
	if (document.ContactForm.ClientName.value == 'Name' || document.ContactForm.ClientName.value == '')
	{
		ShowPopup("ERROR", "Please enter your name.");
		return false;
	}
	else if (document.ContactForm.ClientPhone.value == 'Phone number' || document.ContactForm.ClientPhone.value == '')
	{
		ShowPopup("ERROR", "Please enter your phone number.");
		return false;
	}
	else if (document.ContactForm.ClientEmail.value != "E-mail" && !IsValidEmail(document.ContactForm.ClientEmail.value))
	{
		ShowPopup("ERROR", "Please enter a valid e-mail address or leave this field blank.");
		return false;
	}
	
	
	//2.
	//document.ContactForm.submit();
	var Parameters =	"&Name=" + escape(document.ContactForm.ClientName.value) +
				"&Phone=" + escape(document.ContactForm.ClientPhone.value) +
				"&Email=" + escape(document.ContactForm.ClientEmail.value) +
				"&NumberOfBedrooms=" + escape(document.ContactForm.ClientBedrooms.value) +
				"&PriceRange=" + escape(document.ContactForm.ClientPrice.value) +
				"&SpecialInstructions=" + escape(document.ContactForm.ClientComments.value);
				
	var MyAjax = new AjaxConnection("ajax/ajax_submit_comments.php", "SubmitCom=1" + Parameters, "AfterTryToSubmitContactForm"); 
	
}


function AfterTryToSubmitContactForm(xml, text)
{
	//3.
	ShowPopup("Success!", "Thank you, your message has been delivered to Judy!<br /><br />We will be in contact with you shortly.");
}

