window.addEventListener("load", init, false);

function init(aEvent)
{
  var toolbar = document.getElementById("mail-bar2");
  var item = document.getElementById("search-container");
  toolbar.insertItem("button-credits", item, null, false);

  if (BASEnabled()){
    var folder = GetFirstSelectedMsgFolder();
    var user = folder.server.username;
    UpdateCreditsAsync = UpdateCredits(user);
    UpdateCreditsAsync.next();
  } else {
    var cr = document.getElementById("button-credits");
    cr.disabled = true;
    cr.label = "-";
  }
}

function OnCreditsClick(){
  var folder = GetFirstSelectedMsgFolder();
  var user = folder.server.username;
  UpdateCreditsAsync = UpdateCredits(user);
  UpdateCreditsAsync.next();
}

function OpenBASSettings(){
    window.openDialog("chrome://BAS/content/BASSettings.xul", "_blank", "chrome,resizable=no");
}