/* ======================================
 * Navigation.js
 *
 * Author: Ward Peeters - warrepeeters@gmail.com
 * Website: http://coding-tech.com
 *
 * Description: This will create the drop down menu's on the website
 ===================================== */

(function($) {
    $.fn.Navigation = function(options) {
        // init
        var defaults = {
            speed: 100
        }
        var options = $.extend(defaults, options);

        var action = {
            show: function() {
                return $(this).each(function() {
                    $(this).show();
                    $(this).animate({width: "168px"}, {
                        queue: false,
                        duration: options.speed
                    });
                });
            },
            hide: function() {
                return $(this).each(function() {
                    $(this).animate({width: 0}, {
                        queue: false,
                        duration: options['speed'],
                        complete: function() { $(this).hide() }
                    });
                });
            }
        }

        return this.each(function() {
            // hide all ul in an li
            $(this).find('li ul').hide();
            $(this).find('li', this)
                .bind('mouseover', function() {
                    action.show.apply($(this).children('ul'));
                })
                .bind('mouseleave', function() {
                    action.hide.apply($(this).children('ul'));
                })

        });
    };
})(jQuery);

$(function() {
   $('#navigation').Navigation();
});
