/*
 * 
 * This drop down menu was build by Dennis Hoppe ( http://DennisHoppe.de )
 * The original ideas are from Christian Budschedl ( http://www.Kriesi.at )
 * and so the plugin got Kriesis name ;)  
 *
 * Usage example:
 * 
 * $(document).ready(function(){
 *   jQuery('ul#navigation').kriesi_dropdown();
 * });
 *  
 */

(function($){

  $.fn.kriesi_dropdown = function(options){
  
    // Default settings
    settings = {
      'width' : '10em' // Default width of the submenus, values in em/pt/px
    };
    
    // Merge User options
    if (options) $.extend(settings, options);
    
    // let the Menu drop...
    this
    .css({
      'margin': '0',
      'padding': '0',
      'list-style-type': 'none',
      'position': 'relative',
      'z-index': '1000'
    })

    .find('ul')
      .css({
        'display': 'none',
        'margin': '0',
        'padding': '0',
        'list-style-type': 'none',
        'position': 'absolute',
        'width': settings.width
      })
    .end()

    .find('a')
      .css({
        'display': 'block' 
      })
      .removeAttr("title")
    .end()

    .find('li ul a')
      .css({
        'width': settings.width,
        'float': 'left'
      })
    .end()

    .find('li ul ul')
      .css({
        'left': settings.width,
        'margin-right': '10px'
      })
    .end()

    .find('li')
      .css({
        'float': 'left',
        'position': 'relative'
      })
      .hover(function(){
        $(this)
        .find('ul:first')
          .css({
            visibility: "visible",
            display: "none"
          })
          .show();
        }, function(){
          $(this)
          .find('ul:first')
            .css({
              visibility: "hidden"
            });
      })
    .end();
    
    // Support chainability
    return this;
  };
  
})(jQuery);

