var CQ = {
  init: function() {
    this.activate_menu('menu-items');
    this.activate_menu('submenu');
  },

  activate_menu: function(element) {
    if (typeof(element) == 'string')
      var menu = document.getElementById(element);
    else var menu = element;
    if (menu) {
      var url = String(window.location.pathname);//.replace(/http:\/\/[^\/]+/g, '');
      for (var x=0; x<menu.childNodes.length; x++)
        if (menu.childNodes[x].nodeName == 'A') {
          var link = menu.childNodes[x].getAttribute('href')
          .replace(RegExp('https?:\/\/'+String(window.location.host)), '');
          if (link == '/') link = RegExp('^'+link+'$');
          else link = RegExp('^'+link);
          if (url.match(link))
            menu.childNodes[x].className = 'active';
        }
    }
  }
};

if ('attachEvent' in window) {
  window.attachEvent('onload', function(e) {
    CQ.init();
  });
} else {
  window.addEventListener('load', function(e) {
    CQ.init();
  }, false);
}