 /**
 * jQuery.jFAQ - Easy FAQ creator using jQuery.
 * Copyright (c) 2008 XombieDesign - http//xombiedesign.com
 * Licensed under GPL license (http://www.opensource.org/licenses/gpl-license.php).
 * Date: 7/2/2008
 * @author Ryan Holt, Trip Oneal
 * @version 1.0.3
 *
 * Requires: jQuery 1.2+
 *
 * Notes:
 *  Internet Explorer 6 + 7 Issues:
 *	- Hiding "top" anchors not working in IE.
 *	- Changed $('a[href="#top"]').hide(); to $('a').attr({'href': '#top'}).hide();
 *	- Changed $('a[href="#top"]').hide(); to $('a[title="Back to the Top"]').hide();
 *     and added to the anchor append.
 *
 *	Scrolls smoothly down page, but jumps when clicking "top" anchor:
 *	- $('html,body').animate({scrollTop:0}, 'slow'); bounces in IE
 *	- $('body').animate({scrollTop:0}, 'slow'); jumps in IE, but doesn't bounce
 *
 *
 *	- Added titles to the dynamically created "subNav".
 */
 
 $(document).ready(function() {
	$('<a href="#top" title="Back to Top"><br />Back to Top</a>').appendTo("h3:contains('?')");
	$('a[title="Back to Top"]').hide(); // Hide all "top" anchors

// Start "subNav" list, read content of each h3 tag and create "subNav" li dynamically
	$("#content").prepend('<ul id="subNav"></ul>');
	$("h3:contains('?')").attr("goat", function (a) { return a; });
	$("h3:contains('?')").each(function(i){
		$('<li><a href="#'+(i)+'" monkey="'+(i)+'" title="'+$(this).text()+'">'+$(this).text()+'</a></li>').appendTo('#subNav');
	});
	
	$('a[monkey*=]').click(function() {
		$('.faqHover').removeClass('faqHover');	// Remove all traces of ".faqHover"
		$('a[title="Back to Top"]').hide(); // Hide target "top" anchor
		
		if(location.pathname.replace(/^\//,'')==this.pathname.replace(/^\//,'')&&location.hostname==this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target || $('[goat=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset-200}, 'slow');
				($target).addClass('faqHover'); // Add class to the target li
				$('.faqHover a[title="Back to Top"]').show(); // Show target "top" anchor
				return false;
			}
		}
	});
// Create scroll function to eliminate need for named page anchor
// then hide this and all "top" anchors when clicked
	$('a[title="Back to Top"]').click(function() {
		$('html,body').animate({scrollTop: 0}, 'slow');
		$(this).each('a[title="Back to Top"]').hide();
	});
});
 

