
// Change the Events tabs/links
function changeEventsMenu(eDay, eventsBarDay) { 
	changeAllBGImg(eventsBarsGroup, eventsBarDay, 'homepage/tabEventsBarActive.jpg'); 
	changeAllClass(eventsBarsGroup2, eventsBarDay, 'eventPaneBar2');
	
	// Close the last opened to help with new selections that have no data
	for (j=0; j<eventsInfo.length; j++) {
		if (document.getElementById(eventsInfo[j]).style.display === "block") {
			document.getElementById(eventsInfo[j]).style.display = "none";
		}
	}
	
	// Only show the innerHTML if events are returend form the DB
	var primaryContent = document.getElementById(eventsBarDay);
	var myUL = primaryContent.getElementsByTagName("ul");
	
	for (i=0; i<myUL.length; i++) {
		var stripWhite = myUL[i].innerHTML;
		stripWhite = stripWhite.Trim();
		if (stripWhite === "") {
			myUL[i].style.display = "none";
			myUL[i].style.visibility = "hidden";
		} else {
			toggleDivGroupDisplay(eventsInfo, eDay);
		}
	}
}


function checkHTTPSProtocol(currDirectory, currPage) {
	var devURL = getFullURL();
	if (devURL.indexOf("triplestrength") > -1) {
		//break;				   
	}
	if (currDirectory === "support-the-museum" || currDirectory === "membership") {
		if (currPage === "donation.aspx" || currPage === "capital-campaign.aspx" || currPage === "membership.aspx" || currPage === "giftMembership.aspx") {
			forceHTTPSProtocol();
		} else {
			forceHTTPProtocol();
		}
	} else if (currDirectory === "employment-opportunities" && currPage.indexOf("application") > -1) {
		forceHTTPSProtocol();
	} else {
		forceHTTPProtocol();
	}
}

function forceHTTPSProtocol() {
	var currURL = getFullURL();
	var currProtocol = currURL.split(":");
	if (currProtocol[0] === "http") {
		location.href = "https:" + currProtocol[1];
	}
}

function forceHTTPProtocol() {
	var currURL = getFullURL();
	var currProtocol = currURL.split(":");
	if (currProtocol[0] === "https") {
		location.href = "http:" + currProtocol[1];
	}
}

// Switch out HTML content for the Alt Flash Text Headers
function loadMainSWFHeader(swfName, width, height, objId, color) {
		
		// ![CDATA[
		var swfName = new SWFObject("/lib/swf/interiorTemplate/interiorHeader.swf", "Main Text Header", width, height, "8", "");
		swfName.addParam("wmode", "transparent");
		swfName.addVariable("headlineWidth", width); // put the layers HTML text
		swfName.addVariable("headlineHeight", height); // put the layers HTML text
		swfName.addVariable("headlineColor", color);
		
		// Catch & escpape all characters passed to Flash...Flash will use the unescape() to revert to HTML text
		var obj = document.getElementById(objId);
		if(obj){
			var html = obj.innerHTML;
			
			// Catch instances of "é" and convert to Hex code
			if (html.indexOf("\xe9") > -1) {	
				var str = html.split("\xe9");
				html = str[0] + "%C3%A9" + str[1];
			}
			
			// Catch instances of "+" and convert to Hex code
			if (html.indexOf("+") > -1) {	
				var str = html.split("+");
				html = str[0] + "%2B" + str[1];
			}
			
			swfName.addVariable("headlineText", escape(html));
			swfName.write(objId);
			
			// Create new a div to be printed in place of the flash
			var printableDiv = document.createElement("div");
			// Grab its current object
			var currObj = obj.id;
			// Set the new obj and it params
			printableDiv.id = "printText" + currObj.substring((currObj.length-3), currObj.length);
			printableDiv.className = "printFlashAlt";
			printableDiv.innerHTML = "<h3>" + html + "</h3>";
    		// Append the new div
			obj.parentNode.insertBefore(printableDiv, obj.nextSibling);

		}
		
		// ]]>
}

// Load the Home page Flash
function loadHomePageFlash() {
		// ![CDATA[
		var homePageFlashHolder = new SWFObject("/lib/swf/homePage/homePage.swf", "The Hershey Story", 645, 389, "8", "");
		homePageFlashHolder.addParam("wmode", "transparent");
		homePageFlashHolder.addVariable("clipPath", "/lib/swf/homePage/homeAssets.swf");
		homePageFlashHolder.addVariable("xmlPath", "/lib/swf/homePage/billboards.xml");
		homePageFlashHolder.write("mainFlash");
		// ]]>
}

// Load the Splash Page Flash
function loadSplashPageFlash() {
		// ![CDATA[
		var splashPageFlashHolder = new SWFObject("/lib/swf/homePage/splash.swf", "The Hershey Story", 998, 541, "9", "");
		splashPageFlashHolder.addParam("wmode", "transparent");
		splashPageFlashHolder.addVariable("clipPath", "/lib/swf/homePage/splashAnimation.swf");
		splashPageFlashHolder.write("mainSplash");
		// ]]>
}

// Load the Home page Flash
function loadNewsRoomFlash() {
		// ![CDATA[
		var homePageFlashHolder = new SWFObject("/lib/swf/newsroom/videoPlayer.swf", "The Hershey Story", 645, 300, "8", "");
		homePageFlashHolder.addParam("wmode", "transparent");
		homePageFlashHolder.addVariable("clipPath", "/lib/swf/newsroom/THSNews27.flv");
		homePageFlashHolder.write("newsroomFlash");
		// ]]>
}

// Load the Home page Flash
function load2MinFlash() {
		// ![CDATA[
		var flashHolder = new SWFObject("/lib/swf/hershey-story-video/videoPlayer.swf", "The Hershey Story", 645, 396, "8", "");
		flashHolder.addParam("wmode", "transparent");
		flashHolder.addVariable("clipPath", "/lib/swf/hershey-story-video/2MinVideo.flv");
		flashHolder.write("2MinFlash");
		// ]]>
}

// Fit the Picture being loaded into the pop-up window.
function popUp(page, width, height) {
	var myWin;
	myWin = openNewWindow(page, "", 0, 0, 0, 0, 1, 0, width, height);
}

// Fit the Picture being loaded into the pop-up window.
function popUpFitPic(img) {
	var myWin;
	myWin = openNewWindow("/lib/includes/pop-ups/blank.html?img=" + img, "", 0, 0, 0, 0, 0, 0, 200, 200);
}

// Fit the Picture in the pop-up for Cafe Zooka
function cafeMenuFitPic(img) {
	var myWin;
	myWin = openNewWindow("/lib/includes/pop-ups/cafeEnlarge.html?img=" + img, "", 0, 0, 0, 0, 0, 0, 200, 200);
}