// JavaScript Document

// JavaScript Document

(function($) {

	$.fn.spasticNav = function(options) {

		options = $.extend({
			overlap : 0,
			speed : 500,
			reset : 500,
			color : '#3C3627',
			easing : 'easeInOutQuad'
		}, options);
		
		//$('#navContainer'.css(height, this.height()))
		

		return this.each(function() {

		 	var nav = $(this),
		 		currentPageItem = $('#selected', nav),
		 		blob,
		 		reset;

		 	$('<li id="blob"></li>').css({
		 		width : currentPageItem.outerWidth(),
		 		//height : currentPageItem.outerHeight() + options.overlap,
				height: "5px",
		 		left : currentPageItem.position().left,
		 		//top : currentPageItem.position().top - options.overlap / 2,
				top:"57px",
		 		backgroundColor : options.color
		 	}).appendTo(this);
			

		 	blob = $('#blob', nav);

			$('li:not(#blob)', nav).hover(function() {
				// mouse over
				//alert($('#blob').find('a').css('color', '#fff'););
				//$('#blob').children($('#blob').children().length).css('color', '#000');
				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.easing)
				}, options.reset);

			});

		}); // end each

	};

})(jQuery);
