// Features
/*

author: scott lenger
last updated: December 2007

instructions:
1. link to file
2. add "setFeatures();" to onload function
3. make sure container div id and list heading tag match what is defined at the beginning of the script.

*/

// These XHTML/CSS id's must match
var featureId = "features"; // id of features containing div
var listHeading = "h3";

function setFeatures() {
	var getFeatureHeader = '';
	
	// add a little CSS to give the impression of links
	if(!document.getElementById(featureId)) {return;} // make sure the XHTML id matches
	
	// add the javascript only css
	var featureList = document.getElementById(featureId);
	featureList.className = "compact";
	
	// show the first child list by default
	var getFeatureHeader = featureList.getElementsByTagName(listHeading);
	getFeatureHeader[0].parentNode.className = 'fcurrent';
	
	// give parent li onclick
	for (var i=0; i<getFeatureHeader.length; i++) {
		getFeatureHeader[i].parentNode.onclick = function() {
			hideFeatures(); // removes previous list
			this.className += " fcurrent"; // shows selected list
		}
	}
	
	// removes fcurrent class from parent wrapper li
	function hideFeatures() {
		for (var i=0; i<getFeatureHeader.length; i++) {
			getFeatureHeader[i].parentNode.className = getFeatureHeader[i].className.replace(" fcurrent", "");
		}
	}

	 /*
	// jQuery Version
	$("ul#features").find("ul").eq(0).css({display: "block"});
	$("ul#features").find("h3").eq(0).addClass("fcurrent");
	
	// give h3's onclick function
	$("ul#features li h3").click(function() {
		// hide all child lists, then show the requested list
		$("ul#features li ul").hide();
		$(this).parents("li").children("ul").show(); // fadeIn also works nicely depending on bg
		// remove h3 class and assign to current
		$("ul#features li h3").removeClass("fcurrent");
		$(this).parents("li").children("h3").addClass("fcurrent");
	});
	*/
}