function formCheck(formName){
  ValidOk = true;
  var count = 0;
  while(count < formName.elements.length){
    var fieldType = formName.elements[count].type;
    var theFieldName = formName.elements[count].name;
    var fieldName = formName.elements[formName.elements[count].name];
	switch(fieldType){
	  case 'text':
	    if(theFieldName == 'ABN'){
	  	  numCheck(fieldName,11,'ABN number');
		}else if(theFieldName == 'address'){
		  strCheck(fieldName,2,'address');
		//}else if(theFieldName == 'company'){
		  //strCheck(fieldName,1,'company');
		}else if(theFieldName == 'email'){
	  	  emailCheck(fieldName,'email address');
		}else if(theFieldName == 'VerifyEmail'){
			confirmemailCheck(fieldName, formName.email);  
		}else if(theFieldName == 'firstName'){
	      strCheck(fieldName,2,'first name');
		}else if(theFieldName == 'Title'){
	      strCheck(fieldName,2,'Title');
		}else if(theFieldName == 'invoiceNumber'){
	  	  alphaNumericCheck(fieldName,5,'invoice number');
		}else if(theFieldName == 'lastName'){
	  	  strCheck(fieldName,2,'last name');
		}else if(theFieldName == 'surname'){
	  	  strCheck(fieldName,2,'surname');
		}else if(theFieldName == 'name'){
	  	  strCheck(fieldName,2,'name');  
		}else if(theFieldName == 'position'){
	  	  strCheck(fieldName,2,'position held');
		}else if(theFieldName == 'suburb'){
	  	  strCheck(fieldName,2,'suburb');
		}else if(theFieldName == 'surname'){
	  	  strCheck(fieldName,2,'surname');
		}else if(theFieldName == 'storeName'){
	  	  strCheck(fieldName,4,'store name');  
		}else if(theFieldName == 'phone'){
	  	  phoneCheck(fieldName);
		}else if(theFieldName == 'postCode'){
	  	  numCheck(fieldName,4,'post code');
		}else if(theFieldName == 'Keyword'){
	  	  strCheck(fieldName,2,'keyword. (min 2 characters)');
		}else if(theFieldName == 'token'){
	  	  dualNumCheck(fieldName,8,13,'token number');
		}else if(theFieldName == 'userName'){
	  	  strCheck(fieldName,7,'User ID');
		}else if(theFieldName == 'locationpurchased'){
	  	  strCheck(fieldName,1,'purchased address');
		}else if(theFieldName == 'suburbpurchased'){
	  	  strCheck(fieldName,1,'purchased surburb');
		}else if(theFieldName == 'postcodepurchased'){
	  	  numCheck(fieldName,4,'purchased postcode'); 
		//}else if(theFieldName == 'year'){
	  	//numCheck(fieldName,4,'year');
		}else if(theFieldName == 'keyword'){
	  	  strCheck(fieldName,1,'keyword');
		}else if(theFieldName == 'Description'){
	  	  strCheck(fieldName,1,'description');
		}else if(theFieldName == 'Link'){
	  	  strCheck(fieldName,1,'link');
		}else if(theFieldName == 'ModelName'){
	  	  strCheck(fieldName,1,'Model Name');
		}else if(theFieldName == 'vchTitle'){
	  	  strCheck(fieldName,1,'title');
		}
	  break;
	  case 'radio':
	    if(theFieldName == 'gender'){
	     genderCheck(fieldName,'Please select a gender');
		}else if(theFieldName == 'userManage'){
	      radioCheck(fieldName,'Please select an option');
		}else if(theFieldName == 'principal'){
	      radioCheck(fieldName,'Please select an option');
		}else if(theFieldName == 'dealer'){
	      dealerCheck(formName,fieldName,'Please select an option');
		}
	  break;
	  case 'select-one':
	    if(theFieldName == "state"){
	      selectboxCheck(fieldName,'Please select a state.');
	    }else if(theFieldName == 'day'){
	      dateChecker(formName);
	    }else if(theFieldName == "year"){
	      selectboxCheck(fieldName,'Please select a year.');
		}else if(theFieldName == 'title'){
	      selectboxCheck(fieldName,'Please select a title.');
		}else if(theFieldName == 'ProductModel'){
	      selectboxCheck(fieldName,'Please select a model.');
		}else if(theFieldName == 'ProductID'){
	      selectboxCheck(fieldName,'Please select a product model.');
		}else if(theFieldName == 'ProductTypeID'){
	      selectboxCheck(fieldName,'Please select a product type.');
		}else if(theFieldName == 'Model'){
	      selectboxCheck(fieldName,'Please select a product model.');
		}else if(theFieldName == 'Search_Table'){
	      selectboxCheck(fieldName,'Please select a Section.');
		}else if(theFieldName == 'SubSection'){
	      selectboxCheck(fieldName,'Please select a subsection.');
		}else if(theFieldName == 'daypurchased'){
	      selectboxCheck(fieldName,'Please select the day of purchase.');
		}else if(theFieldName == 'monthpurchased'){
	      selectboxCheck(fieldName,'Please select the month of purchase.');
		}else if(theFieldName == 'yearpurchased'){
	      selectboxCheck(fieldName,'Please select the year of purchase.');
		}else if(theFieldName == 'statepurchased'){
	      selectboxCheck(fieldName,'Please select the state where you buy your product.');
		}else if(theFieldName == 'title'){
	      selectboxCheck(fieldName,'Please select your title.');
		}else if(theFieldName == 'FAQCategory'){
	      selectboxCheck(fieldName,'Please select a category.');
		}else if(theFieldName == 'Sub_Category'){
	      selectboxCheck(fieldName,'Please select a category.');
		}else if(theFieldName == 'optProductCat'){
	      selectboxCheck(fieldName,'Please select a product category.');
		}else if(theFieldName == 'optFromSite'){
	      selectboxCheck(fieldName,'Please select which site you came from');
		}else if(theFieldName == 'ddl_category'){
	      selectboxCheck(fieldName,'Please select a product category.');
		}else if(theFieldName == 'ddl_subcategory'){
	      selectboxCheck(fieldName,'Please select a product subcategory.');
		}
		
	  break;
	  case 'textarea':
	    if(theFieldName == "enquiry"){
	      strCheck(fieldName,1,'enquiry');
		}else if(theFieldName == "message"){
		  strCheck(fieldName,1,'comment');
		}
	  break;	  
	  case 'checkbox':
	    if(theFieldName == 'something'){
		  //you can define by name or index
		  //with the select 
		  //selectFieldName = formName.elements[formName.elements['typeOfSubscription'].name];
		  selectFieldName = formName.elements[formName.typeOfSubscription.name];
		  //selectFieldName = formName.elements[formName.elements[count + 1].name];
	      checkboxDropdownCheck(fieldName,selectFieldName,"Please select a way of subscribing");
		}
	  break;
	  case 'password':
	    if(theFieldName == 'password'){
	      passwordCheck(fieldName,6,20,'Please enter your valid password');
		}else if(theFieldName == 'newPassword'){
	      passwordCheck(fieldName,6,20,'Please enter a valid password');  
		}else if(theFieldName == 'newPassword1'){
	      passMatch(formName,fieldName,'passwords do not match');  
		}
	  break;
	  case 'hidden':
	    if(theFieldName == 'dateCheck'){
	      dateCheck(formName,'Please enter a valid date');
		}
	  break;	  
	}
	if(ValidOk == false){
	  break;
	}
	count++;
  }
  if (ValidOk == true){
    formName.submit();
  }
}
