function navigateTo(el) {
  var url = el.value;
  if (url!="") location = url;
}

function showsection(div) {
  YUI().use('node', function(Y) { var divs = Y.all('div.collapse'); 
  for (var i=0; i < divs._nodes.length; i++) {
    var thisdiv = divs._nodes[i];
    hidediv(thisdiv.id);
  }
  if (div == '' || div == null) {
    showdiv('s1');
  } else {
    showdiv(div);
  }
  });
}

function togglesection(div) {
  var d = document.getElementById(div);
  if(d) {
    if (d.style.display != "none") hidediv(div)
    else showdiv(div)
  }
}

function showdiv(div) {
  var d = document.getElementById(div);
  if(d) {
    d.style.display = "";
  }
}

function hidediv(div) {
  var d = document.getElementById(div);
  if (d) {
    d.style.display = "none";
  }
}

function initSection() {
  var url = new String(window.location);
  var index = url.indexOf('#')+1;
  var newdiv = url.substr(index);
  DEBUG = index;
  if (index > 0) showsection(newdiv);
  else showsection('');
}

YUI({timeout: 10000}).use("io",
    function(Y) {
      var div = Y.Node.get('#menuModule');
      function successHandler(id, o){
        div.set("innerHTML", o.responseText);
      }
      function failureHandler(id, o){
        div.set("innerHTML", o.status + " " + o.statusText);
      }
      function getModule(){
        var sUrl = "menu.html";
        var request = Y.io(sUrl, {
          method:"GET",
          on:
            {
              success:successHandler,
              failure:failureHandler
            }
          }
        );
      }
      Y.on("domready", getModule);
      Y.on("domready", initSection);
    }
  );