function IsValidEmail(str){
	var at = '@';
	var dot = '.';
	var lat = parseInt(str.indexOf(at));
	var ldot = parseInt(str.lastIndexOf(dot));
	var lstr = parseInt(str.length);
	
	//no '@' or '@' is first character or '@' is the last character
	if ((lat <= 0) || (lat == parseInt(lstr-1)))
		return false;

	//no '.' or '.' is first character or '.' is the last character
	if ((ldot <= 0) || (ldot == parseInt(lstr-1)))
		return false;

	//presence of another '@'
	if (str.indexOf(at, parseInt(lat+1)) != -1) 
		return false;

	//presence of '.' before or after '@'
	if ((str.substr(parseInt(lat - 1), 1) == dot) || (str.substr(parseInt(lat + 1), 1) == dot))
		return false;

	//check '.' is at least one character after '@'
	if (str.indexOf(dot, parseInt(lat + 2)) == -1) 
		return false;

	//check for blank
	if (str.indexOf(" ") != -1) 
		return false;

	//check the length after the last '.' is not less than 2 characters
	if (str.substr(parseInt(ldot + 1)).length < 2) 
		return false;

	if (!IsAlphaNumeric(str.substr(ldot + 1)))
		return false;	
	
	return true;
}
function IsAlphaNumeric(str){
	for (i=0; i<str.length; i++){
		if (!((str.charCodeAt(i)>=97) && (str.charCodeAt(i)<=122)) && !((str.charCodeAt(i)>=65) && (str.charCodeAt(i)<=90)) && !((str.charCodeAt(i)>=48) && (str.charCodeAt(i)<=57))){
			return false;
		}
	}
	return true;
}


function Trim(str)
{
 while(str.charAt(0) == (" ") )
 {
  str = str.substring(1);
 }
 while(str.charAt(str.length-1) == " " )
 {
  str = str.substring(0,str.length-1);
 }
 return str;
}

function IsEmpty(v){
	varValue = Trim(v);
	if (varValue.length == 0){ return true; }else{ return false; }
}

function IsDigit(o,e) {
	if (!e) var e = window.event
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	if (((code < 48)||(code > 57 ))) 
	{
		if (code != 8 && code != 46 && code != 9 && code != 45 && code != 40 && code != 41)
		{
			return false;
		}
	}
}

function findObj(n){
	var d=document;
	x=d.getElementById(n);
	return x;
}