function validate_form1(theForm)
{
  // validate form 1 fields
  var emailFilter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
  if (theForm.strStreetNo.value=="") {
    alert("Please enter a value for the unit/street number.");
	theForm.strStreetNo.focus();
	return false;
  }
  if (theForm.strStreetName.value=="") {
    alert("Please enter a value for the street name.");
	theForm.strStreetName.focus();
	return false;
  }
  if (theForm.strSuburb.value=="") {
    alert("Please enter a value for the street name.");
	theForm.strStreetName.focus();
	return false;
  }
  if (theForm.strHomeStyle.selectedIndex <= 0) {
    alert("Please select the home style.");
	theForm.strHomeStyle.focus();
	return false;
  }
  if (theForm.strType.selectedIndex <= 0) {
    alert("Please select your involvement with the property.");
	theForm.strType.focus();
	return false;
  }
  if (theForm.strSelling.selectedIndex <= 0) {
    alert("Please select when you are planning to sell.");
	theForm.strSelling.focus();
	return false;
  }
  if (theForm.strFirstname.value=="") {
    alert("Please enter your firstname.");
	theForm.strFirstname.focus();
	return false;
  }
  if (theForm.strLastname.value=="") {
    alert("Please enter your lastname.");
	theForm.strLastname.focus();
	return false;
  }
  if (!emailFilter.test(theForm.strEmail.value)) {
		alert("Please enter a valid email address.");
		theForm.strEmail.focus();
		return false;
  }
  if (theForm.confirmEmail.value!=theForm.strEmail.value) {
    alert("Your email and confirmed email do not match.  Please check the email address is entered correctly.");
	theForm.confirmEmail.focus();
	return false;
  }
  // allow the area code, but check only valid digits apart from that
  // replace with regular expression test later
  if (theForm.strPhone2.value=="" || theForm.strPhone3.value=="") {
    alert("Please enter the phone number in the format provided - eg. (07) 4123-4567");
	theForm.strPhone2.focus();
	return false;
  }
  
  return true;
}

function validate_form2(theForm)
{
  var fields=new Array('strAgeRange','strHomeSize','strLotSize','strConstructionType','intBedrooms','floBathrooms','intEnsuites',
					   'intLivingAreas','strParking','strAircon','strPool','intHomeCondition');
  var names=new Array('Approximate Age','Home size','Lot size','Construction type','Bedrooms','Bathrooms','Ensuites','Living areas',
					  'Parking facility','Air conditioning','Pool','Home condition');
  // validate the above drop downs
  for (i=0; i < fields.length; i++)
    if (document.forms[0].elements[fields[i]].selectedIndex <= 0) {
	  alert("Please select a resonse for "+names[i]);
	  document.forms[0].elements[fields[i]].focus();
	  return false;
	}
  return true;	
}