jQuery.fn.menu = function () {
  // get jQuery version of 'this'
  var $input = jQuery(this);
  $input.find('ul').hide();
  $input.find('li a').click(onClick);
  return $input;
  /*return this.each(function () {
  });*/
  function onClick() {
    var checkElement = $(this).next();
    if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
      //console.debug('entra', $(this));
      $(this).parent().find('ul').slideUp('normal');
      return false;
    }
    if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
      $(this).find('ul:visible').slideUp('normal');
      checkElement.slideDown('normal');
      return false;
    }
  }
};

