function emailCheck(emailaddr) {
var s=/^(.+)@(.+)\.(.+)$/;
if (emailaddr.match(s)==null) {       
	return false;       
}
return true;
}

// phone number - strip out delimiters and check for 10 digits

function checkPhone (strng) {

var stripped = strng.replace(/[\(\)\.\-\ ]/g, ''); //strip out acceptable non-numeric characters
	if (isNaN(parseInt(stripped))) {
	   return false; 
	}
	if (!(stripped.length == 10)) {
		return false; 
	} 		
return true;
}	

function frmValidate(theForm) {	
	if (theForm.first_name.value == "") {
		alert("First Name is a required field.");
		theForm.first_name.focus();
		return(false);
	}
	
	if (theForm.last_name.value == "") {
		alert("Last Name is a required field.");
		theForm.last_name.focus();
		return(false);
	}
	if (theForm.company.value == "") {
		alert("Company is a required field.");
		theForm.company.focus();
		return(false);
	}
	if (theForm.title.value == "") {
		alert("Title is a required field.");
		theForm.title.focus();
		return(false);
	}
	if (theForm.phone.value == "") {
		alert("Phone is a required field.");
		theForm.phone.focus();
		return(false);
	}
	if (!(checkPhone(theForm.phone.value))) {
		alert("Please enter a valid 10 digit numeric day phone number.");
		theForm.phone.focus();
		return(false);
	}			
	if (theForm.email.value == "") {
		alert("Email address is a required field.");
		theForm.email.focus();
		return(false);
	}
	if (!(emailCheck(theForm.email.value))) {
		alert("Please enter a valid email address.  Example: 'yourname@company.com'.");
		theForm.email.focus();
		return(false);
	}
	if (theForm.No_Employees.value == "") {
		alert("Number of Employees is a required field.");
		theForm.No_Employees.focus();
		return(false);
	}
	if (theForm.Top_IT_Initiatives.value == "") {
		alert("Top IT Initiatives is a required field.");
		theForm.Top_IT_Initiatives.focus();
		return(false);
	}		

	//theForm.retURL.value = "http://www.evergreensys.com/downloads/thankyou.php?download_id="+theForm.download_id.value+"&track_id=" + theForm.email.value;		
	theForm.retURL.value = theForm.retURL.value+"&track_id=" + theForm.email.value;		
}
