function validEmail(email) {
			invalidChars = " /:,;";
			if (email == "") {	
				return false;
			}
			for (i=0; i<invalidChars.length; i++) {	
				badChar = invalidChars.charAt(i);
				if (email.indexOf(badChar,0) > -1) {
					return false;
				}
			}
			atPos = email.indexOf("@",1);
			if (atPos == -1) {
				return false;
			}
			if (email.indexOf("@",atPos+1) != -1) {	
				return false;
			}
			periodPos = email.indexOf(".",atPos);
			if (periodPos == -1) {		
				return false;
			}
			if (periodPos+3 > email.length)	{		
				return false;
			}
			return true;
		}

function isNum(passedVal) {
	if (passedVal == "") {
		return false;
	}
	for (i=0; i<passedVal.length; i++) {
		if (passedVal.charAt(i) < "0") {
			return false;
		}
		if (passedVal.charAt(i) > "9") {
			return false;
		}
	}
	return true;
}

function validNum(inZip) {
	if (inZip == "") {
		return true;
	}
	if (isNum(inZip)) {
		return true;
	}
	return false;
} 

function validForm(theform) {

	if (THETEXT.innerHTML == "") {
		alert("Please enter a profile")
		return false
	}else{
		theform.profile.value = THETEXT.innerHTML;
	}

	if (theform.ORGANISATION_NAME.value == "") {
		alert("Please enter a organisation name");
		theform.ORGANISATION_NAME.focus();
		return false;
	}
	
	if (theform.VOLUNTEER_COORDINATOR.value == "") {
		alert("Please enter a volunteer coordinator");
		theform.VOLUNTEER_COORDINATOR.focus();
		return false;
	}
	
	
	if (theform.STREET_ADDRESS_1.value == "") {
		alert("Please enter a street address");
		theform.STREET_ADDRESS_1.focus();
		return false;
	}

   SUBURB_ID = theform.SUBURB_ID.selectedIndex
	if (theform.SUBURB_ID.options[SUBURB_ID].value == "") {
		alert("Please enter a suburb");
		theform.SUBURB_ID.focus();
		return false;
	}
	if (theform.POSTCODE.value == "") {
		alert("Please enter a postcode");
		theform.POSTCODE.focus();
		return false;
	}
	if (theform.PHONE_NUMBER.value == "") {
		alert("Please enter a phone number");
		theform.PHONE_NUMBER.focus();
		return false;
	}
	if (theform.EMAIL.value == "") {
		alert("Please enter an email");
		theform.EMAIL.focus();
		return false;
	}

	ORGANISATION_CATEGORY_ID = theform.ORGANISATION_CATEGORY_ID.selectedIndex;
	if (theform.ORGANISATION_CATEGORY_ID.options[ORGANISATION_CATEGORY_ID].value == "") {
		alert("Please enter a organisation category");
		theform.ORGANISATION_CATEGORY_ID.focus();
		return false;
	}
	if (theform.USERNAME.value == "") {
		alert("Please enter a username");
		theform.USERNAME.focus();
		return false;
	}
	if (theform.PASSWORD.value == "") {
		alert("Please enter a password");
		theform.PASSWORD.focus();
		return false;
	}
	if (theform.PROFILE.value == "") {
		alert("Please enter a profile");
		theform.PROFILE.focus();
		return false;
	}
	if (!validNum(theform.POSTCODE.value)) {
		alert("You must enter a number.  No spaces, hyphens etc are allowed");
		theform.POSTCODE.focus();
		theform.POSTCODE.select();
		return false;
	}
	if (!validEmail(theform.EMAIL.value)) {
						alert("Invalid E-mail Address");
						theform.EMAIL.focus();
						theform.EMAIL.select();
						return false;
	}
	return true
}
