function checkData(theForm){
	$("#errormsg").remove();
	// Test if DOM is available and there is an element called required
	if(!document.getElementById || !document.createTextNode){return;}

	theFormID	= $(theForm).attr("id");
	prefix		= theFormID.split("_")[1] != "" ? "_"+theFormID.split("_")[1] : "";
	required	= $("#"+theFormID+" #required").val();
	errExists	= false;
	
	if(required!=""){
		// Cleanup old mess
		$(".indicator, p.help, p.error, div#errormsg").remove();
		$(".error").removeClass("error");
		var firstMissing = "";
		var bError = false;
		var f;

		// loop over required fields
		var reqfields = required.split(",");
		for(var i=0;i<reqfields.length;i++){
			// check if required field is there
			f = eval("theForm."+reqfields[i]);
			if(!f){continue;}
			// test if the required field has an error,
			// according to its type
			if(typeof f.type != "undefined"){
				switch(f.type.toLowerCase())
				{
					case "text":
					case "password":
						if(f.value=="" && f.id!="email"){cf_adderr(f)}
						// email is a special field and needs checking
						if(f.id=="email" && !cf_isEmailAddr(f.value)){cf_adderr(f)}
					break;
					case "textarea":
						if(f.value==""){cf_adderr(f)}
					break;
					case "checkbox":
						if(!f.checked){cf_adderr(f)}
					break;
					case "select-one":
						if(!f.selectedIndex && f.selectedIndex==0){cf_adderr(f)}
					break;
				}
			}else{
				// radio does not return type (i think even checkbox does the same) - so let"s use jQuery for them
				var theField = $("input[@name="+reqfields[i]+"]");
				var theFieldVal = $("input[@name="+reqfields[i]+"][@checked]").val();
				if(typeof theFieldVal == "undefined" || theFieldVal == ""){
					$(theField[0]).before(errorIndicator);
					errExists = true;
				}
			}
		}
		if($("#pass").val() != "" && $("#pass1").val() != "" && $("#pass").val() != $("#pass1").val()){
			f = eval("theForm.pass1");
			cf_adderr(f);
		}
	}
	if(errExists){
		$("#"+theFormID)
			.after('<div id="errormsg"><p>Please fix the required fields indicated <img alt="Error" src="/jscripts/images/alert.gif" title="This field has an error!" class="errorIndicator"></p></div>');
		$("#"+firstMissing).focus();
		return false;
	}
}
function cf_adderr(o){
	$(o)
		.addClass(errorClass)
		.before(errorIndicator);
	errExists = true;
}
function cf_isEmailAddr(str){
	return str.match(/^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/);
}

