

//----- Contact Form Validation -----------//
// checks the first name, last name, phone
// number, organization and email address
function checkContactForm(theForm) {
	var emailObject = document.getElementById("email");
	emailObject.value = trim(emailObject.value);
	var firstName = document.getElementById("middleName");
	firstName.value = trim(firstName.value);
	var lastName = document.getElementById("lastName");
	lastName.value = trim(lastName.value);
	 
	if (firstName.value.length == 0) {
		alert("Please enter your first name.");
		firstName.focus();
		return false;
	} else if (lastName.value.length == 0) {
		alert("Please enter your last name.");
		lastName.focus();
		return false;
	} else if (emailObject.value.length == 0) {
		alert("Please enter your email address.");
		emailObject.focus();
		return false;
	} else if (!checkemail(emailObject.value)) {
		alert("Please check your email address for errors.");
		emailObject.focus();
		return false;
	} else {
		alert("Submission CONTACT Good");
		//theForm.submit();
		return true;
	}
}


//----- Validate Email Addresses -----------//
// checks for valid looking email addy
function checkemail(str){
	var filter=/^.+@.+\..{2,3}$/;	
	return (filter.test(str));
}



//----- Trim White Space -----------//
//trim whitespace for validation
function trim(s){
	if((s==null)||(typeof(s)!='string')||!s.length)return'';return s.replace(/^\s+/,'').replace(/\s+$/,'')
}



//----- Open New Window -----------//
//Open a new window with specific width/height/location 
function openWindow(location, width, height) {		
	newWidth = width + 20;
	newHeight = height + 20;
	widthHeight = "width=" + newWidth + ",height=" + newHeight;
	window.open(location,"",widthHeight);		
}