// JavaScript Document
var warned=0; 

//------------------------------------
//Check for null or empty string
//------------------------------------
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

//-----------------------------------------------
// Returns true if string s is empty or 
// whitespace characters only.
// whitespace characters
//-----------------------------------------------
var whitespace = " \t\n\r";

function isWhitespace (s)

{ 
  var i;

    // Is s empty?
    if (isEmpty(s)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}


//---------------------------------------------------------
// isEmail (STRING s [, BOOLEAN emptyOK])
// 
// Email address must be of form a@b.c -- in other words:
// * there must be at least one character before the @
// * there must be at least one character before and after the .
// * the characters @ and . are both required
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.
//---------------------------------------------------------


function strLength( str )
  {
    var chkstr = str;   
		return (chkstr.length);
  }
//-----------------------------------------------
// Validate the string passed is all Numeric
//-----------------------------------------------
function validateNumeric( str )
{
  var checkOK = "0123456789.-";
  var checkStr = str
  var allValid = true;
  var decPoints = 0;
  var i,j,ch;
    
	
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++){	
			if (ch == checkOK.charAt(j)){
				break;
			}
							
			//if (ch == "."){  
			//	if (++decPoints > 1 )
			//		alert("False on Decimal Places");
			//		allValid = false;
			//}	
		} 
		if (j == checkOK.length){
				
				allValid = false;
		}			
	}
    return (allValid);  
}

//-----------------------------------------------
// Validate the string passed is all Alpha 
//-----------------------------------------------
function validateAlpha( str )
{
  var checkStr = str;
  var allValid = true;
  var checkOK = "0123456789";
  var decPoints = 0;
  var i,j,ch;
    
	for (i = 0;  i < checkStr.length;  i++){
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < checkOK.length;  j++){
			if (ch == checkOK.charAt(j)){
				allValid = false;
				break;   			
			}		
		}	
	}
	
	return (allValid);
}

function isValidEmail(str) {

   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);

}

function isEmail(s) {
email = s.value
AtPos = s.indexOf("@")
StopPos = s.lastIndexOf(".")
Message = ""

if (isWhitespace(s)) {
return false;
}

if (AtPos == -1 || StopPos == -1) {
return false;
}

if (StopPos < AtPos) {
return false;
}

if (StopPos - AtPos == 1) {
return false;
}

return true;
}