      
  function Login_ParseCookies()
  {
    if (document.cookie != null)
    {
      var cookies = document.cookie.split(";");
      if (cookies.length > 0)
      {
        for (var i=0; i<cookies.length; i++)
        {
          var tagNameIndex = cookies[i].indexOf(window.loginCookieName + "=");
          if (tagNameIndex == 0 || 
              tagNameIndex == 1)
          {
            var data = cookies[i].substring((tagNameIndex + 1) + window.loginCookieName.length);
            if (data.length > 0)
            {
              var cookieElements = data.split("|");
              for (j=0; j<cookieElements.length; j++)
              {
                if (cookieElements[j].indexOf("username=") == 0)
                {
                  if (self.document.forms["submitForm"] != null &&
                      self.document.forms["submitForm"]["username"] != null )
                  {
                    self.document.forms["submitForm"]["username"].value = cookieElements[j].substring("username=".length);
                  }
                }
                else if (cookieElements[j].indexOf("password=") == 0)
                {
                  if (self.document.forms["submitForm"] != null &&
                      self.document.forms["submitForm"]["password"] != null )
                  {                
                    self.document.forms["submitForm"]["password"].value = cookieElements[j].substring("password=".length);
                  }
                  if (self.document.forms["submitForm"] != null &&
                      self.document.forms["submitForm"]["remember_password_checkbox"] != null )
                  {                
                    self.document.forms["submitForm"]["remember_password_checkbox"].checked = true;
                  }                  
                }
              }
            }
          }
        }
      }
    }
  }

  function Login_ExportCookie()
  {
    var ckdate = new Date();
    var username = self.document.forms["submitForm"]["username"].value;
    var password = self.document.forms["submitForm"]["password"].value;
    var savePasswordDays = 0;
    var savePassword = self.document.forms["submitForm"]["remember_password_checkbox"].checked;
    if (savePassword == true)
    {
      savePasswordDays = 365;
    }
    ckdate.setTime(ckdate.getTime() + (savePasswordDays * 24 * 60 * 60 * 1000));
    document.cookie = window.loginCookieName + "=" +
                      "username=" + username + 
                      "|password=" + (savePassword == true ? password : "") + 
                      ";expires=" + ckdate.toGMTString();
  } 


  function Login_OnSubmit()
  {
    if (self.document.forms["submitForm"]["username"].value == "")
    {
      alert("Username is required.\n");
      self.document.forms["submitForm"]["username"].focus();
      return false;
    }
    if (self.document.forms["submitForm"]["password"].value == 0)
    {
      alert("Password is required.\n");
      self.document.forms["submitForm"]["password"].focus();
      return false;
    }
    Login_ExportCookie();
    self.document.forms["submitForm"].submit();
    return false;
  }


