// JavaScript Document

function checkDropdown(choice) {
var error = "";
    if (choice == 0) {
	document.form1.region.style.background = 'Yellow';
    error = "You didn't choose a region. Please select a region.\n";
	}  
	else {
		document.form1.region.style.background = 'White';
	}
return error;

}    


function isFNameEmpty(strng) {
var error = "";
  if (strng.length == 0) {
	 document.form1.fname.style.background='Yellow';
     error = "Please enter your First Name.\n";
  }
  else {
	  document.form1.fname.style.background='White';
  }
return error;
}   


function isLNameEmpty(strng) {
var error = "";
  if (strng.length == 0) {
	 document.form1.lname.style.background='Yellow';
     error = "Please enter your Last Name.\n";
  }
  else {
	  document.form1.lname.style.background='White';
  }
return error;
}

function checkEmail (strng) {
var error="";
var emailFilter=/^.+@.+\..{2,3}$/;
var illegalChars= /[\(\)\<\>\,\;\:\\\"\[\]]/
if (strng == "") {
   document.form1.email.style.background='Yellow';
   error = "You didn't enter an email address.\n";

} else if (!(emailFilter.test(strng))) { 
	   document.form1.email.style.background='Yellow';
       error = "Please enter a valid email address.\n";
	   
} else if (strng.match(illegalChars)) {
		document.form1.email.style.background='Yellow';
        error = "The email address contains illegal characters.\n";
		  
} else {
		document.form1.email.style.background='White';
}
return error;   
}

function checkAddress(strng) {
var error = "";
	if (strng.length==0) {
		document.form1.address1.style.background='Yellow';
		error = "Please enter your address.\n";
	} else {
		document.form1.address1.style.background='White';
	}
return error;
}

function checkCity(strng) {
var error = "";
	if (strng.length==0) {
		document.form1.city.style.background='Yellow';
		error = "Please enter City.\n";
	} else {
		document.form1.city.style.background='White';
	}
return error;
}

function checkState(strng) {
var error = "";
var StateFilter = /^[a-zA-Z]*$/;

	if (strng.length==0) {
		document.form1.state.style.background='Yellow';
		error = "Please enter State.\n";
		
	} else if ((strng.length > 2) || (strng.length < 2)) {
		document.form1.state.style.background='Yellow';
		error = "Please enter a valid State.\n";
	
	} else if (!(StateFilter.test(strng))) {
		document.form1.state.style.background='Yellow';
		error = "Please enter 2 letters abbreviations of your State.\n";
	} else {
		document.form1.state.style.background='White';
	}
return error;
}

function checkZip (strng) {
var error = "";
var ZipFilter = /^[0-9]*$/;

	if (strng.length==0) {
		document.form1.zipCode.style.background='Yellow';
		error = "Please enter a Zip Code.\n";
		
	} else if ((strng.length > 5 ) || (strng.length < 5)) {
		document.form1.zipCode.style.background='Yellow';
		error = "Please enter a valide Zip Code.\n";
		
	} else if (!(ZipFilter.test(strng))) {
		document.form1.zipCode.style.background='Yellow';
		error = "Please enter a valid Zip Code. Include only the first 5 digit.\n";
	} else {
		document.form1.zipCode.style.background='White';
	}
return error;
}

function checkPhone (strng) {
var error = "";
var stripped = strng.replace(/[\(\)\.\-\ ]/g, '');
if (strng == "") {
	document.form1.phone.style.background='Yellow';
    error = "You didn't enter a phone number.\n";
   
} else if (isNaN(parseInt(stripped))) {
	document.form1.phone.style.background='Yellow';
    error = "The phone number contains illegal characters.";
	   
} else if (!(stripped.length == 10)) {
	document.form1.phone.style.background='Yellow';
	error = "The phone number is the wrong length. Make sure you included an area code.\n";
} else {
	document.form1.phone.style.background='White';
}
return error;
}

function checkTextArea(strng) {
var error = "";
	if (strng.length==0) {
		document.form1.comments.style.background='Yellow';
		error = "Please enter an area you like to build.\n";
	} else {
		document.form1.comments.style.background='White';
	}
return error;
}

function checkCaptcha(strng) {
var error="";
	if(strng.length==0) {
		document.form1.captcha.style.background='Yellow';
		error="Please enter the security code.\n";
	} else {
		document.form1.comments.style.background='White';
	}
return error;
}


