function displayValidation(theForm,first,boolClearHidden)
{
		validateForm(theForm);
		
	  var formok;    
	  var r=0;
		var ele = document.theForm.elements;
		
		for(var i=0;i<ele.length;i++)
		with(ele[i])
		{

			  var val = ele[i].validator;
			  var FieldState = ele[i].fieldstate;
				if(!val)continue;
  
				/*
	 			// We do not want to validate hidden elements, however there are two cases to consider here:
	 			// 1) If we are in Netscape then the page may well have some or all of the controls in separate layers (divs).
	 			// In this case the base document will have corresponding hidden fields to hold the data from the layer fields for validation.
	 			// Therefore we cannot just test the base document control to see if the type is hidden as this will always be the case for these layered elements.
	 			// The naming convention for these layers is such that the layer name is the element name postfixed with "_CONTROL".
	 			// We rely on this below to check whether the base form element has a corresponding layer element. If it does then we check to see if the layer itself is hidden.
	 			// 2) If the element does not have a corresponding layer element then we are safe to just check the type of the control for hidden.
	 			// N.B. There is one new instance where we need to validate the hidden field and that is dates
	 			// Dates are now concatenated and passed into a hidden field before validation is carried out
	 			// therefore we have to deal with these seperately.	 			
	 			*/

				var divname = ele[i].name + "_CONTROL";
				
				//if ((document.layers) && (document.layers[divname]))
				//{
				//		if (document.layers[divname].hidden) continue;
				//}
				//else
				//{
				if ((ele[i].type == "hidden")&&(ele[i].name != "CL1_DOB_CHECK" && ele[i].name != "CL1_DOB" && ele[i].name != "CL2_DOB" && ele[i].name != "CL1_SECOND_DOB" && ele[i].name != "CL1_ADD_DOB" && ele[i].name != "CL1_PPI_DOB"))continue;
				//}
  
				var valResult;
				var fieldstateResult;
    				
				fieldstateResult = PatternsDict[FieldState]
				if (val == "dropdown")
				{
						valResult = dropdown;
				}  
				else if (val == "divdrop")
				{
						valResult = divdrop;
				}  
				else if (val == "radio")
				{
						valResult = radio;
				}
				else        
				{
						valResult = PatternsDict[val];
				}
				

				
				if (ele[i].ok == false && (first == 0 || first==8))
				{
						DisplayError(ele[i],valResult,fieldstateResult); 
						r=r+1;
				}
				else
				{
						DisplayStart(ele[i],valResult,fieldstateResult); 
						formok = false;
				}
		}
		if (r>0)
		{
			DisplayErrMsg(); 
			formok = false;
		}else{
			ClearErrMsg();
		}

		if (r==0 && first == 0)
		{
				SubmitForm();
		}	
//Use the value 8 for any validation where additional validation takes place before submission
if (first == 8)
	{
		if (r == 0)
		{
			formok = true;
			return true;
		}else{
			DisplayErrMsg();
			formok = false;
			return false;
		}
	}
}