function trim(str){return str.replace(/^\s*|\s*$/g,"");}
function validarEmail(campo)
 {
  if(campo.value == "")return;
  if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo.value))
   {
     return (true)
   }
  else
   {
    alert("La dirección de email no es valida.");
    campo.focus();
	return false;
   }
 }
function validarAlpha(campo)
 {
  if(trim(campo.value) == "")return;
  if (/^[A-Za-z\s]+$/.test(trim(campo.value)))
   {
    return (true)
   }
  else
   {
    return false;
   }
 }
function validarAlphaNumerico(campo)
 {
  if(trim(campo.value) == "")return;
  if (/^[A-Za-z]+$/.test(trim(campo.value)))
   {
    return (true)
   }
  else
   {
    return false;
   }
 }
function validacion_campos()
 {
  valor1 = trim(this.document.RESULTS.realname.value);
  valor2 = trim(this.document.RESULTS.Telefono.value);
  valor3 = trim(this.document.RESULTS.Fax.value);
  valor4 = trim(this.document.RESULTS.realname.value);
  valor5 = trim(this.document.RESULTS.email.value);
  valor6 = trim(this.document.RESULTS.Comentarios.value);
  if(valor1.length==0)
   {
    alert("El campo nombre es necesario.");
    this.document.RESULTS.realname.focus();
   }
  else if(valor2.length==0)
   {
    alert("El campo telefono es necesario.");
    this.document.RESULTS.Telefono.focus();
   }
  else if(valor5.length==0)
   {
    alert("El campo email es necesario.");
    this.document.RESULTS.email.focus();
   }
  else if(valor6.length==0)
   {
    alert("El campo comentarios es necesario.");
    this.document.RESULTS.Comentarios.focus();
   }     
  else if(!validarAlpha(this.document.RESULTS.realname))
   {
    alert("El campo nombre no es valido,(campo alfanumerico).");
    this.document.RESULTS.realname.focus(); 
   }  
  else
   {
    if(validarEmail(this.document.RESULTS.email)){    
    this.document.RESULTS.submit();
    }
   }
 }