function formValidation(oForm) {
	
	var doSubmit = true;
	
	for(var i = 0; i < oForm.length; i++) {
		
		var oE = oForm[i];
		
		if(checkClass(oE, "required")) {
			
			if(oE.type == "text" || oE.type == "textarea") {
				if(oE.value == "") { setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
			else if(oE.type == "checkbox" || oE.type == "radio") {
				
				var aE = oForm[oE.name];
				
				var checked = false;
				
				if(aE.length) {
					for(var j = 0; j < aE.length; j++) {
						checked = (checked || aE[j].checked);
					}
				}
				else { checked = aE.checked; }
				if(!checked) { setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
		}
		
		// start todo
		if(checkClass(oE, "regemail")) {
			if(oE.value != "" && !oE.value.search(/^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i) == 0) { setError(oE, 0); doSubmit = false; }
			else if(!(checkClass(oE, "required") && oE.value == "")) { setError(oE, 1); }
		}
		
		if(checkClass(oE, "regzip")) {
			if(oE.value != "" && !oE.value.search(/^[1-9][\d]{3}[A-Z]{2}$/) == 0) { setError(oE, 0); doSubmit = false; }
			else if(!(checkClass(oE, "required") && oE.value == "")) { setError(oE, 1); }
		}
		// end todo
		
	}
	
	if (doSubmit == false) {
		document.getElementById("message").style.display = "block";
	}
	
	return doSubmit;
}

function checkClass(oE, className) {
	if(oE.className && oE.className.match(new RegExp('\\b'+className+'\\b'))) return true;
	return false;
}

function setError(oE, ok) {
	document.getElementById("label_" + oE.getAttribute('name')).style.color = ok ? "" : "red";
}
