(function($) {

	$.fn.spasticNav = function(options) {

		options = $.extend({
			overlap : 20,
			speed : 1000,
			speed_reset : 300,
			reset : 1000,
			easing : 'easeOutExpo'
		}, options);

		return this.each(function() {

		 	var nav = $(this),
		 		currentPageItem = $('#selected', nav),
		 		blob,
		 		reset;

		 	$('<li id="blob"></li>').css({
		 		width : currentPageItem.outerWidth(),
		 		left : currentPageItem.position().left,
		 		display: 'none'
		 	}).appendTo(this).fadeIn(1000);

		 	blob = $('#blob', nav);

			$('ul.menu_data > li:not(#blob)').hover(function() {

				clearTimeout(reset);
				blob.animate(
					{
						left : $(this).position().left,
						width : $(this).width()
					},
					{
						duration : options.speed,
						easing : options.easing,
						queue : false
					}
				);
			}, function() {

				reset = setTimeout(function() {
					blob.animate({
						width : currentPageItem.outerWidth(),
						left : currentPageItem.position().left
					}, options.speed_reset)
				}, options.reset);

			});


		});

	};

})(jQuery);
