var PAGE_ID;
var INIT_TOPLEVEL_INDEX;
var NAVMASTERS = new NavMasters(); // in most cases, page will have only one nav, but there is no upper limit
		
		 // todo: move global to a better location. It is used by ofxNavOop_accordion to show init open immediate, not w/ duration

function ofPageInit(pageid, tocsectionid)
	{

		PAGE_ID = pageid;
			
		INIT_TOPLEVEL_INDEX = tocsectionid;

		if (document.getElementById("ofAccordion")) {
			var toc = new Accordion("ofAccordionUL", NAVMASTERS,"id");
			toc.init();
		}
	}



		setFlashFont(".ofFlashHeader h1","avenir","#5F9635","#ffffff"); // selector, font, color, background-color

function Zen() {
//do nothing
}

function TabClick(TabID){
for(i = 0; i < tabsContent.length; i++){ 
if (TabID == tabsContent[i]){
document.getElementById(tabsContent[i]).style.display = 'block';/*      */

addClass(document.getElementById(tabs[i]),"ofSelected");
} else {
document.getElementById(tabsContent[i]).style.display = 'none';
removeClass(document.getElementById(tabs[i]),"ofSelected");
}}}


function attachStateParam(state) {
var linkHref = document.getElementById("open_a_529_account").href;
document.getElementById("open_a_529_account").href = linkHref + '?state='+state;
}

function toggleGTS(state) {
	if (document.getElementById) {
		var gtsLink = document.getElementById("gtsLink");
		gtsLink.setAttribute("href", "#"); // get rid of the href
		var menu = document.getElementById("goToSectionBox").firstChild;
// Make sure the firstChild is an HTML tag and nothing else
		while (menu.nodeType != 1) { //nodeType 1 is HTML element
			menu = menu.nextSibling; // assign next sibling instead
		}
		setElementClass(gtsLink, state);
		setElementClass(menu, state);
		if (document.getElementById("searchType")) {
			if (state == "active") { 
				document.getElementById("searchType").style.visibility = "hidden";
			} else {
				document.getElementById("searchType").style.visibility = "visible";
			}
		}
	}
}

function getElementClass(element) {
	if (element.getAttribute("class")) {
		return element.getAttribute("class");
	} else if (element.getAttribute("className")) {
		return element.getAttribute("className");
	}
}

function setElementClass(element, classValue) {
	if (element.setAttribute("class", classValue)) {
		element.setAttribute("class", classValue);
	} else if (element.setAttribute("className", classValue)) {
		element.setAttribute("className", classValue);
	}
}


/** 
* Browser detection
*/

var IE = ((parseInt(navigator.appVersion)>=4)&&(navigator.appName.indexOf("Microsoft")!=-1))? 1:0;

/**			
*			Function: showFlashDiv
*			@author Stephen McCall
*			
*			@param {String} divID name of div to hide/show
*			@param {Boolean} visibility 1 or 0, sets visiblity of divID
*			@param {String} flashURL URL to flash file to be displayed in divID
*			@param {String} flashHeight height of flash file
*			@param {String} flashWidth width of flash file
*
*			Note: this function depends on the "flash.js" file for flash detection
*			@see "flash.js"
*/

function showFlashDiv(divID,visibility,flashURL,flashHeight,flashWidth){

var div_visibility;

if (parseInt(flash.version) >= 7) {

var flashObject = '<OBJECT CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" WIDTH="'+flashWidth+'" HEIGHT="'+flashHeight+'" codebase="https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ID=testcommand><PARAM NAME="MOVIE" VALUE="'+flashURL+'"><param name="wmode" value="transparent" /><PARAM NAME="PLAY" VALUE="false"><PARAM NAME="LOOP" VALUE="false"><PARAM NAME="QUALITY" VALUE="high"><PARAM NAME="SCALE" VALUE="SHOWALL"><EMBED SRC="'+flashURL+'" wmode="transparent" WIDTH="'+flashWidth+'" HEIGHT="'+flashHeight+'" PLAY="false"  LOOP="false" QUALITY="high" TYPE="application/x-shockwave-flash" SCALE="SHOWALL"  swLiveConnect="true" PLUGINSPAGE="https://www.macromedia.com/go/flashplayer/" /></EMBED></OBJECT>';

if(IE) {
 	if(visibility == 1) { div_visibility = "visible"; }
	else { div_visibility = "hidden"; }
	document.all[divID].style.visibility = div_visibility;
	document.all[divID].innerHTML = flashObject;
 	}

else {
 	if(visibility == 1) { div_visibility = 'visible'; }
	else { div_visibility = 'hidden'; }
	document.getElementById(divID).style.visibility = div_visibility;
	document.getElementById(divID).innerHTML = flashObject;
 	}

}

else {

ofPopWinVideo("/common/flash/download_flash.shtml");

	}
	
}

