function Check_email(mv_fieldname)
		{
			var mv_Str = mv_fieldname.value;
			if (mv_Str.length != 0)
			{
				var mv_Str = fnTrim(mv_Str);
				var erro = fnvalidateEmail(mv_Str);
		        if (erro == "err")
				{				
					return false;
				}
		   }
		}   

function fnvalidateEmail(pstr) 
	{
		var strtemp = pstr;
		strtemp = fnTrim(strtemp);
        if(strtemp != "")
        {
		   //check for @ and '.'and '_' and 1-9 and "a-z" and A-Z" in the email string
			for(var index = 0;index < strtemp.length;index++)
			{
				 if(!((strtemp.charAt(index) >="0" && strtemp.charAt(index) <= "9") ||(strtemp.charAt(index) == "@" || strtemp.charAt(index) == "." || strtemp.charAt(index)=="_" || strtemp.charAt(index)=="-") ||(strtemp.charAt(index) >= "a" && strtemp.charAt(index) <= "z" ) ||(strtemp.charAt(index) >= "A" && strtemp.charAt(index) <= "Z")))
				{
				return "err";
				break;
				}
			}              
			if(strtemp.indexOf("@") ==-1 || strtemp.indexOf(".") ==-1 ||strtemp.length<6)
			{
				return "err"; 
			}     
		}
	}

function fnRTrim(pstr)
	{
		 var strtemp = pstr;
		 while( strtemp.length > 0 && strtemp.charAt(strtemp.length-1) == " "  )
		 {
		   strtemp = strtemp.substring(0,strtemp.length-1);
		 }
		return strtemp;
	}

function fnLTrim(pstr)
{
	var strtemp = pstr;
	while(strtemp.length > 0 && strtemp.charAt(0) == " " )
	{
		strtemp = strtemp.substring(1,strtemp.length)
	}
	return strtemp;
  }       

	function fnTrim(pstr)
	{
		return fnLTrim(fnRTrim(pstr));
	}