CGSITE.loadFunctions = function() {
	
	// replace navigation lists with Flash + add printable nav after
	if($('nav')) {
		var navLists = $('nav').innerHTML;
		var so = new SWFObject("navbar.swf?books=books&games=games&teachers=teachers&media=press&licensed=monkeybusiness&movies=movie_tv&history=history&art=artexhibit_hattiesburg", "Navigation Menu", "490", "60", "9", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.write("nav");
	}
	
	CGSITE.updateCopyright(2007);
	
	// get all h2 tags and convert to Flash + add printable HTML headline after
	var headlines = $$('h2');
	headlines.each(function(i, index){
		if (i.className != "noConvert") {
			i.id = "headline" + index;
			var headlineText = i.innerHTML;
			var flashText = CGSITE.textToFlash(headlineText);
			var bookPodPattern = new RegExp("^bookPod", "i");
			var widePodPattern = new RegExp("openWidth$", "i");
			// if it's an overall page headline:
			if (!bookPodPattern.match(i.up().className) || widePodPattern.match(i.up().className)) {
				var swfUrl = "headline_page.swf?hlText=" + flashText;
				var so = new SWFObject(swfUrl, flashText, "545", "28", "9", "#FFFFFF");
			// else, if it's a headline inside a bookPod:
			} else {
				var swfUrl = "headline_featurepod.swf?hlText=" + flashText;
				var so = new SWFObject(swfUrl, flashText, "265", "28", "9", "#FFFFFF");
			}
			so.addParam("wmode", "transparent");
			so.write(i.id);
			/* did the Flash get added? if so, add a printing version of the headline
			 * since objects and embeds won't print, per style sheet
			 */
			var embedPattern = new RegExp("<embed", "gi");
			var objectPattern = new RegExp("<object", "gi");
			var swfPattern = new RegExp("\.swf", "gi");
			if (embedPattern.match(i.innerHTML) || objectPattern.match(i.innerHTML) || swfPattern.match(i.innerHTML)) {
				var printOnlyHead = new Element("h2");
				printOnlyHead.className = "printOnly";
				printOnlyHead.update(headlineText);
				i.insert({
					after : printOnlyHead
				});
			} // end if
		} // end if
	}.bind(this));
	
	// get all bookPod divs and reformat to 2-column layout
	var bookPods = $$('div.bookPod');
	var clearingDiv = "<div class=\"clear\"><\/div>";
	var floatValue = "right";
	bookPods.each(function(i, index){
		var widePodPattern = new RegExp("openWidth$", "i");
		if (!widePodPattern.match(i.className)) {
			// pad the top-right pod a bit at right, to compensate for banana tree leaf
			if (index == 1) {
				var innerPad = new Element("div");
				innerPad.style.paddingRight = "25px";
				innerPad.update(i.innerHTML);
				i.update(innerPad);
			}
			floatValue = (floatValue == "right" ? "left" : "right");
			i.style.width = "46%";
			i.style.cssFloat = floatValue;
			i.style.styleFloat = floatValue;
			if (floatValue == "right" || index == bookPods.length - 1) {
				i.insert({
					after : clearingDiv
				});
			} // end inner if
		} // end outer if
	}.bind(this));
	
	// write Flash games into their spots on game pages
	if ($('gamePod')) {
		switch($('gamePod').className) {
			case "games_drawing":
				var hl = "Learn to Draw Curious George!";
				break;
			case "games_counting":
				var hl = "Curious About Counting?";
				break;
		}
		var fileName = $('gamePod').className + ".swf";
		var so = new SWFObject(fileName, hl, "550", "366", "9", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.write("gamePod");
	}
	
} // end loadFunctions

Event.observe(window, "load", CGSITE.loadFunctions);