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 == "txtName"){
					customStrCheck(fieldName,1,'your name');
				}else if(theFieldName == "txtEmail"){
					emailCheck(fieldName);
				}
				else if(theFieldName == "Firstname"){
					strCheck(fieldName,1,'your first name');
				}
				else if(theFieldName == "AccNum"){
					customStrCheck(fieldName, 6, 'Account Number');
				}
				else if(theFieldName == "TagNum"){
					customNumCheck(fieldName, 7, 10, 'Tag Number');
				}
				else if(theFieldName == "myPostcode"){
					numCheck(fieldName,4,'your Postcode');
				}
				else if(theFieldName == "Lastname"){
					strCheck(fieldName,1,'your last name');
				}
				else if(theFieldName == "AccName"){
					strCheck(fieldName,1,'your account name');
				}
				else if(theFieldName == "myAddress"){
					strCheck(fieldName,1,'your address');
				}
				else if(theFieldName == "mySuburb"){
					strCheck(fieldName,1,'your suburb');
				}
				else if(theFieldName == "Address1"){
					strCheck(fieldName,1,'your address');
				}
				else if(theFieldName == "Address"){
					strCheck(fieldName,1,'your address');
				}
				else if(theFieldName == "Suburb"){
					strCheck(fieldName,1,'your suburb');
				}
				else if(theFieldName == "State"){
					strCheck(fieldName,1,'your state');
				}
				else if(theFieldName == "Postcode"){
					numCheck(fieldName,4,'your Postcode');
				}
				else if(theFieldName == "Email"){
					emailCheck(fieldName);
				}
				else if(theFieldName == "tagNumber"){
					customNumCheck(fieldName, 7, 10, 'Tag Number');
				}
				else if(theFieldName == "AccNumber"){
					customStrCheck(fieldName, 6, 'Account Number');
				}
				//check for the change details page
				else if(theFieldName == "famName2"){
					strCheck(fieldName,1,'your family name');
				}
				else if(theFieldName == "givenName2"){
					strCheck(fieldName,1,'your given name');
				}
				else if(theFieldName == "Address2"){
					strCheck(fieldName,1,'your location address');
				}
				else if(theFieldName == "Suburb2"){
					strCheck(fieldName,1,'your suburb');
				}
				else if(theFieldName == "Postcode2"){
					isNumCheck(fieldName,'your postcode');
				}
				else if(theFieldName == "Email2"){
					emailCheck(fieldName);
				}
				else if(theFieldName == "homePhone2"){
					isNumCheck(fieldName,'your home phone number');
				}
				//check for the violations page 
				else if(theFieldName == "AccNumViolations"){
					if(formName.CardNumViolations.value.length < 1)
					{
						customStrCheck2(fieldName, 6, 'Account Number');
					}
				}
				else if(theFieldName == "CardNumViolations"){
					if(formName.AccNumViolations.value.length < 1)
					{
						customNumCheck2(fieldName, 7, 12, 'Tag or Card Number');
					}
				}
				else if(theFieldName == "NameViolations"){
					strCheck(fieldName,1,'your name');
				}
				else if(theFieldName == "myYearViolations"){
					isNumCheck(fieldName,'a valid travel date');
				}
				else if(theFieldName == "myTimeViolations"){
					timeCheck(fieldName);
				}
				else if(theFieldName == "VehicleTypeViolations"){
					strCheck(fieldName,1,'the vehicle type');
				}
				else if(theFieldName == "RegNumViolations"){
					strCheck(fieldName,1,'the registration number');
				}
				else if(theFieldName == "TollAmtViolations"){
					isNumCheck(fieldName,'the toll amount');
				}
				else if(theFieldName == "phoneViolations"){
					numCheck(fieldName,10,'Phone');
				}
				else if(theFieldName == "BeepsHeardViolations"){
					isEmptyCheck(fieldName,1, 'reason or the number of beeps heard');
				}
				//EWay Registration Number
				else if(theFieldName == "vchAcctNo"){
					isEmptyCheck3(fieldName,6,'E-way Account number');
				}else if(theFieldName == "vchEmail"){
					emailCheck(fieldName);
				}else if(theFieldName == "vchConfirmEmail"){
					confirmemailCheck2(fieldName,formName.vchEmail);
				}else if(theFieldName == "vchRegNoCar_1"){
					numOfCar = frm.numOfCar.value;
					compareNumber = 1;
					for(i=1; i <= numOfCar; i++)
					{
						vchRegNoCar = 'vchRegNoCar_' + i;
						isEmptyCheck2(eval("frm."+ vchRegNoCar + ".name"),1,'vehicle ' + i + ' registration number');
					}
				}
				
				break;
 	  
			case 'select-one':
				if(theFieldName == "State"){
					selectCheck(fieldName, "a State") 
				}
				else if(theFieldName == "myState"){
					selectCheck(fieldName, "a State") 
				}
				//check for the change details page
				else if(theFieldName == "title2"){
					selectCheck(fieldName, "your Title") 
				}
				else if(theFieldName == "myState2"){
					selectCheck(fieldName, "your State") 
				}
				//check for the violations page
				else if(theFieldName == "TagIssuer"){
					selectCheck(fieldName, "a tag issuer") 
				}
				else if(theFieldName == "myDayViolations"){
					selectCheck(fieldName, "a valid travel date") 
				}
				else if(theFieldName == "myMonthViolations"){
					selectCheck(fieldName, "a valid travel date") 
				}
				else if(theFieldName == "MotorwayViolations"){
					selectCheck(fieldName, 'the motorway');
				}else if(theFieldName == "vchStateCar_1"){
					numOfCar = frm.numOfCar.value;
					for(i=1; i <= numOfCar; i++)
					{
						vchStateCar = 'vchStateCar_' + i;
						selectCheck2(eval("frm."+ vchStateCar + ".name"), 'vehicle ' + i + ' state of registration');
					}
				}
				else if(theFieldName == "dtRegDayCar_1"){
					numOfCar = frm.numOfCar.value;
					for(i=1; i <= numOfCar; i++)
					{
						dtRegDayCar = 'dtRegDayCar_' + i;
						selectCheck2(eval("frm."+ dtRegDayCar + ".name"), 'vehicle ' + i + ' registration commencement day');
					}
				}
				else if(theFieldName == "dtRegMonthCar_1"){
					numOfCar = frm.numOfCar.value;
					for(i=1; i <= numOfCar; i++)
					{
						dtRegMonthCar = 'dtRegMonthCar_' + i;
						selectCheck2(eval("frm."+ dtRegMonthCar + ".name"), 'vehicle ' + i + ' registration commencement month');
					}
				}

				else if(theFieldName == "dtRegYearCar_1"){
					numOfCar = frm.numOfCar.value;
					for(i=1; i <= numOfCar; i++)
					{
						dtRegYearCar = 'dtRegYearCar_' + i;
						selectCheck2(eval("frm."+ dtRegYearCar + ".name"), 'vehicle ' + i + ' registration commencement year');
					}
				}

				break;
	  
			case 'textarea':
				if(theFieldName == 'commentArea'){
					strCheck(fieldName,1,'your comment');   
				}
				break;
	  
			case 'password':
				/*
				if(theFieldName == 'default_password123'){
					isChecked(fieldName, 'default_password');
				}
				*/
			break;
	  	  
			case 'radio':
				if(theFieldName == 'comment'){
					isChecked(fieldName, 'Please select one of the comment type');
					if (formName.elements["comment"][4].checked)
					{
						strCheck(formName.elements["comment_other"], 1, 'the other type comment');
					}
				}
				else if(theFieldName == 'country'){
					isChecked(fieldName, 'Please select your the country');
					if (formName.elements["country"][2].checked)
					{
						strCheck(formName.elements["country_other"], 1, 'the other country');
					}
				}
				else if(theFieldName == 'product'){
					if (formName.elements["product"][6].checked)
					{
						strCheck(formName.elements["product_other"], 1, 'the other product');
					}
				}
				break;
	  
			case 'checkbox':
				//checking for change details
				if(theFieldName == 'acknowledgement2'){
					singleCheckValidation(fieldName);
				}
				else if(theFieldName == 'finalTNC'){
					singleCheckValidation(fieldName);
				}
				/*
				if(theFieldName == 'default_radio123'){
					isChecked(fieldName, 'default_radio');
				}
				*/		
			break;

		}
		if(ValidOk == false){
			return false;
	  		break;
		}
		count++;
	}
	
	if (ValidOk == true){
		//return true;
		formName.submit();
	}	
}
