function changeTitle(theTitle) {
	title = " ~ Charleston Park - Tyler, Texas ~ Traditional Neighborhood and Development";
	document.title = theTitle+title;
}


function swapImage(oldImage, newImage) {
	var oldImage = document.getElementById(oldImage).src = 'images/'+newImage;
}


function Validator(theForm)
{

  if (theForm.contact_name.value == 0)
  {
    alert("Please enter something in the \"Name\" field.");
    theForm.contact_name.focus();
    return (false);
  }
  if (theForm.email.value == 0)
  {
    alert("Please enter something in the \"Email\" field.");
    theForm.email.focus();
    return (false);
  }

/////////////////////////////////////start of email check

var emailStr = (document.theForm.email.value);

var checkTLD=1;

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

var emailPat=/^(.+)@(.+)$/;

var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

var validChars="\[^\\s" + specialChars + "\]";

var quotedUser="(\"[^\"]*\")";

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

var atom=validChars + '+';

var word="(" + atom + "|" + quotedUser + ")";

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

alert("Email email address seems incorrect (check @ and .'s)");
var nogo="y";
    theForm.email.focus();
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Ths username contains invalid characters.");
var nogo="y";
    theForm.email.focus();
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Ths domain name contains invalid characters.");
var nogo="y";
    theForm.email.focus();
return false;
   }
}

if (user.match(userPat)==null) {

alert("The username doesn't seem to be valid.");
var nogo="y";
    theForm.email.focus();
return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Destination IP address is invalid!");
var nogo="y";
    theForm.email.focus();
return false;
   }
}
return true;
}
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("The domain name does not seem to be valid.");
var nogo="y";
    theForm.email.focus();
return false;
   }
}

if (checkTLD && domArr[domArr.length-1].length!=2 
&& domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("The email address must end in a well-known domain or two letter " + "country.");
var nogo="y";
    theForm.email.focus();
return false;
}

if (len<2) {
alert("This email address is missing a hostname!");
var nogo="y";
    theForm.email.focus();
return false;
}


/////////////////////////////////////end of email check


  if ((theForm.contact_pref.value == "NotSpecified"))
  {
    alert("Please select how you would like to be contacted.");
    theForm.contact_pref.focus();
    return (false);
  }

 if (theForm.contact_pref.value == "phone" && theForm.phone.value == 0)
  {
    alert("You selected to be contacted by phone, please provide a phone number for us to contact you.");
    theForm.phone.focus();
    return (false);
  }

 if (theForm.contact_pref.value == "phone2" && theForm.phone2.value == 0)
  {
    alert("You selected to be contacted by phone, please provide a phone number for us to contact you.");
    theForm.phone2.focus();
    return (false);
  }

 if (theForm.contact_pref.value == "mail" && theForm.address.value == 0)
  {
    alert("You selected to be contacted by mail, please provide a mailing address for us to contact you.");
    theForm.address.focus();
    return (false);
  }
 if (theForm.contact_pref.value == "mail" && theForm.city.value == 0)
  {
    alert("You selected to be contacted by mail, please provide a city for us to contact you.");
    theForm.city.focus();
    return (false);
  }

 if (theForm.contact_pref.value == "mail" && theForm.zip.value == 0)
  {
    alert("You selected to be contacted by mail, please provide a Zip or Postal Code for us to contact you.");
    theForm.zip.focus();
    return (false);
  }

 if (theForm.contact_pref.value == "mail" && theForm.state.value == 0)
  {
    alert("You selected to be contacted by mail, please provide a state or province for us to contact you.");
    theForm.state.focus();
    return (false);
  }

}

