      var maxYear = 2070;
      var minYear = 1900;

//Ensures key pressed is a valid numeric
function validateIntKeyPress()
{
	event.returnValue = validNumericKeyCode( event.keyCode );
}



// Keep user from entering more than maxLength characters
function TextAreaMaxArea_Keypress(objTextArea)
{
	if ((objTextArea.value.length- objTextArea.document.selection.createRange().text.length)>objTextArea.maxLength-1)
		{
			event.returnValue = false;
		}

}

// Keep user from pasting more than maxLength characters
function TextAreaMaxArea_Paste(objTextArea)
{
	var zClipBoardText = window.clipboardData.getData("Text").replace(/^\s+|\s+$/g, '');

	if (zClipBoardText.length + (objTextArea.value.length - objTextArea.document.selection.createRange().text.length) > objTextArea.maxLength)
		{
			alert("Exceeds maximum number of allowed characters")
			event.returnValue = false;
		}

}

//Ensures each pasted character is a valid numeric
function validateIntPaste()
{

	var zClipBoardText = window.clipboardData.getData("Text").replace(/^\s+|\s+$/g, '');
	var lCnt;

	zfLastValue = this.value;

	for( lCnt = 0; lCnt < zClipBoardText.length; lCnt++ )
	{
		if( !validNumericKeyCode(zClipBoardText.charCodeAt(lCnt)) )
		{
			alert ("Must be numeric");
			event.returnValue = false;
			break;
		}
	}
	window.clipboardData.setData("Text",zClipBoardText);
	return;
}

//Returns true if key code between 0 and 9
function validNumericKeyCode( zKeyCode )
{
	var lpAscZero = 48;
	var lpAscNine = 57;
	
	//0 - 9
	return (zKeyCode >= lpAscZero && zKeyCode <= lpAscNine) 

}
 
 function trim(strInput) 
	{	
	//PP Trims off leading and trailing empty spaces
	
	var retValue = strInput;
    var ch = retValue.substring(0, 1);

	if (typeof strInput != "string") 
      { 
		 return strInput; 
      }
   while (ch == " ") 
       {
		retValue = retValue.substring(1, retValue.length);
		ch = retValue.substring(0, 1);
       }
		ch = retValue.substring(retValue.length-1, retValue.length);
   while (ch == " ") 
	   {
		retValue = retValue.substring(0, retValue.length-1);
		ch = retValue.substring(retValue.length-1, retValue.length);
       }
   return retValue; 
	}
      

function SetFocus (currentElement)
{
   var strTabId
   var obj

	if (currentElement.name == 'txtOperatorName')
	{
		currentElement = document.frmMaintainLicence.btnOpSearch
	}

	strTabId = currentElement.getAttribute ('TabId')
	if (strTabId != null)
	{
	    obj = document.getElementById(strTabId)
	    TabClick (obj)
	}	
	else
	{
		// JCAW - 16 Dec 2003 - This is a horrible work-around, but is needed because Fillcombo
		// controls do not support a TabID.  This means mandatory combos cause an error in the .focus()
		// command (because we cannot Tabclick() to the correct tab.
		
		// When FillCombo has been fixed to support passing in and rendering the TabID attribute,
		// we should get rid of this nasty, nasty code :o)
		if (currentElement.name == 'cboBusinessTrade')
		{
			// show the operator tab...
			obj = document.getElementById('HeaderTab1')
			TabClick (obj)
		}
	}
	
	currentElement.focus();
	
	if (currentElement.name.substr(0,3) != "cbo")
		{
		currentElement.select();
		}

}

function validateNumeric(varElement)
{

	// Determine numeric separator based on user location
     	var decimalSeparator = ".";
		var groupingDigit = ",";
	  //+---------------------------------------------------------------//
	  // Numeric field check
	  // loop through each character and fail if :
	  // minus sign is anywhere but the first character
	  // more than one decimal point entered
	  // not in range 0 to 9.
	  //+---------------------------------------------------------------//

        oneDecimal = false
	    inputStr = varElement
	    
	    for (var i = 0; i < inputStr.length; i++) 
	    {
			var oneChar = inputStr.charAt(i)
			if (i == 0 && oneChar == "-") 
	        {
				continue
			}
		if (oneChar == decimalSeparator && !oneDecimal) 
		{
			oneDecimal = true
			continue	
		}
		else if (oneChar == decimalSeparator && oneDecimal) 
		{
			return false
		} 
		if (oneChar < "0" || oneChar > "9") 
		{
			if (oneChar != groupingDigit)
			{
			   return false
			}	
		}
	  } return true;
}

//+--------------------------------------------------------------------------//
// Integer validation function.
//+--------------------------------------------------------------------------//

function validateInteger(varElement)
{
	  // Interger field check
	  // loop through each character and fail if not in range 0 to 9.
	  
            inputStr = varElement
	    
	    for (var i = 0; i < inputStr.length; i++) 
	    {
		var oneChar = inputStr.charAt(i)
		if (oneChar < "0" || oneChar > "9") 
		{
			return false
		}	 
	    } return true;
}

//+--------------------------------------------------------------------------//
// Currency validation function.
//+--------------------------------------------------------------------------//

function validateCurrency(varElement)
{

	// Determine numeric separator based on user location
     	var decimalSeparator = ".";
		var groupingDigit = ",";
		var countPos
	  //+---------------------------------------------------------------//
	  // Numeric field check
	  // loop through each character and fail if :
	  // minus sign is anywhere but the first character
	  // more than one decimal point entered
	  // not in range 0 to 9.
	  // not more than two characters after decimal point
	  //+---------------------------------------------------------------//

        oneDecimal = false
	    inputStr = varElement
	    
	    for (var i = 0; i < inputStr.length; i++) 
	    {
			var oneChar = inputStr.charAt(i)
			countPos += 1
			
			if (i == 0 && oneChar == "-") 
	        {
				continue
			}
			if (oneChar == decimalSeparator && !oneDecimal) 
			{
				oneDecimal = true
				countPos = 0
				continue	
			}
			else if (oneChar == decimalSeparator && oneDecimal) 
			{
				return false
			}
			if (oneDecimal && countPos > 2)
			{
				return false
			} 
			if (oneChar < "0" || oneChar > "9") 
			{
				if (oneChar != groupingDigit)
				{
				   return false
				}	
			}
		} return true;
}

//+--------------------------------------------------------------------------//
// String validation function.
//+--------------------------------------------------------------------------//

function validateString(varElement)
{

	  //+---------------------------------------------------------------//
	  // String field check
	  // loop through each character and fail if any of the following letters appear:
	  //
	  //	 space `¬!"£$%^&*()-_=+\|,/#
	  //
	  //+---------------------------------------------------------------//

	    inputStr = varElement;
	    errorStr = " `¬!£$%^&*()-_=+\\|,/#\"";
	    
	    for (var i = 0; i < errorStr.length; i++) 
	    {
			var oneChar = errorStr.charAt(i);
			if (inputStr.indexOf(oneChar) > 0)
			{
				return false;
			}
		} return true;
}


function validateSentence(varElement)
{

	  //+---------------------------------------------------------------//
	  // String field check
	  // loop through each character and fail if any of the following letters appear:
	  //
	  //	 `¬!"£$%^&*()-_=+\|,/#
	  //
	  //+---------------------------------------------------------------//

	    inputStr = varElement;
	    errorStr = "`¬!£$%^&*()-_=+\\|,/#\"";
	    
	    for (var i = 0; i < errorStr.length; i++) 
	    {
			var oneChar = errorStr.charAt(i);
			if (inputStr.indexOf(oneChar) > 0)
			{
				return false;
			}
		} return true;
}


//+--------------------------------------------------------------------------//
// Letter validation function.
//+--------------------------------------------------------------------------//

function validateLetter(varElement)
{
	  //+---------------------------------------------------------------//
	  // String field check
	  // loop through each character and fail if any of the following letters appear:
	  //
	  //	 space `¬!"£$%^&*()-_=+\|,/#0123456789
	  //
	  //+---------------------------------------------------------------//

	    inputStr = varElement;
	    errorStr = "0123456789 `¬!£$%^&*()-_=+\\|,/#\"";
	    	    
	    for (var i = 0; i < errorStr.length; i++) 
	    {			
			var oneChar = errorStr.charAt(i);		
			if (inputStr.indexOf(oneChar) != -1)
			{				
				return false;
			}
		} 		
		return true;
}

//+-----------------------------------------------------------------------//
// Date validation function.
//+-----------------------------------------------------------------------//

function validateDate(varElement) 
  {
  
   //+--------------------------------------------------------------------//
   // Only perform date validation if a date has been entered!
   //+--------------------------------------------------------------------//
   
   if (varElement.length != 0)
   {
   
   //+--------------------------------------------------------------------//
   // Determine date separator based on user location
   //+--------------------------------------------------------------------//


        var dateSeparator = "/";


    //+-----------------------------------------------------------------------//
    // Check the date length
    //+-----------------------------------------------------------------------//

      var minLength = 8;
      var maxLength = 10;
      
        if (varElement.length < minLength || varElement.length > maxLength)
        {
	  return false;
        }

    //+-----------------------------------------------------------------------//
    // Check if any characters other than integers or the date separator
    // have been entered.
    //+-----------------------------------------------------------------------//

      for (var i = 0; i < varElement.length; i++) 
      {
	var oneChar = varElement.charAt(i)
		
	if (oneChar < "0" || oneChar > "9") 
	{
	  if (oneChar != dateSeparator)
	  {
	    return false;
          }	
	}
      }

    //+-----------------------------------------------------------------------//
    // Check that at least two delimeters have been entered.
    // If more than two delimeters the range check will find it.
    //+-----------------------------------------------------------------------//

      var delim1 = varElement.indexOf(dateSeparator)
      var delim2 = varElement.lastIndexOf(dateSeparator)

      if (delim1 == -1 || delim1 == delim2)
      {
	return false;
      }

    //+-----------------------------------------------------------------------//
    // Split the date into day, month and year, check that each is a number.
    //+-----------------------------------------------------------------------//

      var dd = varElement.substring(0,delim1)
      var mm = varElement.substring(delim1 + 1,delim2)
      var yyyy = varElement.substring(delim2 + 1,varElement.length)

      if (isNaN(dd) || isNaN(mm) || isNaN(yyyy))
      {
	return false;
      }

    //+-----------------------------------------------------------------------//
    // Check that the year is in range.
    //+-----------------------------------------------------------------------//

      if (yyyy < minYear || yyyy > maxYear)
      {
	return false;
      }

    //+-----------------------------------------------------------------------//
    // Check that the month is valid and has the correct number of days.
    //+-----------------------------------------------------------------------//

      if (mm < 1 || mm > 12)
      {
	return false;
      }      
      else
      {
	if ((mm == 4 || mm == 6 || mm == 9 || mm == 11) && (dd > 30 || dd < 1))
	{
	  return false;
	}
	else if (dd > 31 || dd < 1)
	{
	  return false;
	}
      }

    //+-----------------------------------------------------------------------//
    // Check that February has the correct number of days.
    //+-----------------------------------------------------------------------//

	if (mm == 2) 
	{
		// figure out if "year" is a leap year; don't forget that
		// century years are only leap years if divisible by 400
		var isleap=(yyyy%4==0 && (yyyy%100!=0 || yyyy%400==0));
		if (dd > 29 || (dd == 29 && !isleap)) 
			{
			return false;
		    }
	}
/*
	if ((mm == 2) && ((yyyy % 4) > 0) && (dd > 28))
	{
	return false;
	}
	else if ((mm == 2) && (dd > 29))
	{
	return false;
	}
*/
      return true;

    } 
    return true; // End of 'if populated' statement.
  }

//+--------------------------------------------------------------------------//
// Day of Month validation function..
//+--------------------------------------------------------------------------//

function validateDayOfMonth ( varDay, varMonth, varYear )
{
   if ( varDay.length > 0 )
   {

      if (isNaN(varDay) || isNaN (varMonth) || isNaN(varYear) )
      {
         return false;
      }
   
      if ( varDay > 31 || varDay < 1)
      {
         return false;
      }
   
      if ( (varMonth == 4 || varMonth == 6 || varMonth == 9 || varMonth == 11) && varDay > 30 )
      {
         return false;
      }
      
      if (varMonth == 2)
      {
		// figure out if "year" is a leap year; don't forget that
		// century years are only leap years if divisible by 400
		var isleap=(varYear%4==0 && (varYear%100!=0 || varYear%400==0));
		if (varDay > 29 || (varDay == 29 && !isleap)) 
			{
			return false;
		    }
      }
   }
   
   return true; // End of 'if populated' statement.
}

//+--------------------------------------------------------------------------//
// Year validation function..
//+--------------------------------------------------------------------------//

function validateYear ( varYear )
{
   if (varYear.length > 0)
   {
      if (isNaN(varYear))
      {
         return false;
      }
      
      if (varYear <minYear || varYear > maxYear)
      {
         return false;
      }
   }
   
   return true;
}

//+--------------------------------------------------------------------------//
// Validate the current element.
//+--------------------------------------------------------------------------//

function validate(validElement, currentForm, iCurrentElement) 
  {

   //+--------------------------------------------------------------------//
   // Determine type of element
   //+--------------------------------------------------------------------//

   var elementType = validElement.fieldType;

   //+--------------------------------------------------------------------//
   // Manditory field check
   //+--------------------------------------------------------------------//

   if (validElement.textlength)
   {
      if (validElement.value.length > validElement.textlength)
      {
         alert( 'The indicated field is ' + (validElement.value.length - validElement.textlength) + ' characters more than permitted!');      
         return false;
      }
   }

   if (validElement.mandatory) 
     {
      if (trim(validElement.value) == "")		// manditory field with no data
        {
         alert("The indicated field is mandatory!");      
         return false;
        }
     }
   
   if (validElement.minLength)
		{
		   if (validElement.value.length < validElement.minLength)
		   {
		      alert( 'The indicated field is ' + (validElement.minLength - validElement.value.length) + ' characters less than permitted!');      
		      return false;
		   }
		}

   // Type check
   switch (elementType) 
     {
      case "numeric":
        // Validate numeric data
        if (!validateNumeric(validElement.value)) 
        {
			alert("The indicated field is not a valid numeric.")
			SetFocus (validElement)
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "integer":
        // Validate integer data
        if (!validateInteger(validElement.value)) 
        {
			alert("The indicated field is not a valid integer.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "currency":
        // Validate currency data
        if (!validateCurrency(validElement.value)) 
        {
			alert("The indicated field is not a valid currency.")
			SetFocus (validElement)
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "Email":
      
      // Validate the field is a well-formed e-mail address
      // The email validation function handles displaying the alert box,
      // so we don't do one here.
      
      if (ValidateEmail(validElement.value))
      {
		return true;
		break;
      }
      else
      {
		SetFocus (validElement);
		return false;      
      }
            
      case "date":
        // Validate date data
        if (!validateDate(validElement.value)) 
        {
			alert("The indicated field is not a valid date.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "day":
        // Validate day data
        if (!validateDayOfMonth(validElement.value, currentForm.item(iCurrentElement + 1).value, currentForm.item(iCurrentElement + 2).value)) 
        {
			alert("The indicated field is not a valid date.")
			SetFocus (validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "year":
        // Validate year data
        if (!validateYear(validElement.value)) 
        {
			alert("The indicated field is not a valid year.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "string":
        // Validate string data
        if (!validateString(validElement.value)) 
        {
			alert("The indicated field is not a valid string.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      
      case "string_end_user":
        // Validate string data.  Error should be friendly for the end user.
        if (!validateString(validElement.value)) 
        {
			alert("The indicated field is invalid.  The field should contain only letters and numbers, with no spaces.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        }         
        
     } return true;
  }

//+--------------------------------------------------------------------------//
// performValidation should be called by validating page
//+--------------------------------------------------------------------------//

function performValidation()
{
   // Build the object tags to be used for client-side validation

   var currentElement, elementType;
   var allForms = document.forms;

  if (allForms!=null)
     {
      // loop through all forms

      for (iForms=0; iForms<allForms.length; iForms++)
        {
         var currentForm = allForms[iForms];
         if (currentForm!=null) 
           {
            for (iCurrentForm=0; iCurrentForm<currentForm.length; iCurrentForm++)
              {
               currentElement = currentForm[iCurrentForm];

               // Only check if it is a text field and not disabled or read only
				if (currentElement.name != null)
				{
					if (((currentElement.name.substr(0,3) == "txt") || (currentElement.name.substr(0,3) == "cbo")) &&
					(!currentElement.disabled == true) &&
					(!currentElement.readonly == true))
					  {
					   // Do validation for element

					   if (!validate(currentElement, currentForm, iCurrentForm))
					     {
					      SetFocus ( currentElement)
					      return false;
					     }
					  }
					if ((currentElement.name.substr(0,2) == "ta") &&
					(!currentElement.disabled == true) &&
					(!currentElement.readonly == true))
					  {
					   // Do validation for element

					   if (!validate(currentElement, currentForm, iCurrentForm))
					     {
					      SetFocus ( currentElement)
					      return false;
					     }
					  }
					else if (currentElement.name == "txtOperatorName")
					  {
					   // Do validation for element

					   if (!validate(currentElement, currentForm, iCurrentForm))
					     {
					      SetFocus ( currentElement)
					      return false;
					     }
					  }
				  }
              }
           }
        }
     }
     return true;
}

function IsDate1AfterDate2(dte1, dte2)
{ 
	if( dte1.valueOf() >= dte2.valueOf())
		return true;
	else
		return false;
}

function ValidateEmail(strEmail) 
{
// If there is no email... Then it's valid.  Use the mandatory=True extendo to
// make an e-mail field mandatory.
if (strEmail=='')
{
	return true;
}

strEmail = strEmail.toLowerCase()

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var blnCheckTLD=1;

/* The following is the list of known TLDs that an e-mail address must end with. */

var strKnownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var strEmailPat=/^(.+)@(.+)$/;
 
// We don't want to allow certain special characters in the address. 
var strSpecChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + strSpecChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "Fred.Bloggs"@yahoo.com
is a legal e-mail address. */

var strQuotedUsr="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var strIPDomPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in joe.bloggs@cmgplc.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var strWord="(" + atom + "|" + strQuotedUsr + ")";

// The following pattern describes the structure of the user

var strUserPat=new RegExp("^" + strWord + "(\\." + strWord + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to strIPDomPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid */

var a_MatchArray=strEmail.match(strEmailPat);

if (a_MatchArray==null) 
{
	alert("The E-mail address is incorrect (check @ and .'s)");
	return false;
}
var user=a_MatchArray[1];
var domain=a_MatchArray[2];

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("The E-mail username contains invalid characters.");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("The E-mail domain name contains invalid characters.");
return false;
   }
}

if (user.match(strUserPat)==null) 
{
	alert("The E-mail username does not appear to be valid.");
	return false;
}

var IPArray=domain.match(strIPDomPat);
if (IPArray!=null) 
{
	for (var i=1;i<=4;i++) 
	{
		if (IPArray[i]>255) 
		{
			alert("The E-mail destination IP address is invalid!");
			return false;
	    }
	}
return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) 
{
	if (domArr[i].search(atomPat)==-1) 
	{
		alert("The E-mail domain name does not appear to be valid.");
		return false;
	}
}

if (blnCheckTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(strKnownDomsPat)==-1) 
{
	alert("The E-mail address must end in a well-known domain (com, org, etc.) or a two-letter country code.");
	return false;
}

if (len<2) 
{
	alert("This E-mail does not have a hostame!");
	return false;
}

return true;
}


//same as performValidation function - modified to support w3c standards
//mandatory and fieldtype attributes are not part of the fucntion

function formValidation()
{

// Build the object tags to be used for client-side validation

   var currentElement, elementType;
   var allForms = document.forms;

  if (allForms!=null)
     {
      // loop through all forms

      for (iForms=0; iForms<allForms.length; iForms++)
        {
         var currentForm = allForms[iForms];
         if (currentForm!=null) 
           {
            for (iCurrentForm=0; iCurrentForm<currentForm.length; iCurrentForm++)
              {
               currentElement = currentForm[iCurrentForm];

               // Only check if it is a text field and not disabled or read only

               if (((currentElement.name.substr(0,3) == "txt") || (currentElement.name.substr(0,3) == "cbo")) &&
               (!currentElement.disabled == true) &&
               (!currentElement.readonly == true))
                 {
                  // Do validation for element

                  if (!validateEle(currentElement, currentForm, iCurrentForm))
                    {
                     SetFocus ( currentElement)
                     return false;
                    }
                 }
               if ((currentElement.name.substr(0,2) == "ta") &&
               (!currentElement.disabled == true) &&
               (!currentElement.readonly == true))
                 {
                  // Do validation for element

                  if (!validateEle(currentElement, currentForm, iCurrentForm))
                    {
                     SetFocus ( currentElement)
                     return false;
                    }
                 }
               else if (currentElement.name == "txtOperatorName")
                 {
                  // Do validation for element

                  if (!validateEle(currentElement, currentForm, iCurrentForm))
                    {
                     SetFocus ( currentElement)
                     return false;
                    }
                 }
              }
           }
        }
     }
     return true;

}


function validateEle(validElement, currentForm, iCurrentElement)
{
	//		Constants used to identify function
	//		1	Numeric
	//		2	Integer
	//		3	Currency
	//		4	Email
	//		5	Date
	//		6	Day
	//		7	Year
	//		8	String
	//		9	String end user
	//      10  
	

	//+--------------------------------------------------------------------//
   // Determine type of element
   //+--------------------------------------------------------------------//
   
   //A mandatory hidden input should have been configured in html
   
   var mandatoryFields = document.getElementById('mandatory').value;  
   var FieldType = document.getElementById('FieldType').value;   
   var elementType;   
   var minLength = document.getElementById('minLength').value;  
   var minLengthArr; 
   var FieldTypeArr = FieldType.split(","); 
   var minLen;
   
	
   //+--------------------------------------------------------------------//
   // Mandatory field check
   //+--------------------------------------------------------------------//
	
	elementType = 0;
	
   minLengthArr = minLength.split(",")
	
   for(var i=0; i<FieldTypeArr.length;i++)
	{
		if (FieldTypeArr[i].match(validElement.id) !=null){
			elementType = FieldTypeArr[i].substring(FieldTypeArr[i].length-1);
			
		}
	}
   
   if (mandatoryFields.match(validElement.id) != null) 
     {
      if (validElement.value == "")		// manditory field with no data
        {
         alert("The indicated field is mandatory!");      
         return false;
        }
     }
   
   if (minLength.match(validElement.id) != null)
		{
		   for(var i=0; i<minLengthArr.length;i++)
			{
				if (minLengthArr[i].match(validElement.id) !=null){
					minLen = minLengthArr[i].substring(minLengthArr[i].length-1);
			
				}
			}
			
		   if (validElement.value.length < minLen)
		   {
		      alert( 'The indicated field is ' + (minLen - validElement.value.length) + ' characters less than permitted!');      
		      return false;
		   }
		}
	
   // Type check
   
   
   switch (elementType) 
     {
      case "1":
        // Validate numeric data
        if (!validateNumeric(validElement.value)) 
        {
			alert("The indicated field is not a valid numeric.")
			SetFocus (validElement)
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "2":
        // Validate integer data
        if (!validateInteger(validElement.value)) 
        {
			alert("The indicated field is not a valid integer.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "3":
        // Validate currency data
        if (!validateCurrency(validElement.value)) 
        {
			alert("The indicated field is not a valid currency.")
			SetFocus (validElement)
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      case "4":
      
      // Validate the field is a well-formed e-mail address
      // The email validation function handles displaying the alert box,
      // so we don't do one here.
      
      if (ValidateEmail(validElement.value))
      {
		return true;
		break;
      }
      else
      {
		SetFocus (validElement);
		return false;      
      }
            
      case "5":
        // Validate date data
        if (!validateDate(validElement.value)) 
        {
			alert("The indicated field is not a valid date.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "6":
        // Validate day data
        if (!validateDayOfMonth(validElement.value, currentForm.item(iCurrentElement + 1).value, currentForm.item(iCurrentElement + 2).value)) 
        {
			alert("The indicated field is not a valid date.")
			SetFocus (validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "7":
        // Validate year data
        if (!validateYear(validElement.value)) 
        {
			alert("The indicated field is not a valid year.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 

      case "8":
        // Validate string data
        if (!validateString(validElement.value)) 
        {
			alert("The indicated field is not a valid string.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        } 
      
      case "9":
        // Validate string data.  Error should be friendly for the end user.
        if (!validateString(validElement.value)) 
        {
			alert("The indicated field is invalid.  The field should contain only letters and numbers, with no spaces.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        }
        case "10":
        //Validate the string data, but allow space
        if (!validateSentence(validElement.value)) 
        {
			alert("The indicated field is invalid.  The field should contain only letters and numbers.")
			SetFocus(validElement);
			return false;
        }
        else 
        {
			return true;
			break;
        }
        
     } 
     return true;
	
	

}