var MBWResidents = new Group('RHRMWEh0TFhQy+f3rMvn94');

DeclareUser('6horQu4aK0L/eav0/3mr9P','Em/b3h5v294gWa+DXFmvg0',[MBWResidents,'RqasMWtFfWM']);

// 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 = .1;
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['access'].style.display = 'none';
      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)",1000);
      break;
    case this.ccLogout:
      document.all['login'].style.display = '';
      document.all['logout'].style.display = 'none';
      document.all['access'].style.display = '';
      default_text();
  }
  return true;
}

function default_text()
{
  document.all['cnt'].innerHTML = "<p align='center'>"+"<font face='Times New Roman' color='#081C59' size='2'>"+"You must be logged in to view this content!"+"</font>"+"</p>";
  document.all['curuser'].innerHTML = "Log 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();
}

