LTG.addLoadEvent(function(){
	/* code here runs when page loads */
	$("#lesson_spec_nav > div").each(function(i){
		//console.log(this.id);
		$(this).click(function() {
			var me = this;
			$("#"+me.id).addClass("tabOn").removeClass("tabOff");
			if(me.id!="box_lesson_tab") {
				$("#box_lesson_tab").removeClass("tabOn").addClass("tabOff");
				$("#lesson_tab_content").hide();
			} else {
				$("#lesson_tab_content").show();
				location.hash = "#lesson";
			}
			if(me.id!="box_handouts_tab") {
				$("#box_handouts_tab").removeClass("tabOn").addClass("tabOff");
				$("#handouts_tab_content").hide();
			} else {
				$("#handouts_tab_content").show();
				location.hash = "#handouts";
			}
			if(me.id!="box_standards_tab") {
				$("#box_standards_tab").removeClass("tabOn").addClass("tabOff");
				$("#standards_tab_content").hide();
			} else {
				if(LTG.loaded_standards != true) {
					LTG.showStandards();
				}
				$("#standards_tab_content").show();
				location.hash = "#standards";
			}
			if(me.id!="box_framework_tab") {
				$("#box_framework_tab").removeClass("tabOn").addClass("tabOff");
				$("#framework_tab_content").hide();
			} else {
				$("#framework_tab_content").show();
				location.hash = "#framework";
			}
		});
	});
	if(print_version!='yes') {
		LTG.updateSupporters(state_name,"lessons");
	} else {
		$("#box_framework_tab").click();
	}
	$("#page_navigator_concepts").click(function() {
		$("#kw_table").slideToggle("slow", function () {
			$("#kw_table td").css("zoom","100%"); // fixing IE italics bug
		});
		if($(this).html()=="Key Words/Concepts <span>click to view</span>") {
			$(this).html("Key Words/Concepts <span>click to hide</span>");
		} else {
			$(this).html("Key Words/Concepts <span>click to view</span>");
		}
	});
	$(".lt .toggle").click(function() {
		$(this).parent().next(".lesson_text").slideToggle("slow", function () {
			$(this).css("zoom","100%"); // fixing IE italics bug
		});
		if($(this).text()=="(click to view)") {
			$(this).text("(click to hide)");
		} else {
			$(this).text("(click to view)");
		}								
	});
	switch(location.hash) {
		case "#handouts":
			$("#box_handouts_tab").click();
			break;    
		case "#standards":
			$("#box_standards_tab").click();
			break;
		case "#framework":
			$("#box_framework_tab").click();
			break;
		case "#LLL":
			LTG.expandLLL();
			break;
		default:
		
	}
});

LTG.expandLLL = function() {
	$(".lt .toggle").each(function() {
		var me = this;
		if($(me).parent().text()=="LEAGUE Learning Link(s): (click to view)") {
			if($(me).text()=="(click to view)") {
				$(me).click();
			}
		}
	});
}
LTG.expandPSR = function() {
	$(".lt .toggle").each(function() {
		var me = this;
		if($(me).parent().text()=="Post Service Reflection: (click to view)") {
			if($(me).text()=="(click to view)") {
				$(me).click();
			}
		}
	});
}

LTG.showStandards = function(print_version) {
	$("#the_standards").html("...searching...");
	$("#view_standards").attr("disabled","disabled");
	var options = {
		success: function(responseText) {
			LTG.loaded_standards = true;
			$("#the_standards").html(responseText);
			$("#view_standards").attr("disabled","");
		}
	};
	$('#standards_search').ajaxSubmit(options);
}
LTG.showFramework = function(ploid, print_it) {
	if(LTG.loaded_fw != true) {
		$.get("/lessons/ajax_show_framework.asp", { ploid: ploid },
		function(data){
			LTG.loaded_fw = true;
			$("#framework_results").html(data);
			
		});
	} else {
		if(print_it==true) LTG.tryPrint();
	}
}


LTG.showParent = function(img,id) {
	var new_div = document.createElement("div");
	new_div.id = id;
	new_div.innerHTML = '...loading...';
	img.parentNode.parentNode.style.border = "0";
	img.parentNode.parentNode.parentNode.insertBefore(new_div,img.parentNode.parentNode);
	img.parentNode.removeChild(img);
	$.get("/lessons/ajax_show_standard.asp", { id: id },
	function(data){
		var results_arr = data.split("|");
		var the_id = results_arr[0];
		var the_results = document.getElementById(the_id);
		the_results.id = "";
		the_results.innerHTML = results_arr[1];
	});
}


LTG.updateSupporters = function(stateName,displayFormat) {
	//console.log("update supporters("+stateName+","+displayFormat+")");
	var image1 = "";
	var image2 = "";
	var outputTxt = "";
	var sup1 = "";
	var sup2 = "";
	var JetBlue = "JetBlue";
	var WKKellogg = "W.K. Kellogg Foundation";
	var CAA = "CAA Foundation";
	var Lilly = "Lilly Endowment";
	var Wachovia = "Wachovia";
	var RGK = "RGK Foundation";
	//var outputSpot = document.getElementById(theId);
	//if(outputSpot) {
		switch (stateName) {
			case "AZ": { sup1 = JetBlue; break; }
			case "CA": { sup1 = JetBlue; sup2 = CAA; break; }
			case "CO": { sup1 = JetBlue; break; }
			case "DC": { sup1 = JetBlue; break; }
			case "FL": { sup1 = JetBlue; break; }
			case "IL": { sup1 = JetBlue; break; }
			case "IN": { sup1 = Lilly; break; }
			case "LA": { sup1 = JetBlue; break; }
			case "MA": { sup1 = JetBlue; break; }
			case "ME": { sup1 = JetBlue; break; }
			case "MI": { sup1 = WKKellogg; break; }
			case "NC": { sup1 = JetBlue; break; }
			case "NJ": { sup1 = Wachovia; sup2 = JetBlue; break; }
			case "NV": { sup1 = JetBlue; break; }
			case "NY": { sup1 = JetBlue; break; }
			case "OH": { sup1 = JetBlue; break; }
			case "OR": { sup1 = JetBlue; break; }
			case "PA": { sup1 = JetBlue; break; }
			case "TN": { sup1 = JetBlue; break; }
			case "TX": { sup1 = RGK; sup2 = JetBlue; break; }
			case "UT": { sup1 = JetBlue; break; }
			case "VA": { sup1 = JetBlue; break; }
			default: { stateName = ""; } 
		}
		if (stateName!="") {
			switch (sup1) {
				case JetBlue: { url1 = "www.jetblue.com"; break; }
				case RGK: { url1 = "www.rgkfoundation.org"; break; }
				case WKKellogg: { url1 = "www.wkkf.org"; break; }
				case Wachovia: { url1 = "www.wachovia.com"; break; }
				case Lilly: { url1 = "www.lillyendowment.org"; break; }
				case CAA: { url1 = "www.caa.com"; break; }
				default: { url1 = ""; }
			}
			
			switch (sup2) {
				case JetBlue: { url2 = "www.jetblue.com"; break; }
				case RGK: { url2 = "www.rgkfoundation.org"; break; }
				case WKKellogg: { url2 = "www.wkkf.org"; break; }
				case Wachovia: { url2 = "www.wachovia.com"; break; }
				case Lilly: { url2 = "www.lillyendowment.org"; break; }
				case CAA: { url2 = "www.caa.com"; break; }
				default: { urls = ""; }
			}
			
			outputTxt = "<em>Learning to Give</em> thanks the supporters who believe in the importance of educating youth to give their time, talent and treasure to their communities.";
			if(sup1!="") {
				image1 = "<a href=\"http://" + url1 + "\">" + "<img src=\"/lessons/supporters/" + sup1 + ".gif\" alt=\"" + sup1 + " Logo\" border=\"0\" /></a>";
			}
			if(sup2!="") {
				image2 = "<a href=\"http://" + url2 + "\"><img src=\"/lessons/supporters/" + sup2 + ".gif\" alt=\"" + sup2 + " Logo\" border=\"0\" /></a>";
			}
			if(stateName!="") {
				if(displayFormat=="search") {
					if(sup2!="") {
						outputTxt+= image2;
					}
				} else if(displayFormat=="lessons") {
					outputTxt = image1
					if(sup2!="") {
						outputTxt+= "<br />" + image2
					}
				}
			}
			$("#ltg_supporters_middle").html("<div align='center' style='padding:5px;'>"+outputTxt+"</div>");
			$("#ltg_supporters").slideDown();
		} else {
			$("#ltg_supporters").slideUp();
		}
	//}
}