
function trim(texto01) 
{
	while(texto01.substring(0,1) == ' ')
		texto01 = texto01.substring(1,texto01.length);

	while(texto01.substring(texto01.length-1,texto01.length) == ' ')
		texto01 =texto01.substring(0, texto01.length-1);   
	
	return texto01;
}

  ////
  function IsValidEmail (texto)
{
	var mail = 'abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ0123456789@._-';	
	text=trim(texto);		
	conta =0;
	conta2=0;

	for(i=0;i<text.length;i++)
	{		
		if(mail.indexOf(text.charAt(i)) == -1)
		{			
				return false;
		}		
		else
		{
				if(text.charAt(i) == '@')				{
					conta++;					
					if(conta > 1)
						return false;
				}
				if(text.charAt(i) == '.')
				{					
					conta2++;				
				}	
					
		}
	}
	if(conta==0 || conta2==0)
		return false;		
	
    return true;
} 




