<!--
//Javascript 

/******************************************************
FUNCTION: 	test_email
ARGS: 		in_email
PURPOSE: 	tests if email is valid (contains at least 
			three characters , one dot and one @ symbol)
RETURNS: 	0 if valid, non-zero if invalid
******************************************************/
function test_email(in_email) {
	var tmp_chr;
	at_cnt = 0;
	dot_cnt = 0;
	char_cnt = 0;
	
	email_len = in_email.length;
	
	if (email_len == 0)
		return("99");
	else {
		for (i=0;i<email_len;i++) {
	    	tmp_chr = in_email.substring(i,i+1);
			if (tmp_chr == "@")
				at_cnt = at_cnt + 1;
			else
				if (tmp_chr == '.')
					dot_cnt = dot_cnt + 1;
				else
					char_cnt = char_cnt + 1;
		}
		if (at_cnt != 1) 
			return("1");
		else if (dot_cnt < 1)
			return("2");
		else if (char_cnt < 3)
			return("3");
	}
	return("0");
}


/*******************************************************************
FUNCTION: 	val_zip
ARGS: 		in_zip
PURPOSE: 	tests if zip is valid (five digits long)
RETURNS: 	true or false
********************************************************************/
function val_zip(in_zip) {	
	var tmp_chr;
	var num_cnt = 0;
	var bad_chr_cnt = 0;
	zip_len = in_zip.length;

	//alert("IN ZIP: " + in_zip + ".");
	if (zip_len == 0)
		return false;
	else {
		for (i=0;i<zip_len;i++) {
	    	tmp_chr = in_zip.substring(i,i+1);		
			isnum_val = isnum(tmp_chr);
			if (isnum_val == "yes")
				num_cnt = num_cnt + 1;
			else
				bad_chr_cnt = bad_chr_cnt + 1;
		}
		if ((num_cnt != 5) || (bad_chr_cnt > 0))
			return false;
		else
			if (bad_chr_cnt > 0)
				return false;
	}
	return true;
}

/*******************************************************************
FUNCTION: 	val_date
ARGS: 		in_date
PURPOSE: 	tests if date is valid (in mm/dd/yy format)
RETURNS: 	0 or non-zero
********************************************************************/
function val_date(in_date) {
	var isnum_val, tmp_chr, slash_cnt, mo, da, yr;
	tmp_chr = "";
	slash_cnt = 0;
	mo = "";
	da = "";
	yr = "";
	isnum_val = "";
		
	//alert(in_date);
	for (i=0;i<in_date.length;i++) {
	    tmp_chr = in_date.substring(i,i+1);
		if (tmp_chr == '/') {
			//alert("Found divider");
		    slash_cnt++;
			if (slash_cnt > 2)
			    return(1);
		}
		else {
			isnum_val = isnum(tmp_chr);
			if (isnum_val == "yes") {
				if (slash_cnt == 0)
					mo = mo + tmp_chr;
				else if (slash_cnt == 1)
					da = da + tmp_chr;
				else if (slash_cnt == 2)
					yr = yr + tmp_chr;
			}
			else
			    return(2);
		}
	}

	if ((mo.length > 0 && mo.length <= 2) &&
		(da.length > 0 && da.length <= 2) &&
	    (yr.length == 2 || yr.length == 4))
		return(0);
	else
		return(3);
}

/*******************************************************************
FUNCTION: 	alphanumeric
ARGS: 		string
PURPOSE: 	tests if string is alphanumeric or not
RETURNS: 	true if alphanumeric, false if not
********************************************************************/
function alphanumeric(alphanum)
{
	var numaric = alphanum;
	for(var j=0; j<numaric.length; j++)
		{
		  var alphaa = numaric.charAt(j);
		  var hh = alphaa.charCodeAt(0);
		  if((hh > 47 && hh<59) || (hh > 64 && hh<91) || (hh > 96 && hh<123))
		  {
		  }
		else	{
			 return false;
		  }
		}
 return true;
}


/******************************************************
FUNCTION: 	test_email
ARGS: 		in_email
PURPOSE: 	tests if email is valid (contains at least 
			three characters , one dot and one @ symbol)
RETURNS: 	0 if valid, non-zero if invalid
******************************************************/
function test_email(in_email) {
	var tmp_chr;
	at_cnt = 0;
	dot_cnt = 0;
	char_cnt = 0;
	email_len = in_email.length;
	
	if (email_len == 0)
		return("99");
	else {
		for (i=0;i<email_len;i++) {
	    	tmp_chr = in_email.substring(i,i+1);
			if (tmp_chr == "@")
				at_cnt = at_cnt + 1;
			else
				if (tmp_chr == '.')
					dot_cnt = dot_cnt + 1;
				else
					char_cnt = char_cnt + 1;
		}
		if (at_cnt != 1) 
			return("1");
		else if (dot_cnt == 0)
			return("2");
		else if (char_cnt == 3)
			return("3");
	}
	return("0");
}

/*********************************************
FUNCTION: isnum
ARGS: in_str
PURPOSE: tests if passes string is all numeric
RETURNS: "yes" or "no"
*********************************************/
function isnum(in_str) {
	var ret_code, i, tmp_chr;
	ret_code = "no";
	
	for (i=0;i<in_str.length;i++) {
	    tmp_chr = in_str.substring(i,i+1);
		if (tmp_chr == '0' || tmp_chr == '1' || tmp_chr == '2' || tmp_chr == '3' || tmp_chr == '4' || tmp_chr == '5' || tmp_chr == '6' || tmp_chr == '7' || tmp_chr == '8' || tmp_chr == '9')
			ret_code = "yes";
		else {
			ret_code = "no";
			break;
		}
	}
	return(ret_code);
}


/******************************************************
FUNCTION: 	test_tel
ARGS: 		in_tel
PURPOSE: 	tests if tel is valid (contains at least 
			seven numbers)
RETURNS: 	0 if valid, non-zero if invalid
******************************************************/
function test_tel(in_tel) {
	var tmp_chr;
	var num_cnt = 0;
	var bad_chr_cnt = 0;
	tel_len = in_tel.length;

	if (tel_len == 0)
		return("99");
	else {
		for (i=0;i<tel_len;i++) {
	    	tmp_chr = in_tel.substring(i,i+1);		
			isnum_val = isnum(tmp_chr);
			if (isnum_val == "yes")
				num_cnt = num_cnt + 1;
			else
				if (tmp_chr != '(' && tmp_chr != ')' && tmp_chr != '-')
					bad_chr_cnt = bad_chr_cnt + 1;
		}
		if (num_cnt < 7) 
			return("1");
		else if (bad_chr_cnt > 0)
			return("2");
	}
	return("0");
}

//Gets the Value of the Radio Button
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

//Checks the state of the check boxes and returns True of False
function checkbox_checker(checkObj) {
	if ((checkObj).checked)
		return true;
	else
		return false;
}

function describe_checked_item(check_true_false,desc) {
	if (check_true_false == true)
		return desc;
	else
		return "";
}

function build_check_list_desc() {
	var i;
	var check_list_desc;
	var args;
	check_list_desc = "";
	
	args=build_check_list_desc.arguments
		
	for (i=0;i<args.length;i++)
		if (args[i].length > 0)
			if (check_list_desc == "")
				check_list_desc = args[i];
			else
				check_list_desc = check_list_desc + ", " + args[i];
	return check_list_desc;
}
-->
