
//function to validate by length
function validlength(item, len) {
   return (item.length >= len);
}
//function to validate an email address
function validemail(item) {
   if (!validlength(item, 5)) return false;
   if (item.indexOf ('@', 0) == -1) return false;
   return true;
}
// display an error alert
function error(elem, text) {
// abort if we already found an error
   if (errfound) return;
   window.alert(text);
   elem.select();
   elem.focus();
   errfound = true;
}
// main validation function
function validate_optin() {
   errfound = false;
			if (!validemail(document.optin.email.value))
    			error(document.optin.email,"Sorry, Invalid Email Address!");

   return !errfound; /* true if there are no errors */
}

function validate_contact() {
   errfound = false;
   			if (!validlength(document.contact_form.first_name.value,1))
    			error(document.contact_form.first_name,"Sorry, Invalid Submission.\n\nNo First Name provided.");
			if (!validemail(document.contact_form.email.value))
			   			if (!validlength(document.contact_form.last_name.value,1))
    			error(document.contact_form.last_name,"Sorry, Invalid Submission.\n\nNo Last Name provided.");
			if (!validemail(document.contact_form.email.value))
    			error(document.contact_form.email,"Sorry, Invalid Email Address.\n\nYou might have mistyped your email.");
			if (!validlength(document.contact_form.comments.value,1))
    			error(document.contact_form.comments,"Sorry, Invalid Submission.\n\nNot comments are being provided.");

   return !errfound; /* true if there are no errors */

}
//efface
function efface (elem) {
vers = navigator.appVersion;
proper_version = parseFloat(vers); // pick the number off the front of vers
if (proper_version >3 ){
if (elem.val!=1){
elem.value='';
elem.val=1;
}
}
}