var mPrefix = "You did not enter a value into the "
var mSuffix = " field. This is a required field. Please enter it now."
  

/**
 * whiteSpace is a string that contains the standard white space
 * characters.
 * They are: space, carriage return, new line, tab, and form feed.
 * The whiteSpace string is used to evaluate if a single character
 * string is a white space character. For example, if chr is a variable
 * that contains a character and you want to know if it is a
 * whiteSpace character
 * if (whiteSpace.indexOf(chr) != -1)
 * will tell you as
 * indexOf()
 * will return -1 if the character in the chr variable
 * is not a character in the whiteSpace string.
 **/

 

var whitespace = " \r\n\t\f"

// Returns a string with trailing spaces stripped

function ltrim ( s ){
	return s.replace( /^\s*/, "" )
}

function rtrim ( s ){
	return s.replace( /\s*$/, "" );
}

function trim ( s ){
	return rtrim(ltrim(s));
}


function checkString(field, s, fname)
	{
		if ( trim(s).length < 1 )
			{
					field.focus();
					//form.custLastname.focus();
				    alert(mPrefix + fname + mSuffix);
					//alert("Please enter your LAST Name.");
					return false;
			}
		else {			return true;			}
	}



function checkEmail(field, strEmail, fname) {

		if ((strEmail.indexOf('@') < 0) || ((strEmail.charAt(strEmail.length-4) != '.') && (strEmail.charAt(strEmail.length-3) != '.'))) 
			{
				field.focus();
				alert("You have entered an invalid email address. \r\Please enter email as: xyz@abc.com");
				//signUpform.email.select();
				return false;
		} 
		
		else {
				return true;
	}
}


function isNumberString (InString)  {
		if(InString.length==0) return (false);
			var RefString="1234567890";
			for (Count=0; Count < InString.length; Count++)  {
			TempChar= InString.substring (Count, Count+1);
			if (RefString.indexOf (TempChar, 0)==-1)  
			return (false);
		}
		return (true);
	}


function checkNumber(field, strNumber, fname)
	{
		if  (isNumberString(strNumber) == 1 )
			{
					return true; 
			}
		else
			{		field.focus();
				alert("Please enter a number");
					return false;
			}
	}
