// JavaScript Document
function validate(form) {
  	var e = form.elements;
  	
	if(e['firstname'].value == "") {
		alert('Please fill in the First Name field.');
		return false;
	}
	if(e['lastname'].value == "") {
		alert('Please fill in the Last Name field.');
		return false;
	}
	
	if(e['phone'].value == "") {		
		alert('Please fill in the Home Phone field.');
		return false;
	} 
	
	var stripped = e['phone'].value.replace(/[\(\)\.\-\ ]/g, '');    
	if (isNaN(parseInt(stripped))) {
		alert("The Home Phone contains illegal characters.");
		return false;
	} else if (!(stripped.length == 10)) {
		alert("The Home Phone is the wrong length. Make sure you included an area code.");
		return false;
	} 
	
	if(e['email'].value == "") {
		alert('Please fill in the Email field.');
		return false;
	}	
	
  	var apos = e['email'].value.indexOf("@");
  	var dotpos = e['email'].value.lastIndexOf(".");
  	if (apos<1||dotpos-apos<2) {
		alert('Please enter a valid Email address.');
		return false;
	}
	

	
	return true;
}