//jQuery.noConflict();

(function($) {

	$.fn.spasticNav = function(options) {
	
		options = $.extend({
			overlap : 0,
			speed : 500,
			reset : 50,
			color : '#FFFFFF',
			easing : 'easeOutExpo'
		}, options);
	
		return this.each(function() {
		
		 	var nav = $(this),
		 		currentPageItem = $('.current_page_item', nav),
		 		blob,
		 		reset;
		 		
		 	$('<li id="blob"></li>').css({
		 		width : currentPageItem.outerWidth(),
		 		height : currentPageItem.outerHeight() + options.overlap,
		 		left : currentPageItem.position().left,
		 		top : currentPageItem.position().top - options.overlap / 2,
		 		backgroundColor : options.color
		 	}).appendTo(this);
		 	
		 	blob = $('#blob', nav);
					 	
			$('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
					}
				);
				
				//color
				$('.current_page_item').find('a').css('color', '#6f0e73');
				$(this).find('a').css('color', '#ffffff');
			}, function() {
				// mouse out	
				reset = setTimeout(function() {
					
					blob.animate({
						width : currentPageItem.outerWidth(),
						left : currentPageItem.position().left
					}, options.speed)
					
					// delay color back
					$('.current_page_item').animate({marginTop:'0px'},350, function() {	
						$('.current_page_item').find('a').css('color', '#ffffff');
					});
					
				}, options.reset);
				
				$(this).find('a').css('color', '#6f0e73');
			});
		 
		
		}); // end each
	
	};

})(jQuery);
