/*
$(document).ready(function(){
  // This code is executed after the DOM has been completely loaded 
  // Changing thedefault easing effect - will affect the slideUp/slideDown methods: 
  $.easing.def = "easeOutBounce";
  // Binding a click event handler to the links: 
  $('li.xbutton a').click(function(e){
    // Finding the drop down list that corresponds to the current section: 
    var dropDown = $(this).parent().next();
    // Closing all other drop down sections, except the current one 
    $('.xdropdown').not(dropDown).slideUp('slow');
    dropDown.stop(false,true).slideToggle('slow');
    // Preventing the default event (which would be to navigate the browser to the link's address) 
    e.preventDefault();
  })
});
*/

/* * * *
 *
 * Código de:
 * http://www.davidrojas.net/index.php/jquery/screencast-como-hacer-un-plugin-jquery-menu-acordeon-multinivel/
 *
 *
 * http://www.noupe.com/css/7-advanced-css-menu-for-your-next-design.html
 * http://13styles.com/
 *
 * http://www.htmldog.com/articles/suckerfish/dropdowns/example/
 *
 */
 
$(function(){
  
  (function($){
      
    $.fn.accordion = function(custom) {
      
      var defaults = {
        keepOpen: false,
        startingOpen: false
      } 
        
      var settings = $.extend({}, defaults, custom);
      
      if(settings.startingOpen){
        $(settings.startingOpen).parent().show();
        $(settings.startingOpen).parent().parent().parent().show();
      }
      
      return this.each(function(){
        var obj = $(this);
        $('li a', obj).click(function(event){
          
          var elem = $(this).next();
          
          if(elem.is('ul')){
          
            event.preventDefault();
          
            if(!settings.keepOpen){
              obj.find('ul:visible').not(elem).not(elem.parents('ul:visible')).slideUp();
            }
          
            elem.slideToggle();
          
          }

        });
      });
    };
  })(jQuery);
  
  $('#xmenu').accordion({keepOpen:false, startingOpen: '.active'});

});

