// verify version 1.4.1 10/28/98
//		A bunch of little JavaScript routines writen my Matt Toledo to facilitate simple
//		tasks

// removeIllegal 	- this function filters out illegal characters from a form field.
//			  it returns the string sans the illegal characters.
function removeIllegal(value)
{
	illegal="$%@\#";
	newstr ='';
	for (i = 0; i < value.length; i++)
	{
		if (illegal.indexOf(value.charAt(i)) == -1)
		{
			newstr += value.charAt(i);
		}
	}
	return newstr;
}

// checkIfBlank		- this function checks to see if a form field contails nothing, or is all spaces.
//			  if it is all spaces or null then it returns true.  Not all spaces then returns 
//			  false.
function checkIfBlank(value)
{
	// see if null
	if (value.length <= 0)
	{
		return true;
	}
	
	// see if all blank
	space=' ';
	for (i = 0; i < value.length; i++)
	{
		if (value.charAt(i) != space)
		{
			return false;
		}
	}
	return true;
}

// removeNonPhone	- this function filters outs non phone number related characters.  It returns
//			  the filtered string
function removeNonPhone(value)
{
	legal='0123456789()-';
	newstr ='';
	for (i = 0; i < value.length; i++)
	{
		if (legal.indexOf(value.charAt(i)) != -1)
		{
			newstr += value.charAt(i);
		}
	}
	return newstr;
}

// removeNonNumber	- this function filters out any character that isn't a digit.  It returns the
//			  filtered string.
function removeNonNumber(value)
{
	legal='0123456789';
	newstr ='';
	for (i = 0; i < value.length; i++)
	{
		if (legal.indexOf(value.charAt(i)) != -1)
		{
			newstr += value.charAt(i);
		}
	}
	return newstr;
}

// removeSpace	- This function filters out all spaces and returns the string without spaces
function removeSpace(value)
{
	newstr ='';
	for (i = 0; i < value.length; i++)
	{
		if (value.charAt(i) != ' ')
		{
			newstr += value.charAt(i);
		}
	}
	return newstr;
}

// removeNonLetter	- this function filters out any character that aren't a number.  It returns the
//			  filtered string.
function removeNonLetter(value)
{
	legal='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
	newstr ='';
	for (i = 0; i < value.length; i++)
	{
		if (legal.indexOf(value.charAt(i)) != -1)
		{
			newstr += value.charAt(i);
		}
	}
	return newstr;
}

// isNumber - checks to see if the value is a number.  Returns true if it is valid.
	      function isNumber(value)
{
	legal='0123456789';
	for (i = 0; i < value.length; i++)
	{
		if (legal.indexOf(value.charAt(i)) == -1)
		{
			return false;
		}
	}
	return true;
}

// CheckYear 	- this function makes sure that the the value supplied is a valid 4 digit year.  If
//		  not valid, then the submitted value is returned as blank.
function checkYear(value)
{
	if (value.length < 4)
	{
		alert ("The year must be 4 digits in length.\nEXAMPLE: 1999\n");
		return "";
	}
	return value;
}

// CheckMonth 	- this function takes a look at a value, makes sure its a valid month.  If not valid,
//		  the value is reset to blank. 
function checkMonth(value)
{
	value = removeNonNumber(value);
	if ((value.length < 1) || (value.length > 2) || (parseInt(value) < 1) || (parseInt(value) > 12))
	{
		alert("This is not a valid month\nValid months are 1 through 12\n");
		return "";
	}
	return value;
}

// CheckDay 	- this function makes sure that the value sumbitted is a valid for the month.  If
//		  not valid, the value is reset to blank.
function checkDay(value)
{
	value = removeNonNumber(value);
	if ((value < 1) || (value > 31))
	{
		alert("Valid days are 1 - 31\n");
		return '';
	}
	return value;
} 	
	
// CheckHour	- this function makes sure that the value submitted is a valid hour 1 - 12
function checkHour(value)
{	
	value = removeNonNumber(value);
	if ((value < 1) || (value > 12))
	{
		alert("Valid hours are 1 - 12\n");
		return '';
	}
	return value;
}

// CheckMinute	- this function makes sure that the value submitted is a valid minute 00 - 59
function checkMinute(value)
{	
	value = removeNonNumber(value);
	if ((int(value) < 0) || (int(value) > 59))
	{
		alert("Valid minutes are 0 - 59\n You typed in: "+value+"\n");
		return '';
	}
	return value;
}


