function childsOf(node, name, visitor) {
  if (!node)
    return;	
  var nodes = node.childNodes;
  for (var i = 0; i < nodes.length; ++i) {
    var node = nodes[i];
    if (node.nodeName != name)
      continue;
    visitor(node);
  }
}
function hookChannels() {
  childsOf(document.getElementById("channels"), "UL", function(ul) {
    childsOf(ul, "LI", function(li) {
      childsOf(li, "UL", function(ul) {
        ul.onclick = function(e) {
          if (!e) var e = window.event;
          if (e.stopPropagation)
            e.stopPropagation();
          else
            e.cancelBubble = true;
        };
      });
      li.onclick = function() {
        if (this.className.indexOf("expanded") >= 0)
          this.className = this.className.replace(/\bexpanded\b/, "");
        else
          this.className += " expanded";
      };
    });
  });
}
window.onload = hookChannels;
