var numCategoriesSelected=0;
	
function validateForm() {

	var errorFlag=0;
	var errorMessage="";

	if(document.form1.organizationEmail) {
		document.form1.organizationEmail.value=trim(document.form1.organizationEmail.value);
	}
	
	document.form1.password1.value=trim(document.form1.password1.value);
	document.form1.password2.value=trim(document.form1.password2.value);
	document.form1.city.value=trim(document.form1.city.value);
	document.form1.stateID.value=trim(document.form1.stateID.value);
	document.form1.zipCode.value=trim(document.form1.zipCode.value);

	//Check the organizationEmail field (if the field exists on this form)
	if(document.form1.organizationEmail && (document.form1.organizationEmail.value=="" || document.form1.organizationEmail.value.indexOf("@")==-1)) {
		errorMessage+="<li>Enter your work email address.</li>";
		errorFlag=1;
	}

	//Make sure they aren't using a disallowed email domain
	if(document.form1.organizationEmail && document.form1.organizationEmail.value.indexOf("@")>-1) {
		
		var theirEmailDomain=document.form1.organizationEmail.value.substring(document.form1.organizationEmail.value.indexOf("@")+1,document.form1.organizationEmail.value.length);

		if(isDisallowedEmailDomain(theirEmailDomain)) {
			errorMessage+="<li>Use your work email address, not a web-based email address like <span style='color:blue;'>" + theirEmailDomain + "</span>.</li>";
			errorFlag=1;
		}
		
	}

	//Check the password fields
	if((document.form1.password1.value=="" || document.form1.password2.value=="") && document.form1.isPasswordRequired.value==1) {
		errorMessage+="<li>Enter a password and then confirm it.</li>";
		errorFlag=1;
	}
	
	//Check the password fields
	if((document.form1.password1.value!="" && document.form1.password2.value!="") && (document.form1.password1.value!=document.form1.password2.value)) {
		errorMessage+="<li>Enter your password and then confirm it (they didn't appear to match).</li>";
		errorFlag=1;
	}
	
	//Check the city field
	if(document.form1.city.value=="") {
		errorMessage+="<li>Enter your city.</li>";
		errorFlag=1;
	}
	
	//Check the state field
	if(document.form1.stateID.value=="") {
		errorMessage+="<li>Enter your state.</li>";
		errorFlag=1;
	}
	
	//Check the zipCode field
	if(document.form1.zipCode.value=="") {
		errorMessage+="<li>Enter your zip code.</li>";
		errorFlag=1;
	}

	if(errorFlag==1) {
		document.getElementById("errorList").innerHTML="<ul>"+errorMessage+"</ul>";
		document.getElementById("errorDiv").style.display="";
		window.scrollTo(0,0);
		return false;
	} else {
		document.getElementById("errorList").innerHTML="";
		document.getElementById("errorDiv").style.display="none";
		return true;
	}
	
}

function isDisallowedEmailDomain(theirEmailDomain) {

	var disallowedEmailDomains=new Array("yahoo.com","yahoomail.com","gmail.com","hotmail.com","aol.com","juno.com","msn.com","gawab.com","zenbe.com","fastmail.com");

	for(var i=0;i<disallowedEmailDomains.length;i++) {
		if(disallowedEmailDomains[i]==theirEmailDomain) {
			return true;
		}
	}

	return false;
}