/*
#####################################################
# 
# Phenotype.net v2009
# Animated Navigation v1.0
#
# Hand-crafted by Phenotype (phenotype.net)
# Animates navigation items using jQuery
# Derived from http://www.tyssendesign.com.au/articles/animated-navigation-items-using-jquery/
#
#####################################################
*/

	/**
	* @param navigationSelector:String 		Path to navigation items
	* @param options:Object					(selectedClass, hoverClass, fadeInDuration, fadeOutDuration)
	*/
	
	function animatedNavigation(navigationSelector, options) {
	
		// Loop through the navigation list items
		$(navigationSelector).each(function() {
			// compare IDs of the body and list-items
			var myClass = $(this).attr("class");
			// only perform the change on hover if item is not selected already (so the active link doesn't change on hover)
			if (myClass != options.selectedClass) {
				// for mouse actions
				$(this).children("a").hover(function() {
					// add a class to the list item so that additional styling can be applied
					$(this).addClass(options.hoverClass);
					// add in the span that will be faded in and out
					$(this).append("<span><\/span>");
					$(this).find("span").fadeIn(options.fadeInDuration);
				}, function() {
					$(this).removeClass(options.hoverClass);
					// fade out the span then remove it completely to prevent the animations from continuing to run if you move over different items quickly
					$(this).find("span").fadeOut(options.fadeOutDuration, function() {
						$(this).remove();
					});
				});
				/*// for keyboard actions
				$(this).children("a").focus(function() {
					$(this).addClass(options.hoverClass);
					$(this).append("<span><\/span>");
					$(this).find("span").fadeIn(options.fadeInDuration);
				});
				$(this).children("a").blur(function() {
					$(this).removeClass(options.hoverClass);
					$(this).find("span").fadeOut(options.fadeOutDuration, function() {
						$(this).remove();
					});
				});*/
			}
		});
	
	}