Event.observe(window, 'load', function() {

  jar = new CookieJar({
      expires:3600,   // seconds
      path: '/'
  });

  // selectedTab = jar.get('selectedTab' + page);
  // jar.put('selectedTab' + page, {ix : x})

  $A($$("a.deleteJS")).each(deleteClick);

  var marca = $('CategoryBrandId')
  if (marca) {
    marca.onchange = function () {
      location.href = location.href.substring(0, location.href.indexOf('add') + 3) + '/' + this.options[this.options.selectedIndex].value
    }
  }

  //if (window["DHmenuvm"]) DHmenuvm()

  var ie6 = (window.external && typeof window.XMLHttpRequest == "undefined");

  if (ie6) setTimeout('$A($$("#menu .rootNode", "#menu .node")).each(catover)', 1000);

})

function catover(a) {
  var child = a.getElementsBySelector('.subchildren');
  if (child.length == 1) {
    var l = a.getElementsBySelector('a')[0];
    l.child = child[0]
    l.child._isover = false

    l.child.onmouseover = function() {
      l.child._isover = true
    }

    l.child.onmouseout = function() {
      l.child._isover = false
      setTimeout(l.closemenu, 100)
    }

    l.onmouseover = function() {
      this.child.show();
      return false;
    }
    l.onmouseout = function() {
      setTimeout(this.closemenu, 100)
      return false;
    }
    l.closemenu = function() {
      if (l.child._isover == false) l.child.hide();
    }
  }
}

function deleteClick(a) {
  a.onclick = function() {
    var msg = this.warning? this.warning : '¿Está seguro de querer borrar este registro?'
    if(confirm(msg)) {
      this.href += '/OK';
      return true
    }
    return false
  }
}
