(function($) {

	$.fn.spasticNav = function(options) {
	
		options = $.extend({
			speed : 500,
			reset : 100,
			easing : 'easeOutExpo',
			height : 10,
			color : "#712828"
		}, options);
	
		return this.each(function() {
		
		 	var nav = $(this),
		 		currentPageItem = $('.selected', nav),
		 		blob,
		 		reset;
		 	
			// Initial position
		 	$('<li id="blob"></li>').css({
		 		width : $('#nav').width,
		 		left : $('#nav').left - 10,
		 		top : 40,
				height: options.height,
		 		backgroundColor : options.color
		 	}).appendTo(this);
		 	
		 	blob = $('#blob', nav);
		
			// Animate to current position
			blob.animate(
				{
					left : currentPageItem.position().left,
					width : currentPageItem.outerWidth()
				},
				{
					duration : options.speed,
					easing : options.easing,
					queue : false
				}
			);
		 	
			$('li:not(#blob)', nav).hover(function() {
				
				// mouse over
				clearTimeout(reset);
				blob.animate(
					{
						left : $(this).position().left,
						width : $(this).width()
					},
					{
						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);
