(function($) {

    $.fn.spasticNav = function(options) {
    
        options = $.extend({
            overlap : 8,
            speed : 1000,
            reset : 1500,
            color : '#FFFFFF',
            easing : 'easeOutExpo',
            margin : 50
        }, options);
    
        return this.each(function() {
        
             var nav = $(this),
                 currentPageItem = $('li#selected', nav),
                 blob,
                 reset;
                 
             $('<li id="blob"></li>').css({
                 width : currentPageItem.outerWidth() - options.margin,
                 height : currentPageItem.outerHeight() + options.overlap,
                 left : currentPageItem.position().left + options.margin /4.5,
                 top : currentPageItem.position().top - options.overlap / 2,
                 backgroundColor : options.color
             }).appendTo(this);
             
             blob = $('#blob', nav);
             
            $('li.main:not(#blob)', nav).hover(function() {
                // mouse over
                clearTimeout(reset);
                blob.animate(
                    {
                        left : $(this).position().left + options.margin /4.5,
                        width : $(this).width() - options.margin
                    },
                    {
                        duration : options.speed,
                        easing : options.easing,
                        queue : false
                    }
                );
            }, function() {
                // mouse out    
                //reset = setTimeout(function() {
                //    blob.animate({
                //        width : currentPageItem.outerWidth(),
                //        left : currentPageItem.position().left
                //    }, options.speed)
                //}, options.reset);
    
            });
        
        }); // end each
    
    };

})(jQuery);
