/* VFORM.JS - SANTACRUZEXPEDITIONS */

/* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/) */
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Adress!")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Adress!")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Adress!")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Adress!")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Adress!")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Adress!")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Adress!")
		    return false
		 }

 		 return true					
	}

function validateForm() {

var eml = document.contact.email;
var emailID = document.contact.email.value;

if(document.contact.title.value == '') {
alert("Please select a valid title from the list.");
document.contact.title.focus();
return false;
}
if(document.contact.surname.value == '') {
alert("You must enter your Surname.");
document.contact.surname.focus();
return false;
}
if(document.contact.givenname.value == '') {
alert("You must enter your first name.");
document.contact.givenname.focus();
return false;
}
if((emailID == null) || (emailID == '')) {
alert("Please enter your email address.");
eml.focus();
return false;
}
if (echeck(emailID) == false) {
eml.value=""
eml.focus()
return false
}
if(document.contact.heard_how.value == '') {
alert("Please select how you heard about us from the list.");
document.contact.heard_how.focus();
return false;
}
if(document.contact.moreinfo.value == '') {
alert("Please select an option from the More Info list.");
document.contact.moreinfo.focus();
return false;
}
return true;
}//end func