(function($) {

	$.fn.spasticNav = function(options) {
	
		options = $.extend({
			overlapX : 20,
			overlapY : 20,			
			speed : 500,
			reset : 1500,
			color : '#0b2b61',
			easing : 'easeOutExpo'
		}, options);
	
		return this.each(function() {
		
		 	var nav = $(this),
		 		currentPageItem = $('li.current_page_item, li.current_page_ancestor', nav),
		 		blob,
		 		reset;
			
			currentPageItem.children('a').css({color:'#ffffff'});			 	
			
		 	$('<li id="blob"></li>').css({
		 		width : currentPageItem.outerWidth() + options.overlapX,
		 		height : currentPageItem.outerHeight() + options.overlapY,
		 		left : currentPageItem.position().left - options.overlapX / 2,
		 		top : currentPageItem.position().top - options.overlapY / 2,
		 		backgroundColor : options.color
		 	}).appendTo(this);
		 	
		 	blob = $('#blob', nav);
		 	
			$('li:not(#blob)', nav).hover(function() {
				// mouse over
				$(this).not('.current_page_item, li.current_page_ancestor').children('a').css({color:'#ffffff'});
				clearTimeout(reset);
				blob.animate(
					{
						left : ($(this).position().left - options.overlapX / 2),
						width : ($(this).width() + options.overlapX)
					},
					{
						duration : options.speed,
						easing : options.easing,
						queue : false
					}
				);
			}, function() {
				// mouse out	
				$(this).not('.current_page_item, li.current_page_ancestor').children('a').css({color:'#000000'});					
				reset = setTimeout(function() {			
					blob.animate({
						width : (currentPageItem.outerWidth() + options.overlapX),
						left : (currentPageItem.position().left - options.overlapX / 2)
					}, options.speed)
					currentPageItem.children('a').css({color:'#ffffff'});	
				}, options.reset);
	
			});
		
		}); // end each
	
	};

})(jQuery);
