var group_bestuur = new Group('xQGSL8kBki/4q8n8aKvJ/C');

DeclareUser('4uBSX+7gUl/9bfCiWW3wog','xQGSL8kBki/4q8n8aKvJ/C',[group_bestuur,'bStmbpvwvD']);

// This keeps track of the users to they dont need to log in
// every time the load a new page
var S = new Session('my_session');
S.Callback = s_cb; // function s_cb defined below
// if the user doesn't come back after 48 hours, he'll need to login again:
S.nCookieExpirationDelay = 48;
S.bLocationLogin = true;

// Resource callback. Called before and after a resource gets decrypted
function r_cb(context,lparam)
{
  if(context == this.ccAfterDecrypt)
  {
    if(!lparam)
      document.all['cnt'].innerHTML = "Error!";
    else
      document.all['cnt'].innerHTML = lparam;
  } else if(context == this.ccInvallidMaster)
  {
    document.all['cnt'].innerHTML = "You do not have the right to view this page!";
  }
  return true;
}

// Session callback. Called on login / logout
function s_cb(context,lparam)
{
  switch(context)
  {
    case this.ccLogin:
      document.all['login'].style.display = 'none';
      document.all['logout'].style.display = '';
      document.all['username'].value = '';
      document.all['password'].value = '';
      document.all['cnt'].innerHTML = "Loading...";
      document.all['curuser'].innerHTML = this.sUserName;
// Trick: use a setTimeout to decrypt the page content in order to let the browser
// update the page with the changes we made above before beginning decryption
      setTimeout("Content.DecryptResourceS(S)",0);
      break;
    case this.ccLogout:
      document.all['login'].style.display = '';
      document.all['logout'].style.display = 'none';
      default_text();
  }
  return true;
}

function default_text()
{
  document.all['cnt'].innerHTML = "You are not logged in!";
  document.all['curuser'].innerHTML = "not logged in";
}

function login() // called by 'login' button
{
  S.UserLogin(
	document.all['username'].value,
	document.all['password'].value,
	document.all['usecookies'].checked
  );
}

function logout() // called by 'logout' button
{
  S.Logout();
}

