function submitIt( theForm ){

var submitOnly = 'false';

		if(arguments.length > 1){
			if(arguments[1]=='submitOnly'){
				submitOnly = 'true';
			}
				  
		}



var Pattern = new Object();

Pattern.email =/^[-_\.\w]{1,20}[@][-\w]{1,30}[.]\w{1,3}/;    // email

//add extra regular expressions here
			
			var submitOk = "true";
			var endLength = theForm.length;
			
			for(i=0; i< endLength; i++){
					//get the attributes necessary for validation
					var thisItem = theForm[i].id;
					
					var theName = theForm[i].name;
					
					var required = theForm[i].getAttribute("required");
					
					var mirror = theForm[i].getAttribute("mirror");
					
					var validator = theForm[i].getAttribute("validator");
					
					var id = theForm[i].getAttribute("id");
					
					var theGroup = theForm[i].getAttribute("group");
					
					var theDisplay = theForm[i].style.display;
					
					var errorName = theForm[i].getAttribute("errorName");
					
					var errorName = errorName ? errorName : thisItem;
					
					//if the value is required, validate that the field contains a value
					//we'll check for the correctness of the value later
					//right now we just need to make sure it exists
				
					
					if((theForm[i].getAttribute("required")=='true') && (theDisplay != "none")){
						
						if( theGroup != null ){
							
								var groupCheck = false;
							
								for(m=0; m < endLength; m++){
									
									var childGroup = theForm[m].getAttribute("group");
	
									if(childGroup == theGroup){
									
										if((theForm[m].value == "")||(((theForm[m].type == "checkbox")||(theForm[m].type == "radio"))&&(theForm[m].checked==false))){
											//do nothing
										}else{
											//it ok to continue because a member of the group has been selected
											var groupCheck = true;
										}
									}	
								}
								
								if(groupCheck==false){
									alert ("Please complete or select one of the " + theGroup + " group"); 
									submitOk = "false";
									break;
								}	
							
						}else{
							//just check that the single element meets the required criteria					
							if((theForm[i].value == "")||((theForm[i].type == "checkbox")&&(theForm[i].checked==false))){
								alert ("Please complete the " + errorName + " field"); 
								submitOk = "false";
								break;
							}
						}
						
					}
					
					
					
					if(theForm[i].value!=""){						
						if (validator == 'creditcard') {
							//do credit card validation here	
						}else if (validator){
							
							var thePat = Pattern[validator];
							var testResult = thePat.exec(theForm[i].value); 
							
							if(testResult==null){
								alert("Please supply a valid " + errorName + " value");
								submitOk = "false";
								break;
							}
						}
					}
					
					if(mirror != null) {
						//alert(mirror);
						// if the mirror exists, it must match the mirrored field.
						// i.e. one field must match another	
						//alert( theForm[i].value + " : match : " + theForm[mirror].value);
						
						if(theForm[i].value != theForm[mirror].value){				
							alert( thisItem + " must match " + theForm[mirror].id);
							submitOk = "false";
							break;
						}
					}					
					
		}

		if(submitOnly == "true"){

			if(submitOk == "true"){
				return true;
			}else{
				return false;
			}
			
		}else{
			
			if(submitOk == "true"){
				theForm.submit();
			}
			
		}
}
		
