<!--
var countryUSA = 'USA';
function CheckInteger(stringValue)
{
	var isValid = true;
	_stringValue = parseInt(stringValue);
	if (isNaN(_stringValue) || (_stringValue != stringValue)) 
	{
		isValid = false;
	}
	return isValid;
}
function CheckNumber(stringValue)
{
	var isValid = true;
	stringValue = parseFloat(stringValue);
	if (isNaN(stringValue))
	{
		isValid = false;
	}
	return isValid;
}
function CheckRequiredSelect(fieldObject)
{
	var isValid = true;
	var indexValue = fieldObject.selectedIndex;
	var fieldValue = Trim(fieldObject[indexValue].value);
	if (fieldValue.length == 0 || fieldValue == '-1')
	{
		isValid = false;	
	}
	return isValid;
}
function CheckRequiredValue(stringValue)
{
	var isValid = true;
	var stringValue = Trim(stringValue);
	if (stringValue.length == 0)
	{
		isValid = false;	
	}
	return isValid;
}
function CheckRequiredValueOther(SelectField, OtherField)
{
	var otherValue = "other";
	var isValid = CheckRequiredSelect(SelectField);
	if (isValid == true)
	{
		if (SelectField[SelectField.selectedIndex].text.toLowerCase() == otherValue.toLowerCase())
		{
			isValid = CheckRequiredValue(OtherField.value);
		}
	}
	return isValid;
}
function CheckRequiredOption(fieldObject)
{
	var fieldLength = fieldObject.length;
	var isValid = true;
	var isSelected = false;
	var counter = 0;
	if (fieldLength == 1)
	{
		if (fieldObject.checked)
		{
			isSelected = true;
		}
	}
	else
	{
		for (counter = 0; counter < fieldLength; counter++)
		{
			if (fieldObject[counter].checked)
			{
				isSelected = true;
				break;
			}
		}
	}
	if (isSelected == false)
	{
		isValid = false;
	}	
	return isValid;
}
function CheckValidCharacters(stringValue)
{
	var isValid = true;
	var stringLength = stringValue.length;						
	var subString = '';
	var characterCode = 0;
	if (stringLength == 0)
	{
		return isValid;
	}
	else
	{
		for (var i=0; i < stringLength; i++)
		{
			subString = stringValue.charAt(i);
			characterCode = subString.charCodeAt(0);
			if (characterCode == 60 || characterCode == 62)
			{
				isValid = false;
				break;
			}
		}
		return isValid;
	}
}
function CheckValidEmail(email) 
{
	var atPos;
	var periodPos;
	var isValid;
	
	// check for @ sign
	atPos = email.indexOf("@");
	isValid = ((atPos != -1) && 
			   (atPos != 0) &&
			   (atPos != (email.length - 1)) &&
			   (email.indexOf("@", atPos + 1) == -1)
			  );
			  
	// check for period
	if (isValid == true) 
	{
		periodPos = email.lastIndexOf(".");
		isValid = ((periodPos != -1) && (periodPos != (email.length - 1)) && (periodPos > atPos));
	}
	
	return isValid;
}
function LTrim(str)
{
	return str ? str.toString().replace(new RegExp(/^[\s\n\t\r]+/),"") : "";
}
function RTrim(str)
{
	return str ? str.replace(new RegExp(/[\s\n\t\r]+$/),"") : "";
}
function Trim(str)
{
   return RTrim(LTrim(str));
}
function RemovePhoneFormat(fieldValue)
{
	// declare variables
	var formattedValue = '';
	var subValue = '';
	var i = 0;
		
	// strip invalid characters from phone number
	if (fieldValue.length > 0)
	{
		for(i = 0; i < fieldValue.length; i++)
		{
			subValue = fieldValue.charAt(i);
			charCode = subValue.charCodeAt(0);
			if ( (charCode >= 48 && charCode <= 57) || (charCode >= 65 && charCode <= 90) || (charCode >= 97 && charCode <= 122) )
			{
				formattedValue += subValue;
			}
		}
	}
	return formattedValue;
}	
function CheckPhoneValue(fieldValue)
{
	var isValid = true;
	fieldValue = RemovePhoneFormat(fieldValue);
	if (fieldValue.length > 0 && fieldValue.length < 10)
	{
		isValid = false;
	}
	return isValid;
}

function FormatPhone(fieldValue)
{
    if (!CheckPhoneValue(fieldValue))
    {
        return fieldValue;
    }
	fieldValue = RemovePhoneFormat(fieldValue);
	var newValue = "";
	if (fieldValue.length >= 10)
	{
		newValue = "(" + fieldValue.substr(0, 3) + ") " + fieldValue.substr(3, 3) + "-" + fieldValue.substr(6, 4);
		if (fieldValue.length > 10)
		{
			newValue += ", " + fieldValue.substr(10, (fieldValue.length-10));
		}
	}
	return newValue;
}

//-->

