function search()
{
  var searchstr = document.getElementById("searchstr").value
  if (searchstr != "")
  {
    if (searchstr.toLowerCase() == "rug" || searchstr.toLowerCase() == "rugs")
    {
      alert("Please be more specific")
      document.getElementById("searchstr").focus();
      return;
    }
    document.search.submit();
  }
}

function loginaccount()
{
  var x = document.getElementById("email").value;
  if (x == "")
  {
    alert("Please enter you email address");
    document.getElementById("email").focus();
    return;
  }
  if ( x.indexOf('@')==-1 || x.indexOf('.')==-1 || x.indexOf(' ')!=-1 || x.length<7 || !x)
  {
    alert('Please correct the email address');
    document.getElementById("email").focus();
    return;
  }

  if (document.getElementById("password").value == "")
  {
    alert("Please enter you password");
    document.getElementById("password").focus();
    return;
  }
  document.getElementById("command").value = "login";
  document.login.submit();
}

function makeaccount()
{
  var x = document.getElementById("email").value;
  if (x == "")
  {
    alert("Please enter you email address");
    document.getElementById("email").focus();
    return;
  }
  if ( x.indexOf('@')==-1 || x.indexOf('.')==-1 || x.indexOf(' ')!=-1 || x.length<7 || !x)
  {
    alert('Please correct the email address');
    document.getElementById("email").focus();
    return;
  }
  if (document.getElementById("password").value == "")
  {
    alert("Please enter a password");
    document.getElementById("password").focus();
    return;
  }
  document.getElementById("command").value = "make account";
  document.login.submit();
}

function forgottenpassword()
{
  var x = document.getElementById("email").value;
  if (x == "")
  {
    alert("Please enter you email address");
    document.getElementById("email").focus();
    return;
  }
  if ( x.indexOf('@')==-1 || x.indexOf('.')==-1 || x.indexOf(' ')!=-1 || x.length<7 || !x)
  {
    alert('Please correct the email address');
    document.getElementById("email").focus();
    return;
  }
  document.getElementById("command").value = "send password";
  document.login.submit();
}

function checkmyid(id)
{
  if (id == "") document.location.href = "my_account.php";
}

function changedetails()
{
  document.login.action = "my_details.php";
  document.login.submit();
}

function logout()
{
  document.getElementById("command").value = "logout";
  document.login.submit();
}

