(function() {

	var glow;

	gloader.load(
	 ["glow", "1", "glow.anim", "glow.events", "glow.dom"],
	 {
		async: false,
		onLoad: function(fetchedGlow) {
			//write glow back to the variable we defined above
			glow = fetchedGlow;
			//call the init function when ready
			glow.ready(init);
		}
	 }
	);
	
function init() {
	animInit();
}

function animInit() {
	
	glow.dom.get("span.texthead span").css("display", "none");
	
	var showHideBtns = glow.dom.get(".showhowto");
	for (var i = 0; i < showHideBtns.length; i++) {
		
		glow.events.addListener(
			showHideBtns.item(i),
			'click',
			function() {
				showHideHowTo(this);
			}
		);
		
	}
}


function showHideHowTo(e) {

	/* this function is used to determine
	 * which portion to show/hide via event
	 * handling, and then calls itself with
	 * a different type of parameter to actually
	 * do it on the right target with the help of
	 * glow.anim
	 */
	
	if (typeof e == "object") {
		
		/*
		var targ;
		
		if (e.nativeEvent.target) {
			targ = e.nativeEvent.target;
		} else if (e.nativeEvent.srcElement) {
			targ = e.nativeEvent.srcElement;
		}
		
		if (targ.nodeType == 3) {
			targ = targ.parentNode; // Safari bug fix
		}

		switch(targ.attributes['id'].nodeValue) {
			case "sht1":
			showHideHowTo(1);
			break;
			case "sht2":
			showHideHowTo(2);
			break;
			case "sht3":
			showHideHowTo(3);
			break;
			default:
			// should not happen
			break;
		}
		*/
		switch(e.id) {
			case "sht1":
			showHideHowTo(1);
			break;
			case "sht2":
			showHideHowTo(2);
			break;
			case "sht3":
			showHideHowTo(3);
			break;
			default:
			// should not happen
			break;
		}
	} else {
		var whatToShowHide = glow.dom.get("span.texthead span#text" + e);
		if (whatToShowHide.css("display") == "none") {
			glow.dom.get("#sht" + e).attr("src", "/nol/shared/spl/hi/business/08/inflation_calculator/img/hide.gif");
			whatToShowHide.css("color", "#efeded"); // smoothes out anim later if clicked repeatedly
			whatToShowHide.css("display", "block");
			glow.anim.css(whatToShowHide, "0.5", {"color": {to: "#000"}}, {tween:glow.tweens.easeOut()}).start();
		} else {
			glow.dom.get("#sht" + e).attr("src", "/nol/shared/spl/hi/business/08/inflation_calculator/img/show.gif");
			whatToShowHide.css("display", "none");
		}
	}
	
}

	
})();