function formValidation(oForm) {
	var doSubmit = true;
	for(var i=0; i<oForm.length; i++){
		var oE = oForm[i]
		if(eval(oE.getAttribute('required'))){
			if(oE.type=="text"){
				if(oE.value == ""){	setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
			if(oE.type=="file"){
				if(oE.value == ""){	setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
			if(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); }
			}
			else if(oE.type=="select-one"){
				if(oE.selectedIndex==0){ setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
			else if(oE.type=="select-multiple"){
				if(oE.selectedIndex==-1){ setError(oE, 0); doSubmit = false; }
				else { setError(oE, 1); }
			}
		}
		if(eval(oE.getAttribute('emailcheck'))){
			var isOK = true;
			var aEmail = oE.value.split("@");
			if(aEmail.length!=2) { isOK = false; }
			else { 
				if(aEmail[0].length<1) { isOK = false; }
				else {
					aEmail = aEmail[1].split(".");
					if(aEmail.length<2) { isOK = false; }
					else{
						for(var z=0; z<aEmail.length; z++){
							if(aEmail[z].length<2) { isOK = false; }
						}
					}
				}
			}
			if(!isOK) { setError(oE, 0); doSubmit = false; }
			else { setError(oE, 1); }			
		}
	}
	return doSubmit;
}

function setError(oFld, ok){
	document.getElementById(oFld.getAttribute('txtspan')).className = ok?null:"required";
}