function mOut(src,clrIn)  { 
	if (!src.contains(event.toElement)) { 
		src.style.cursor = 'default'; 
		src.bgColor = clrIn; 
	}
} 

function mOvr(src,clrOver){ 
	if (!src.contains(event.fromElement)) { 
		src.style.cursor = 'hand'; 
		src.bgColor = clrOver; 
	}
}

function isEmpty(s)
{  
	return ((s == null) || (s.length == 0))
}

function isWhitespace (s)
{  
  var whitespace = " \t\n\r";
  var i;

   for (i = 0; i < s.length; i++)
   {   
       var c = s.charAt(i);
       if (whitespace.indexOf(c) >= 0) 
	   {
		  return true;
	   }
   }

   return false;
}

function isCharsInBag (s, str)
{  
  var i;
  for (i = 0; i < s.length; i++)
  {   
      var c = s.charAt(i);
      if (str.indexOf(c) == -1) return false;
  }
  return true;
}

function isEmail (s)
{
    if (isEmpty(s))
	{
		window.alert("Please enter your email!");	
		return false;
	}
    if (isWhitespace(s))
	{
		window.alert("Whitspace is not valid!");	
		return false;
	}
   var i = 1;
   var len = s.length;
	pos1 = s.indexOf("@");
	pos2 = s.indexOf(".");
	pos3 = s.lastIndexOf("@");
	pos4 = s.lastIndexOf(".");

	if ((pos1 <= 0)||(pos1 == len)||(pos2 <= 0)||(pos2 == len))  
	{
		window.alert("Please enter correct email.");
		return false;
	}
	else
	{

		if( (pos1 == pos2 - 1) || (pos1 == pos2 + 1) 
		  || ( pos1 != pos3 )  //find two @
		  || ( pos4 < pos3 ) ) //. should behind the '@'  		
		{
			window.alert("Please enter correct email.");
			return false;
		}
	}

	if ( !isCharsInBag( s, "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789.-_@"))
	{
		window.alert("Some letter is not valid in your email");
		return false;
	}
	return true;
}