//
// functions called on submit to validate
//
function validatefields(){

 // just going to do normal js validation on submit
 // need to grab lang and use field labels
// alert(document.forms['ectForm'].subject.value);

var  valid=1;
var feedbackSr="Please complete the following fields: ";

 if (document.forms['fwpClubsForm'].fwpClubsForm_name.value=="")
	 {
		document.getElementById('reqName').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqName').style.color = '#000000' ;
	}

 if (document.forms['fwpClubsForm'].fwpClubsForm_school.value=="")
	 {
		document.getElementById('reqSchool').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqSchool').style.color = '#000000' ;
	}

 if (document.forms['fwpClubsForm'].fwpClubsForm_address.value=="")
	 {
		document.getElementById('reqAddress').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqAddress').style.color = '#000000' ;
	}
	
 if (document.forms['fwpClubsForm'].fwpClubsForm_townCity.value=="")
	 {
		document.getElementById('reqTown').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqTown').style.color = '#000000' ;
	}


 if (document.forms['fwpClubsForm'].fwpClubsForm_postCode.value=="")
	 {
		document.getElementById('reqPostCode').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqPostCode').style.color = '#000000' ;
	}
	
  if (document.forms['fwpClubsForm'].fwpClubsForm_emailAddress.value=="")
	 {
		document.getElementById('reqEmail').style.color = '#ffffff' ;
	 	valid=0;
	}else{
		document.getElementById('reqEmail').style.color = '#000000' ;
	}


		
	
if(valid==0){
	alert ("Please complete all required fields.");
	return false;
}else{

	 if (!validateEmail(document.forms['fwpClubsForm'].fwpClubsForm_emailAddress.value))
	 {
	 		alert ("Please enter a valid email address.");
	return false;
	}else{
		// alert ("this would have sent if I'd enabled the script....");
		return true;
	}
}

}

function validateEmail(str) {
		
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		     return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		  
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		  
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		  
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		  
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		  
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		  
		    return false
		 }

 		 return true					
}
// -->