//check the validity of a user entered email
function validEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {		// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)		// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}
					

function IsDigit( Ch )
	{
	if( (Ch >= '0') && (Ch <= '9') ) 
		return true;
	else 
		return false;
	}

function IsAlpha( Ch )
	{
	if( (Ch >= 'a') && (Ch <= 'z') ) return true;
	else if( (Ch >= 'A') && (Ch <= 'Z') ) return true;
	else return false;
	}

	function IsValidChar( Ch )
	{
		if(IsDigit(Ch) || IsAlpha(Ch))
			return true;
		else
			return false;
	}
		
function trim(strText) {
	// this will get rid of leading spaces 
	while (strText.substring(0,1) == ' ') 
		strText = strText.substring(1, strText.length)

	// this will get rid of trailing spaces 
	while (strText.substring(strText.length-1,strText.length) == ' ')
		strText = strText.substring(0, strText.length-1)

	return strText;
} 

function isNum(inputStr)
	{
		for(var i=0; i < inputStr.length; i++)
			if(IsDigit(inputStr.charAt(i)) == false)
				return false;

		return true;
	}
