// validate catalog request form
function ValidateGroupContact() {
	var emailID=document.group_contact.email;
	var emailcheck=document.group_contact.email.value;
	
	//student validation
	// first name	
	if (document.group_contact.firstName.value=="") {
		document.group_contact.firstName.focus();
		alert('Please enter a first name.');
		return false; 
	}
	// last name	
	if (document.group_contact.lastName.value=="") {
		document.group_contact.lastName.focus();
		alert('Please enter a last name.');
		return false; 
	}
	// school
	if (document.group_contact.school.value=="") {
		document.group_contact.school.focus();
		alert('Please enter an organization or school.');
		return false; 
	}
	// city
	if (document.group_contact.city.value=="") {
		document.group_contact.city.focus();
		alert('Please enter a city.');
		return false; 
	}
	// state
	if (document.group_contact.state.value=="") {
		document.group_contact.state.focus();
		alert('Please select a state.');
		return false; 
	}
	// home phone1
	if (document.group_contact.phoneHome1.value=="") {
		document.group_contact.phoneHome1.focus();
		alert('Please enter a home phone number.');
		return false;
	}
	// home phone2
	if (document.group_contact.phoneHome2.value=="") {
		document.group_contact.phoneHome2.focus();
		alert('Please enter a home phone number.');
		return false;
	}
	// home phone3
	if (document.group_contact.phoneHome3.value=="") {
		document.group_contact.phoneHome3.focus();
		alert('Please enter a home phone number.');
		return false;
	}
	// email
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter an email address.")
		emailID.focus()
		return false;
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false;
	}
	// participants
	if (document.group_contact.participants.value=="") {
		document.group_contact.participants.focus();
		alert('Please the number of participants.');
		return false;
	}
	// starting age
	if (document.group_contact.startAge.value=="") {
		document.group_contact.startAge.focus();
		alert('Please enter the age range of participants.');
		return false;
	}
	// end age
	if (document.group_contact.endAge.value=="") {
		document.group_contact.endAge.focus();
		alert('Please enter the age range of participants.');
		return false;
	}
	return true
}

// email validation
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 email address")
	   return false
	}
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("Invalid E-mail")
	   return false
	}
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    alert("Invalid E-mail")
	    return false
	}
	 if (str.indexOf(at,(lat+1))!=-1){
	    alert("Invalid E-mail")
	    return false
	 }
	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    alert("Invalid E-mail")
	    return false
	 }
	 if (str.indexOf(dot,(lat+2))==-1){
	    alert("Invalid E-mail")
	    return false
	 }
	 if (str.indexOf(" ")!=-1){
	    alert("Invalid E-mail")
	    return false
	 }
 	 return true
}