function textSizeClick(event) {
  var target = event.target;
  if (!target.internal_css) return;
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.executeMenuValue("text-size",target.internal_css);
  refreshTextSizes();
  document.getElementById("main-menu").hidePopup();
}
function refreshTextSizes() {
  var currentSize = YOONO_CMPT.getYServices().skin.getTextSize();
  var container = document.getElementById("text-sizes");
  for(var i=0; i<container.childNodes.length; i++) {
    var item = container.childNodes[i];
    if (item.internal_css == currentSize)
      item.setAttribute("selected","true");
    else
      item.removeAttribute("selected");
  }
}

function changeTextSize(aParam) {
  /*
  var textSizes = YServices.skin.getTextSizeList();
  for (var j in textSizes) {
    var ts = textSizes[j];
    textSizeHtml += '<div class="menu-text-size" text-size="' + ts.css + '">' + this.translateText(ts.name) + '</div>';
  }
  */
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.executeMenuValue("text-size",aParam);
}

function addNetwork() {
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.showFriendsAddService();
}

function showFriendsConfig(event) {
  var friends = YOONO_CMPT.getYServices().yoodgetInstances.getRegisteredYoodgetWrapper("{friends@yoono.com}",-1);
  friends.yoodget.toggleConfig(event);
}

function checkForUpdates()
{
  var um = 
    Components.classes["@mozilla.org/updates/update-manager;1"].
    getService(Components.interfaces.nsIUpdateManager);
  var prompter = 
    Components.classes["@mozilla.org/updates/update-prompt;1"].
    createInstance(Components.interfaces.nsIUpdatePrompt);

  // If there's an update ready to be applied, show the "Update Downloaded"
  // UI instead and let the user know they have to restart the browser for
  // the changes to be applied. 
  if (um.activeUpdate && um.activeUpdate.state == "pending")
    prompter.showUpdateDownloaded(um.activeUpdate);
  else
    prompter.checkForUpdates();
}

function register() {
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.showConfig('register');
}

function signIn() {
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.showConfig('signin');
}

function signOut() {
  var iframe = document.getElementById("main-iframe");
  var iframeWin = iframe.contentWindow;
  if (iframeWin.wrappedJSObject)
    iframeWin = iframeWin.wrappedJSObject;
  var sidebar = iframeWin.ynSidebar;
  sidebar.signIn_disableSidebar();
}
