	//-----------------------------------------------------------------
	function IsValidLength(object, minChars, maxChars)
		{
		var value=object.value;
		if (value.length < minChars) 
		{
			object.select();         
			object.focus();         
    		alert("Your entry should be " + minChars + " or more characters long.");
			return false;
		}
		else if ( maxChars < value.length) 
		{
			object.select();         
			object.focus();         
    		alert("Your entry should be " + maxChars + " or less characters long.");
			return false;
		}
		return true;
		}
	//-----------------------------------------------------------------
	function IsValidNonBlank(object)
	{
		var str = object.value;  
		// Return false if number field is blank.   
		if (str == ""||str == "NA")
		{         
			object.focus();
			object.select();        			
    		alert("Your entry should not be blank. ");
			return false;         
		} 
		return true;  
	}
	//-----------------------------------------------------------------
	function IsValidRadio(object, errorMsg)
	{
		var option = "unchecked";
		var optionList = "";
		var optionCount=object.length;
		for(var i=0;i<optionCount;i++)
		{
			optionList += object[i].value;
			if(i < optionCount - 1) optionList += ", ";	
			if(object[i].checked) option = object[i].value;
		}
		if(option == "unchecked")
		{
			if (IsValidRadio.arguments.length<2)
			{
	    	errorMsg = "Radio option '" + object[0].name + "' is not set. Value is: " + option + " . Should be one of: " + optionList + ".";
			}
			alert(errorMsg);
			return false;         
		}
		return true;
	}
	//-----------------------------------------------------------------
	// A name is anything but less that 48 chars long
	// Refinements would include alphabetical, dashes, spaces, single quotes.
	function IsValidName(object)
	{
		if(!IsValidNonBlank(object)) return false;
		else if (!IsValidLength(object, 1, 48)) return false; 
		return true;   
	}        
	//-----------------------------------------------------------------
	// The value must be an integer between in a range
	function IsValidIntegerRange(object, minValue, maxValue)
	{
		if(!IsValidNonBlank(object)) return false;
		else
		{
			var aValue = parseInt(object.value)
			if(isNaN(aValue)) 
			{
				return false; 
			}
			else
			{
				if(aValue < minValue || aValue > maxValue)
				{
					return false; 
				}
			}
		}
		return true;   
	}        
	//-----------------------------------------------------------------
	// The value must be an integer between in a range
	function IsValidFloatAboveLimit(object, minValue)
	{
		if(!IsValidNonBlank(object)) return false;
		else
		{
			var aValue = parseFloat(object.value)
			if(isNaN(aValue)) 
			{
				return false; 
			}
			else
			{
				var minStr = new String(minValue)
				var delta = 0.00000001
				if(aValue < minValue +  delta)
				{
					return false; 
				}
			}
		}
		return true;   
	}        
	//-----------------------------------------------------------------
	// A street address is anything but less that 64 chars long
	function IsValidStreetAddress(object)
	{
		if(!IsValidNonBlank(object)) return false;
		else if (!IsValidLength(object, 1, 64)) return false; 
		return true;   
	}        
	//-----------------------------------------------------------------
	function IsValidEmailAddress(object)
	{
		var emailParts;
		var emailName;
		var emailLocation;
		var locationParts;
		var str = new String(object.value);
		var emailChar = "\@";
		var atPosition = str.indexOf(emailChar);
		if (atPosition == -1)
		{
    		alert("Your email address is \"" + str + "\". It must contain a " + emailChar);
			return false; 
		} 
		emailParts = str.split(emailChar); 
		emailName = emailParts[0];   
		emailLocation = emailParts[1]; 
		if(emailName == "")
		{
    		alert("Your email address must contain a name before the " + emailChar);
			return false; 
		}  
		if(emailLocation == "")
		{
    		alert("Your email address must contain a location after the " + emailChar);
			return false; 
		}  
		if (emailLocation.indexOf('.') == -1)
		{
    		alert("Your email address must contain one or more '.'s.");
			return false; 
		}
		locationParts =  emailLocation.split('.');
		for(var i=0;i<locationParts.length;i++)
		{
			if (locationParts[i] == "")
			{
    			alert("Your email location must must be in the form 'abc.def.ghij'");
				return false; 
			}
		}
		return true;   
	}
	//-----------------------------------------------------------------
	function IsValidOtherMenu(menuObject, fieldObject)
	{
		var isValid = true;
		if(menuObject.options[menuObject.selectedIndex].value == "other")
		{
			var str = fieldObject.value;  
			// Return false if field is blank.   
			if (str == ""||str == "NA")
			{         
				fieldObject.focus();
				fieldObject.select();        			
				isValid = false;         
    			alert("Your \"other\" text field must not be blank. ");
			}
		}
		return isValid;
	}
	//-----------------------------------------------------------------
	// If the telephone number is not empty
	// make sure the characters are OK.
	// To make a telephone number 'required'
	// add a previous IsValidNonBlank test as well.
	function IsValidTelephoneNumber(textObject)
	{
		var str = textObject.value;  
		// Return false if characters are not '0-9A-Z()-+ '. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 6) 
			{
				alert("Your telephone number should contain 6 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if(!(("A" <= ch  &&  ch <= "Z" ) 
					|| ("0" <=ch && ch <= "9" ) 
					|| ch == "("  ||  ch == ")"
					|| ch == "-"  ||  ch == " "))
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your telephone number should contain only digits, uppercase alphabetic characters or '(',')','-', or space");
					return false;         
				}      
			}
		}   
		return true;   
	}
	//-----------------------------------------------------------------
	// If the credit card number is not empty
	// make sure the characters are OK.
	// To make a credit card number number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidCreditCardNumber(textObject, menuObject)
	{
		var str = textObject.value;  
		// Return false if characters are not '0-9 '. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 6) 
			{
				alert("Your credit card number should contain 6 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if(!(("A" <= ch  &&  ch <= "Z" ) 
					|| ("0" <=ch && ch <= "9" ) 
					|| ch == " "))
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your credit card number should contain only \ndigits or uppercase alphabetic characters. ");
					return false;         
				}      
			}
		}   
		return true;   
	}
	//-----------------------------------------------------------------
	// If the date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidDate(textObject)
	{
		var str = textObject.value;  
		// Return false if characters are not '0-9/ '. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 6) 
			{
				alert("Your date should contain 6 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if(!( ("0" <=ch && ch <= "9" ) 
					|| ch == "/"))
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your date should contain only \ndigits or \"/\". ");
					return false;         
				}      
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
	// If the date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidTime(textObject)
	{
		var str = textObject.value;  
		// Return false if characters are not '0-9A-Za-z()-/ '. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 6) 
			{
				alert("Your date should contain 6 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if(!(("0" <=ch && ch <= "9" ) 
					|| ch == ":" || ch == "a" || ch == "m" || ch == "p" || ch == " " ))
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your time should contain only \ndigits and \":\" and \"am\" or \"pm\". ");
					return false;         
				}      
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
	// If the date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidPostCode(textObject)
	{
		var str = textObject.value;  
	// Return false if characters are not '0-9'. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 4) 
			{
				alert("Your postcode should contain 4 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if( !("0" <=ch && ch <= "9" ) )
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your post code should contain only digits. ");
					return false;         
				}      
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
	// If the date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidMoney(textObject)
	{
		var str = textObject.value;  
	// Return false if characters are not '0-9'. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(charCount < 1) 
			{
				alert("Your money value should contain 1 or more characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if( !(("0" <=ch && ch <= "9" ) || ch == "." || ch == "-") )
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your money value should contain only digits and a \".\". ");
					return false;         
				}      
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
	// If the expiry date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidCreditCardExpiryDate(textObject)
	{
		var str = textObject.value;  
	// Return false if characters are not '0-9'. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(!(charCount == 5)) 
			{
				alert("Your expiry date value should contain 5 characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if( !(("0" <=ch && ch <= "9" ) || ch == "/") )
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your expiry date value should contain only digits and a \"/\". ");
					return false;         
				}
			}
			var components = str.split("/");
			var month = parseInt(components[0])
			var year = parseInt(components[1])
			if(isNaN(month) || !(1 <= month && month <= 12))
			{
				return false;         
			}
			else if(isNaN(year) || !(4 <= year && year <= 20))
			{
				return false;         
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
	// If the expiry date is not empty
	// make sure the characters are OK.
	// To make a date number 'required'
	// add a previous IsValidNonBlank test as well.
	
	function IsValidCreditCardValidationCode(textObject)
	{
		var str = textObject.value;  
	// Return false if characters are not '0-9'. 
		var charCount =  str.length;
		if(charCount > 0)
		{ 
			if(!(charCount == 3)) 
			{
				alert("Your CCV value should contain 5 characters.");
				return false;
			}
			for (var charIndex = 0; charIndex < charCount; charIndex++)
			{      
				var ch = str.charAt(charIndex);
				if( !(("0" <=ch && ch <= "9" ) ) )
				{         
					textObject.select();         
					textObject.focus();         
					alert("Your CCV value should contain only digits. ");
					return false;         
				}
			}
		}   
		return true;   
	}
	
	//-----------------------------------------------------------------
