function esEmail(str)  
{
  var supported = 0; 
  if (window.RegExp) { 
    var tempStr = "a"; 
    var tempReg = new RegExp(tempStr); 
    if (tempReg.test(tempStr)) 
      supported = 1; 
  } 
  if (!supported) 
    return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
  var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
  var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$"); 
  return (!r1.test(str) && r2.test(str)); 
}

function checkFirma(theForm)
{

 if (theForm.nombre.value == "")
  {
    alert("Por favor introduzca su nombre en el campo \"Nombre\".");
    theForm.nombre.focus();
    return (false);
  }

 if (theForm.email.value == "")
  {
    alert("Por favor introduzca su e-mail en el campo \"E-mail\".");
    theForm.email.focus();
    return (false);
  }

 if (theForm.mensaje.value == "")
  {
    alert("Ha olvidado indicar sus comentarios.");
    theForm.mensaje.focus();
    return (false);
  }


if (!esEmail(theForm.email.value))
  {
	alert("La dirección e-mail no es correcta. Escríbala de nuevo, por favor");
	theForm.email.focus();
	return (false);
  }
  var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@._-\t\r\n\f";
  var checkStr = theForm.Email.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("La dirección e-mail no es correcta. Escríbala de nuevo, por favor");
    theForm.email.focus();
    return (false);
  }

  return (true);
}
