function checkFields(){

var theform = document.forms[0]

for(i=0; i<theform.elements.length; i++){
		var field = theform.elements[i]
		var email = theform.email.value;
		var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
		var address = email;
		if(reg.test(address) == false) {
		  alert('Invalid Email Address');
		  return false;
		}
		//alert(theform.elements[i].type)
		var isReq = (field.name.charAt(0)=="*") ? true : false

		
			if((field.type=="text" || field.type=="textarea" || field.type=="password") && field.value==""){
			alert("Please fill in the '"+field.name+ "' field.")
			setTimeout("document.forms[0].elements["+i+"].focus()", 10)
			return false
			}
			
			if(field.type=="select-one" && field.selectedIndex == 0){	
			alert("Please select a value for the '"+field.name+ "' field.")
			setTimeout("document.forms[0].elements["+i+"].focus()", 10)
			return false
			}
			
			if(field.type=="select-multiple"){	
			Sel=0
				for(o=0; o<field.options.length; o++){
					if(field.options[o].selected){
					Sel++
					break
					}
				}
				if(Sel == 0){
				alert("Please select a value for the '"+field.name+ "' field.")
				setTimeout("document.forms[0].elements["+i+"].focus()", 10)
				return false
				}			
			}
			
			if(field.type=="checkbox" || field.type=="radio"){
			var startingIndex = i	
			var Checked = 0
			var rLength=1
				while(field.type == theform.elements[i+1].type){
				rLength++
				i++ 
				}
				
				for(g = startingIndex; g < rLength+startingIndex; g++){
					if(theform.elements[g].checked){
					Checked++
					break
					}
				}		
				//if(Checked == 0){
				//i=startingIndex
				//alert("Please select a value for the '"+field.name+ "' "+field.type+" group")				
				//setTimeout("document.forms[0].elements["+i+"].focus()", 10)
				//return false
				//}
			}
	  
	}//for
	submitForm();
}
function submitForm()
{
  document.forms[0].submit();
}
