<!--
function Trim(TRIM_VALUE){
	if(TRIM_VALUE.length < 1){
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE==""){
		return "";
	}
	else{
		return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE){
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
		return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(0,iTemp +1);
			break;
		}
	iTemp = iTemp-1;
	} //End While
	return strTemp;
} //End Function

function LTrim(VALUE){
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
		return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";
	var iTemp = 0;

	while(iTemp < v_length){
		if(VALUE.charAt(iTemp) == w_space){
		}
		else{
			strTemp = VALUE.substring(iTemp,v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function

function isEmail(email)
{ var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
   if (index > 0 
  		&& email.indexOf(" ") < 0
		&& email.indexOf("$") < 0
		&& email.indexOf('"') < 0
		&& email.indexOf("<") < 0
		&& email.indexOf(">") < 0
		&& email.indexOf("(") < 0
		&& email.indexOf("#") < 0
		&& email.indexOf(")") < 0)
  { var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  return result;
}

function isEmail2(str) {
  // are regular expressions supported?
  var supported = 0;
  if (window.RegExp) {
    var tempStr = "a";
    var tempReg = new RegExp(tempStr);
    if (tempReg.test(tempStr)) supported = 1;
  }
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)|(\\])");
  var r2 = new RegExp("^(\\[?)[a-zA-Z0-9\\-_\\.]+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
  return (!r1.test(str) && r2.test(str));
}

	
function _CF_onError(form_object, input_object, object_value, error_message)
{ alert(error_message);
	return false;	
}

 

function _CF_checkinteger(object_value)
{	 //Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is an integer defined as
    //   having an optional leading + or -.
    //   otherwise containing only the characters 0-9.
	var decimal_format = ".";
	var check_char;

    //The first character can be + -  blank or a digit.
	check_char = object_value.indexOf(decimal_format)
    //Was it a decimal?
    if (check_char < 1)
	return _CF_checknumber(object_value);
    else
	return false;
}



function _CF_numberrange(object_value, min_value, max_value)
{	// check minimum
    if (min_value != null)
	{	if (object_value < min_value)
		return false;
	}

    // check maximum
    if (max_value != null)
	{  if (object_value > max_value)
		return false;
	}
	
    //All tests passed, so...
    return true;
}
	
	
	
function _CF_checknumber(object_value)
{	//Returns true if value is a number or is NULL
    //otherwise returns false	

    if (object_value.length == 0)
        return true;

    //Returns true if value is a number defined as
    //   having an optional leading + or -.
    //   having at most 1 decimal point.
    //   otherwise containing only the characters 0-9.
	var start_format = " .+-0123456789";
	var number_format = " .0123456789";
	var check_char;
	var decimal = false;
	var trailing_blank = false;
	var digits = false;

    //The first character can be + - .  blank or a digit.
	check_char = start_format.indexOf(object_value.charAt(0))
    //Was it a decimal?
	if (check_char == 1)
	    decimal = true;
	else if (check_char < 1)
		return false;
        
	//Remaining characters can be only . or a digit, but only one decimal.
	for (var i = 1; i < object_value.length; i++)
	{	check_char = number_format.indexOf(object_value.charAt(i))
		if (check_char < 0)
			return false;
		else if (check_char == 1)
		{	if (decimal)		// Second decimal.
				return false;
			else
				decimal = true;
		}
		else if (check_char == 0)
		{	if (decimal || digits)	
				trailing_blank = true;
        // ignore leading blanks

		}
	        else if (trailing_blank)
			return false;
		else
			digits = true;
	}	
    //All tests passed, so...
    return true
}
	
	
	
function _CF_checkrange(object_value, min_value, max_value)
{	//if value is in range then return true else return false
    if (object_value.length == 0)
        return true;

    if (!_CF_checknumber(object_value))
	{ return false; }
    else
	{  return (_CF_numberrange((eval(object_value)), min_value, max_value)); }
	
    //All tests passed, so...
    return true;
}



function _CF_checkphone(object_value)
{	if (object_value.length == 0)
        return true;
		
    if (object_value.length != 12)
        return false;

	// check if first 3 characters represent a valid area code
    if (!_CF_checknumber(object_value.substring(0,3)))
		return false;
    else
	if (!_CF_numberrange((eval(object_value.substring(0,3))), 100, 1000))
		return false;

	// check if area code/exchange separator is either a'-' or ' '
	if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
        return false

	// check if  characters 5 - 7 represent a valid exchange
    if (!_CF_checknumber(object_value.substring(4,7)))
		return false;
    else
	if (!_CF_numberrange((eval(object_value.substring(4,7))), 100, 1000))
		return false;
	
	// check if exchange/number separator is either a'-' or ' '
	if (object_value.charAt(7) != "-" && object_value.charAt(7) != " ")
        return false;

	// make sure last for digits are a valid integer
	if (object_value.charAt(8) == "-" || object_value.charAt(8) == "+")
        return false;
	else
	{	return (_CF_checkinteger(object_value.substring(8,12))); }
}
	
	
	
function _CF_checkzip(object_value)
{	if (object_value.length == 0)
		return true;

	if (object_value.length != 5 && object_value.length != 10)
		return false;

	if (object_value.charAt(0) == "-" || object_value.charAt(0) == "+")
		return false;

	if (!_CF_checkinteger(object_value.substring(0,5)))
		return false;

	if (object_value.length == 5)
		return true;

	if (object_value.charAt(5) != "-" && object_value.charAt(5) != " ")
		return false;

	if (object_value.charAt(6) == "-" || object_value.charAt(6) == "+")
		return false;

	return (_CF_checkinteger(object_value.substring(6,10)));
}
	
	

function _CF_checktin(object_value)
{  	var white_space = " -+.";
	var ssc_string="";
	var check_char;

	if (object_value.length == 0)
		return true;

	if (object_value.length != 10)
		return false;

	if (object_value.charAt(2) != "-" && object_value.charAt(2) != " ")
		return false;

	for (var i = 0; i < object_value.length; i++)
	{	check_char = white_space.indexOf(object_value.charAt(i));
		if (check_char < 0)
			ssc_string += object_value.substring(i, (i + 1));
	}

	if (ssc_string.length != 9)
		return false;

	if (!_CF_checkinteger(ssc_string))
		return false;

	return true;
}


 
function _CF_checkssc(object_value)
{  	var white_space = " -+.";
	var ssc_string="";
	var check_char;

	if (object_value.length == 0)
		return true;

	if (object_value.length != 11)
		return false;

	if (object_value.charAt(3) != "-" && object_value.charAt(3) != " ")
		return false;

	if (object_value.charAt(6) != "-" && object_value.charAt(6) != " ")
		return false;

	for (var i = 0; i < object_value.length; i++)
	{	check_char = white_space.indexOf(object_value.charAt(i));
		if (check_char < 0)
			ssc_string += object_value.substring(i, (i + 1));
	}

	if (ssc_string.length != 9)
		return false;

	if (!_CF_checkinteger(ssc_string))
		return false;

	return true;
}
//-->
