
function validateOnSubmit() {
 var elem;
 var errs = 0;

 if (!validatePresent(document.forms.signup.vpassword, 'errorVpass')) errs += 1;  
 if (!validatePresent(document.forms.signup.password, 'errorPassword')) errs += 1;  
 
 
if (validatePresent(document.forms.signup.nickname,'errorNickname')){
}
else {
	errs +=1;
}
if (validateEmail  (document.forms.signup.email, 'errorEmail', true)){
}
else {
	errs +=1;
} 


 if (!validatePresent(document.forms.signup.lname,  'errorLname')) errs += 1; 
 if (!validatePresent(document.forms.signup.fname,  'errorFname')) errs += 1; 



 if (errs > 1)  alert('There are fields which need correction before sending');
 if (errs == 1) alert('There is a field which needs correction before sending');

 if (errs == 0) {
	 if (document.forms.signup.email.value != document.forms.signup.vemail.value){
		alert("Please make sure the verification address matches your email address!");
		setfocus(document.forms.signup.vemail);
		errs = 1;
	 }
 }


 if (errs == 0) {
	 if (document.forms.signup.password.value != document.forms.signup.vpassword.value){
		alert("Passwords do not match, try again.");
		setfocus(document.forms.signup.vpassword);
		errs = 1;
	 }
 }
  
 
if (errs == 0) {

	if (document.getElementById('validnick').value != "1"){

		if (validatePresent(document.forms.signup.nickname,'errorNickname')){ 
			alert("Please choose a different nickname");
			errs += 1;
		} 	
	}
}

if (errs == 0) {

	if (!document.forms.signup.tos.checked){

		alert("You must agree to the Terms of Service");
		errs += 1;

	}

}

 return (errs == 0);
};
