



function check_email(x)
// This function checks if  x  is an emailaddress
{
  var b = /[\.\-@]{2}/;	// an emailadress may not contain two of these next to eachother
  var c = /^[\._\-]/;		// an emailadress may not start with these

  var m = /(^[A-Za-z0-9_\.\-]{2,})@([A-Za-z0-9\.\-\[\]]{6,})$/;
  var p = x.match(m);

  if (p!=null)
  {
    var d = /[\.\-]$/;		// an username may not end with these

    if ((!(b.test(x)))    &&
        (!(c.test(x)))    &&
        (!(d.test(p[1]))) &&
        ( check_subdomain(p[2]) ||
          check_domain(p[2])    ||
          check_IP(p[2])        )
       )
       { return true; }
  }

  return false;
}
