function chk_uname_len() {
  if(document.all.uname.value.length < 8 || document.all.uname.value.length >16)
  { alert("Invalid username\nA valid username is between 8 and 16 characters in length.");
    return false;
  } else return true;
}
function chk_passwd_len() {
  if(document.all.Pwd.value.length < 8 || document.all.Pwd.value.length >16)
  { alert("Invalid password");
    return false;
  } else return true;
}
function do_login(path){
  if(!chk_uname_len()) return false;
  if(!chk_passwd_len()) return false;
  window.open('','client','status=yes,scrollbars=yes,resizable=yes,width=800,height=600');
  document.all.loginfrm.target='client';
  document.all.loginfrm.action=path+'will/scripts/client_upd.php';
  document.all.loginfrm.submit();
  document.all.Pwd.value='';
}
function do_hint(){
  if(!chk_uname_len()) return false;
  pwin = window.open('','temp','status=no,scrollbars=yes,resizable=no,width=300,height=100');
  pwin.focus();
  document.all.loginfrm.target='temp';
  document.all.loginfrm.action='scripts/forgot_form.php';
  document.all.loginfrm.submit();
  document.all.loginfrm.target='_self';
}
function getNewPasswd(){
  if(confirm('If you have forgotten your password and the \'Password Hint\' has not helped\nthen check that your correct Username appears in the \'Client login\' panel and click on \'OK\' below.\nYou will then be emailed with a new password.'))
  {
    if(document.all.uname.value.length == 0)
      return false;
    if(!chk_uname_len())
      return false;
  }
  else
    return false;

  ewin = window.open('','temp','status=no,scrollbars=yes,resizable=no,width=300,height=120');
  ewin.focus();
  document.all.loginfrm.target='temp';
  document.all.loginfrm.action='scripts/forgot_passwd.php';
  document.all.loginfrm.submit();
  document.all.loginfrm.target='_self';
}

function chk_all()
{
  if(!chk_email(document.forms.reg.email.value))
  { alert("The email address you have entered is not valid. Please try again");
    return false; }

  if(document.forms.reg.username.value.length < 8 || document.forms.reg.username.value.length > 16)
  { alert("Your username must be between 8 and 16 characters long");
    return false; }

  if(document.forms.reg.passwd.value.length < 8 || document.forms.reg.passwd.value.length >16)
  { alert("Your password must be between 8 and 16 characters long");
    return false; }

  if(document.forms.reg.passwd.value.toLowerCase() != document.forms.reg.passwd2.value.toLowerCase())
  { alert("The passwords you entered do not match");
    return false; }

  if(document.forms.reg.hint.value.length == 0)
  { alert("Please enter a password hint.\nWe will show you this as a reminder if you forget your password");
    return false; }

  return true;
}

function dowin(path)
{
  window.open('','new','status=yes,scrollbars=yes,resizable=yes,width=800,height=600');
  document.forms.reg.target='new';
  document.forms.reg.action=path+'/will/scripts/register_upd.php';
  document.forms.reg.submit();
  document.forms.reg.passwd.value='';
  document.forms.reg.passwd2.value='';
  document.all.engorscotbox.style.visibility='hidden';
}
