function clearAndFocus( el ) {

    if (el.getAttribute('initialValue')) {
      // do nothing
    } else {
      el.setAttribute ('initialValue', el.value);
      el.value = '';
    }
}


function validate_required(field,alerttxt)
{
with (field)
  {
  if (value==null||value=="")
    {
    alert(alerttxt);return false;
    }
  else
    {
    return true;
    }
  }
}


function validate_form(thisform) {

      var firstName = document.getElementById('t1');
      var surname = document.getElementById('t2');
      var email = document.getElementById('t3');
      var msg = '';
      var focus = false;

      if (firstName.value == '' || firstName.value == 'Firstname') {
          msg = ' - First Name must be filled out!\n';
          focus = (!focus)?firstName:focus;
      };
      if (surname.value == '' || surname.value == 'Surname') {
          msg += ' - Surname must be filled out!\n'
          focus = (!focus)?surname:focus;
      };
      if (email.value == '' || email.value == 'Email') {
          msg += ' - Email must be filled out!\n'
          focus = (!focus)?email:focus;
      } else if (!validate_email(email)) {
          msg += ' - Email must be filled out correctly!\n'
          focus = (!focus)?email:focus;
      }

      if (msg != '') {
          alert ('Correct the following:\n\n' + msg);
          focus.focus();
          return false;
      } else {
          return true;
      }
}


function validate_email(field)
{
with (field)
  {
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
  return (!(apos<1||dotpos-apos<2))
  }
}