<!--

function checkDomainName ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is a valid domain name.  */
/* Valid domain names can only contain letters, numbers, dashes, and periods.*/
/* The domain name may only begin and end with letters and numbers.          */
/* Receives : The value to check                                             */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	// Return false if blank.
	if ( objectValue.length == 0 )
		return false;

	// Make sure contains valid characters.
	if ( !checkValidChars( objectValue, true, true, false, ".-" ) )
		return false;
		
	// Set variables.
	var invalidChars = ".-"

	// Check first character.
	if ( !(invalidChars.indexOf(objectValue.charAt(0)) == -1) )
		return false;
		
	// Walk string and check.
	for ( i = 1; i < objectValue.length; i++ )
	{
		if ( objectValue.charAt(i) == "." )
		{
			// Two periods in a row or a dash before a period.
			if ( !(invalidChars.indexOf(objectValue.charAt(i+1)) == -1) )
				return false;
		}
		else if  ( objectValue.charAt(i) == "-" )
		{
			// Two dashes in a row or a period before a dash.
			if ( !(invalidChars.indexOf(objectValue.charAt(i+1)) == -1) )
				return false;
		}
	}
	
	return true;	
}


function checkEmail ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is a valid email address.*/
/* Valid email addresses can only contain letters, numbers, 1 asterisk, and  */
/* the following characters: @.-_!                                           */
/* Receives : The value to check                                             */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	// Return false if blank.
	if ( objectValue.length == 0 )
		return false;
		
	// Make sure contains valid characters.
	if ( !checkValidChars( objectValue, true, true, false, "@.-_!" ) )
		return false;
		
	// Make sure valid length.
	if ( !checkMinSize( objectValue, 8 ) )
		return false;
	
	// Make sure there is only 1 @ symbol and at least 1 period.
	var foundAt 	= false;
	var foundPeriod = false;
	
	for ( i = 0; i < objectValue.length; i++ )
	{
		if ( objectValue.charAt(i) == "@" )
			if ( foundAt ) // Second @ symbol.
				return false;
			else
				foundAt = true;
		if ( objectValue.charAt(i) == "." )
			foundPeriod = true;
	}
	
	if ( foundAt && foundPeriod )
		return true;
	else
		return false;
}

function checkHasValue ( formObject, objectType )
/*****************************************************************************/
/* Determines whether or not the object passed to it is populated based on   */
/* the object type.  The function supports the following opject types:       */
/* TEXT, PASSWORD, SELECT, RADIO, SINGLE_VALUE_RADIO, CHECKBOX,              */
/* SINGLE_VALUE_CHECKBOX.                                                    */
/* Receives : The object to check                                            */
/*            The object's type                                              */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	if (( objectType == "TEXT" ) || 
		( objectType == "PASSWORD" ))
	{
		if (formObject.length == 0 )
			return false;
		else
			return true;
	}
	else if ( objectType == "SELECT" )
	{
		for ( i = 0; i < formObject.length; i++ )
			if ( formObject.options[i].selected )
				return true;

		return false;
	}
	else if (( objectType == "SINGLE_VALUE_RADIO" ) || 
			 ( objectType == "SINGLE_VALUE_CHECKBOX" ))
	{
		if ( formObject.checked )
			return true;
		else
			return false;
	}
	else if (( objectType == "RADIO" ) || 
			 ( objectType == "CHECKBOX" ))
	{
		for ( i = 0; i < formObject.length; i++ )
			if ( formObject[i].checked )
				return true;
		
		return false;
	}
}

function checkInteger ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is an integer.  The      */
/* function supports both positive and negative integers.                    */
/* Receives : The value to check                                             */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	// Check if length is zero.
	if ( objectValue.length == 0 )
		return true;
		
	// Check if decimal point exists.
	var decimalChar 	= ".";
	var decimalCheck	= objectValue.indexOf(decimalChar)
	
	if ( decimalCheck < 1 )
		return checkNumber( objectValue );
	else
		return false;
}

function checkIPAddress ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is a valid IP address.   */
/* Receives : The value to check                                             */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	// Return false if empty or greater than 15.
	if ( ( objectValue.length == 0 ) || ( objectValue.length > 15 ) )
		return false;
	
	// Verify is numbers and periods.
	if ( !checkValidChars( objectValue, true, false, false, "." ) )
		return false;

	// Make sure first character isn't a period.
	if ( objectValue.charAt(0) == "." )
		return false;
		
	// Make sure last character isn't a period.
	if ( objectValue.charAt(objectValue.length - 1) == "." )
		return false;	
		
	// Walk and test.
	var number			= "";
	var numberCounter	= 0;
	var periodCounter 	= 0;

	for ( i = 0; i < objectValue.length; i++ )
	{
		if ( objectValue.charAt(i) == "." )	
		{
			if ( numberCounter == 0 ) // Two periods in a row.
				return false;
			else 
			{
				periodCounter++;
				if ( periodCounter > 3 )
					return false;
				numberCounter 	= 0;
				number			= "";
			}
		}
		else // Current character is not a period.
		{
			numberCounter++;

			if ( numberCounter > 3 ) // Too many numbers.
				return false;
				
			number += objectValue.charAt(i);
			
			if ( ( numberCounter == 3 ) && ( eval(number) > 255 ) ) // Too high number.
				return false;			
		}
	}
	
	if ( !( periodCounter == 3 ) ) // Not enough classes in IP.
		return false;

	return true;
}

function checkMinSize ( objectValue, minSize )
/*****************************************************************************/
/* Determines whether or not the length of the value passed to it is greater */
/* than or equal to the minimum size.                                        */
/* Receives : Value to check                                                 */
/*            Mimimum size                                                   */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	if ( isNaN( minSize ) )
	{
		alert("MinSize is not a number.");
		return false;
	}
	else if ( objectValue.length < minSize )
		return false;
	else
		return true;
}

function checkNumber ( objectValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is a valid number.  The  */
/* function supports both positive and negative numbers.                     */
/* Receives : Value to check                                                 */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	if ( objectValue.length == 0 ) // Length is zero.
		return true;

	// Initialize variables.
	var startFormat		= " .+-0123456789";
	var numberFormat	= " .0123456789";
	var charCheck		= startFormat.indexOf(objectValue.charAt(0));
	var isDecimal		= false;
	var isTrailingSpace	= false;
	var isDigits		= false;

	if ( charCheck == 1 ) // First char is a period.
		isDecimal = true;
	else if ( charCheck < 1 ) // First char is invalid.
		return false;

	// Walk and test.
	for ( i = 0; i < objectValue.length; i++ )
	{
		charCheck = numberFormat.indexOf(objectValue.charAt(i));
		if ( charCheck < 0 ) // Invalid character.
			return false;
		else if ( charCheck == 1 )
			if ( isDecimal ) // Two decimals.
				return false;
			else
				isDecimal = true;
		else if ( charCheck == 0 ) // Char is a space.
		{
			if ( isDecimal || isDigits ) // Ignore leading spaces.
				isTrailingSpace = true;
		}
		else if ( isTrailingSpace ) // Space in number.
			return false;
		else
			isDigits = true;
	}
	
	return true;
}

function checkNumberRange ( objectValue, minValue, maxValue )
/*****************************************************************************/
/* Determines whether or not the value passed to it is in the range of the   */
/* min value and max value.  This is a sub function of checkRange().         */
/* Receives : Value to check                                                 */
/*            Miminum value                                                  */
/*            Maximum value                                                  */
/* Returns  : True / False                                                   */
/*****************************************************************************/
{
	// Check minimum value.
	if ( minValue != null )
		if ( objectValue < minValue ) // Less than minimum value.
			return false;
			
	// Check maximum value.
	if ( maxValue != null )
		if ( objectValue > maxValue ) // Greater than maximum value.
			return false;
			
	// Value is in renage.
	return true;
}


function checkRange ( objectValue, minValue, maxValue )
/*****************************************************************************/
/*                                                                           */
/* Receives :                                                                */
/* Returns  :                                                                */
/*****************************************************************************/
{
	if ( objectValue == 0 )
		return true;
	
	if ( !checkNumber( objectValue ) )
		return false;
	else
		return ( checkNumberRange((eval(objectValue)), minValue, maxValue ));
	
	return true;
}


function checkValidChars ( objectValue, allowNumbers, allowLetters, allowSpaces, specialChars, isInclude )
/*****************************************************************************/
/*                                                                           */
/* Receives :                                                                */
/* Returns  :                                                                */
/*****************************************************************************/
{
	// Set default variables.
	if ( allowNumbers == null )
		allowNumbers = true;
		
	if ( allowLetters == null )
		allowLetters = true;

	if ( allowSpaces == null )
		allowSpaces = true;

	if ( specialChars == null )
		specialChars = "";

	if ( isInclude == null )
		isInclude = true;

	// Verify passed variables.
	if (( allowNumbers != true ) && ( allowNumbers != false ))
	{
		alert("Invalid variable : allowNumbers\ntrue of false expected");
		return false;
	}
	
	if (( allowLetters != true ) && ( allowLetters != false ))
	{
		alert("Invalid variable : allowLetters\ntrue of false expected");
		return false;
	}
	
	if (( allowSpaces != true ) && ( allowSpaces != false ))
	{
		alert("Invalid variable : allowSpaces\ntrue of false expected");
		return false;
	}
		
	if ( objectValue.length == 0 )
		return true;
		
	if (( isInclude != true ) && ( isInclude != false ))
	{
		alert("Invalid variable : isInclude\ntrue of false expected");
		return false;
	}
		
	// Initialize local variables.
	var letters			= "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var charCheck;

	for ( i = 0; i < objectValue.length; i++ )
	{
		if ( !isNaN(objectValue.charAt(i)) )
		{
			if (!(objectValue.charAt(i) == " "))
			{
				if ( !allowNumbers )
					return false;
			}
			else if ( !allowSpaces )
				return false;
		}
		else if ( !(letters.indexOf(objectValue.charAt(i)) < 0) )
		{
			if ( !allowLetters )
				return false;		
		}
		else if ( objectValue.charAt(i) == " " )
		{
			if ( !allowSpaces )
				return false;
		}
		else if ( isInclude )
		{
			if ( specialChars.indexOf(objectValue.charAt(i)) < 0 )
				return false;
		}
		else
		{
			if ( !( specialChars.indexOf(objectValue.charAt(i)) < 0 ) )
				return false;
		}
		
	}
	
	return true;
}


function onError( formObject, inputObject, objectValue, errorMessage )
/*****************************************************************************/
/*                                                                           */
/* Receives :                                                                */
/* Returns  :                                                                */
/*****************************************************************************/
{
	alert(errorMessage);
	inputObject.focus();
	inputObject.select();
	return false;
}

// -->