// Many thanks to http://www.xs4all.nl/~sbpoley/webmatters/formval.html

function trim(str)
{
  return str.replace(/^\s+|\s+$/g, '')
};

function validateEmail  (vfld)   // element to be validated
{
  var tfld = trim(vfld.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/
  if (!email.test(tfld)) {
    vfld.focus();
    return false;
  }

//  var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/
//  if (!email2.test(tfld))
//    msg (ifld, "warn", "Unusual e-mail address - check if correct");
//  else
//    msg (ifld, "warn", "");
  return true;
};

function validateOnSubmit() {
  var elem;
  var errs=0;
  if (!validateEmail  (document.getElementById('fromaddr'))) errs += 1; 
  if (errs>0) alert('Please give a valid email address so that\n we can reply to your enquiry.');
  return (errs==0);
};

function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=420,height=420,scrollbars=no');
return false;
}
