function Staff_Console() {
  this.loaded = 0;
  
  this.root = "";
  
  this.display = [];
  this.display['login'] = 0;
  
  this.options = [];
  this.options['addevent'] = new Array("staff/events/add.php",550,500);
  this.options['editevent'] = new Array("staff/events/edit.php",550,500);
  this.options['addcommunity'] = new Array("staff/community/add.php",550,500);
  this.options['editcommunity'] = new Array("staff/community/edit.php",550,500);
  this.options['addpoll'] = new Array("staff/polls/add.php",375,450);
  this.options['polls'] = new Array("staff/polls/",450,600);
  this.options['createalbum'] = new Array("staff/photos/create_album.php",425,275);
  this.options['editalbum'] = new Array("staff/photos/edit_album.php",425,275);
  this.options['upload'] = new Array("staff/photos/upload.php",425,275);
  this.options['uploadmultiple'] = new Array("staff/photos/upload_multiple.php",425,400);
  this.options['editphoto'] = new Array("staff/photos/edit_photo.php",425,200);
  
  this.page = "";
  this.edit = "";
}

function staff_console_initialize() {
  var section = "";
  
  with (this) {
    if (Site.loaded == 2) {
      loaded = 1;
      root = Site.root;
    } else {
      window.setTimeout('Staff.Initialize()',10);
    }
  }
}

function staff_console_login() {
  var box;
  var frame;
  var opts;
  
  with (this) {
    if (loaded == 1) {
      box = $('staff_login_box');
      frame = $('staff_login_frame');
      
      if (box) {
        switch (display['login']) {
        case 0:
          frame.src = root+"staff/index.php";
          parent.Site.blanket = 0;
          parent.Site.Overlay();
          box.style.visibility = "visible";
          box.style.display = "inline";
          break;
        case 1:
          
          box.style.visibility = "hidden";
          box.style.display = "none";
          parent.Site.blanket = 1;
          parent.Site.Overlay();
          break;
        }
        
        display['login'] = (display['login'] == 0 ? 1 : 0);
      }
    }
  }
}

function staff_console_refresh(opt) {
  var frame;
  
  with (this) {
    if (loaded == 1) {
      frame = $('staff_'+opt+'_frame');
      
      if (frame) {
        frame.src = frame.src;
      }
    }
  }
}

function staff_console_updatepage() {
  with (this) {
    if (loaded == 1) {
      parent.location.href = parent.location.href;
    }
  }
}

function staff_console_option(opt) {
  var box;
  var frame;
  
  with (this) {
    if (loaded == 1) {
      box = $('staff_options_box');
      frame = $('staff_options_frame');
      
      if (opt == "") {
        if (box) {
          box.style.visibility = "hidden";
          box.style.display = "none";
          frame.src = "";
          frame.width = 1;
          frame.height = 1;
          Login();
          parent.Site.blanket = 0;
          parent.Site.Overlay();
        }
      } else if (options[opt]) {
        if (box) {
          frame.width = options[opt][1];
          frame.height = options[opt][2];
          frame.src = root+options[opt][0]+edit;
          box.style.visibility = "visible";
          box.style.display = "inline";
          Login();
          parent.Site.blanket = 0;
          parent.Site.Overlay();
          
          edit = "";
        }
      }
    }
  }
}

function staff_console_edit(opt,num) {
  with (this) {
    if (loaded == 1) {
      edit = "?id="+num;
      Option(opt);
      Login();
      parent.Site.blanket = 0;
      parent.Site.Overlay();
    }
  }
}

function staff_console_logout() {
  with (this) {
    if (loaded == 1) {
      parent.location.href = root+"staff/logout.php?page="+parent.Site.page;
    }
  }
}

Staff_Console.prototype.Initialize = staff_console_initialize;
Staff_Console.prototype.Login = staff_console_login;
Staff_Console.prototype.Refresh = staff_console_refresh;
Staff_Console.prototype.UpdatePage = staff_console_updatepage;
Staff_Console.prototype.Option = staff_console_option;
Staff_Console.prototype.Modify = staff_console_edit;
Staff_Console.prototype.Logout = staff_console_logout;

var Staff = new Staff_Console();
    Staff.Initialize();

