(function($){
	
	$.fn.spasticNav = function(options){
		options = $.extend({
			overlap: 10,
			speed: 500,
			reset: 1000,
			color: '#0b2b61',
			easing: 'easeOutExpo'
		}, options);
		
		return this.each(function(){
			var $nav = $(this),	
				currentPageItem = $('.selected', $nav),
				$blob,
				reset;
		
		//todo: handle no currentpageitem
		
			$blob = $('<li id="blob"></li>').css({
				width: currentPageItem.outerWidth() + options.overlap,
				height: currentPageItem.outerHeight() + options.overlap,
				left: currentPageItem.position().left - options.overlap /2,
				top: currentPageItem.position().top - options.overlap /2,
				backgroundColor : options.color
			}).appendTo($nav);
		
			$('li:not(#blob)', $nav).hover(function(){  //mouse over
				clearTimeout(reset);
				$blob.animate(
					{ 
						width: $(this).width() + options.overlap,
						left: $(this).position().left - options.overlap /2
				
					},
					{
						duration: options.speed,
						easing: options.easing,
						queue: false
					}
				);
			}, function(){ //mouse out
				reset = setTimeout(function(){
					$blob.animate({
						width: currentPageItem.outerWidth() + options.overlap,
						left: currentPageItem.position().left - options.overlap /2
					}, options.speed)
				}, options.reset);
			});
		
		
		});
		
	}
	
})(jQuery);
