function keyword(kw){
	if(kw.toLowerCase() == "exit") kw = "Enroll";
	for (var n = 0; n <= arrLinks.length - 1; ++n) {
		if (arrLinks[n].pageid.toLowerCase() == kw.toLowerCase()) {
			if(arrLinks[n].cat == "" && arrLinks[n].link == "") {
					collapseAll();
					unbold(nPrev);
			}
			else openlink("m" + arrLinks[n].cat,arrLinks[n].cat + arrLinks[n].link);
			break;
		}
   }
}

var nPrev = "301" ;

function boldMe(n) {
	var doc = document;  	
	var whichLayer = n.charAt(0);
	if ((n) != nPrev) unbold(nPrev,whichLayer);
	var theItem = doc.getElementById("item" + n);
	var theLink = doc.getElementById("A"+n+"link");
	if(theLink){
		theItem.className  = "selected";
		theLink.className  = "selected";
		theLink.blur();
		
		nPrev = n;
	} else setTimeout("boldMe(\""+n+"\")", 1000)
}
	
function unbold(boldLink,whichLayer) {
	var doc = document;
	var theItem = doc.getElementById("item" + boldLink);
	var theLink = doc.getElementById("A" + boldLink + "link");
	if(theItem) theItem.className  = "";
	if(theLink) theLink.className  = "";
}
	
function boldThisTab(thisTab,numberOfTabs) {
	var doc = window.MiddleContent.TabHeader.document;  	
	var theItem = doc.getElementById(thisTab);
	theItem.blur();
	var theChild
	for (var n = 1; n <= numberOfTabs; ++n) {
		if(n!=thisTab) {
			var theOuterSpan = doc.getElementById("Outer" + n);
			theOuterSpan.className  = "none";
		} else {
			var theOuterSpan = doc.getElementById("Outer" + n);
			theOuterSpan.className  = "current";
		}
	}
}

var booOtherFocus = false;  
function expand(s) {
	var doc = document;

	var thisParentLayer = doc.getElementById(s+"UL");
	
	var thisChildLayer = doc.getElementById(s+"Child");
	if (thisChildLayer.style.display == "none") {
		for (var n = 1; n <= numberOfCats; ++n) {
		  var tempLayer = doc.getElementById("m"+n+"Child");
		  tempLayer.style.display = "none";
		}
		thisChildLayer.style.display = "block";
	} else thisChildLayer.style.display = "none";
	var theItem = doc.getElementById("catlink" + s);
	sizeForStupidIEWin();
	sizeSignOnArea();
	theItem.blur();
	//if (!booOtherFocus) window.focus();
}

function collapseAll() {
	var doc = document;
	for (var n = 1; n <= numberOfCats; ++n) {
		var theLayer = doc.getElementById("m"+n+"Child")
		if (theLayer) theLayer.style.display = "none";
	}
}

function openlink(cat,listlink) {
	if(window.document.getElementById(cat+"Child")){
		if (window.document.getElementById(cat+"Child").style.display == "none") expand(cat);
		boldMe(listlink);
	} else setTimeout("openlink(\"" + cat + "\",\"" + listlink + "\")", 1000)
}

function showMenu() {		// used by IE6 (or less) because it can't do a transparent SELECT control
	var theMenu = document.getElementById('selectDiv');
	var fixer = document.getElementById('selHider');
	theMenu.style.left = "10em"
	theMenu = document.getElementById('selector');
	if(ie5or6) document.getElementById('ie6SelectLayerFixer').style.display='block'; 
	if(ie5or6) theMenu.setAttribute("size",20)
	theMenu.focus();
	fixer.style.display = "block"
}

function hideApps(){		// used by IE6 (or less) to hide the fake open SELECT control
	var theMenu = document.getElementById('selectDiv');
	var fixer = document.getElementById('selHider');
	theMenu.style.left = "-1000em"
	theMenu = document.getElementById('selector');
	if(ie5or6) document.getElementById('ie6SelectLayerFixer').style.display=''; 
	if(ie5or6) theMenu.setAttribute("size",1)
	fixer.style.display = "none"
}

function applyMouse(over) {		// used to make SELECT hightlight the pseudo-button below it
	var appButton = document.getElementById('apply');
	if(over){
		appButton.className = "over"
	} else {
		appButton.className = ""
	}
}

function go(box) {  // to go to the other application forms on the site
	applyMouse(false)
	if(typeof(box) == "object") dest = box.options[box.selectedIndex].value;
	else dest = box;
	if (dest !="") {
		var look = dest.substring(0,10);
		var so = dest.indexOf("SignOn&so=")
		if(so > -1) { 
			top.onlineBanking(true) ;
			if(ie5or6) hideApps();
			box.selectedIndex = 0;
			//                   alert('top/applyMenu/' + dest.split('so=')[1]); 
			pageTracker._trackPageview('top/applyMenu/' + dest.split('so=')[1]); 
			return true;
		}
		else if (look == "/index.asp") {
			target = window.top; 
			dest = secureserverDomain  + "/" + indexpage + dest.substr(10) 
			pageTracker._trackPageview('top/applyMenu/' + dest.split('i=')[1]); 
			}
		else if (look == "/provident") {
			pageTracker._trackPageview('top/applyMenu/' + dest.split('i=')[1]); 
			target = window.MiddleContent;
		}
		else {
			pageTracker._trackPageview('top/applyMenu/equityApply'); 
			alert(dest);
			if(ie5or6) hideApps();
			box.selectedIndex = 0;
			return true
		}
		if(ie5or6) hideApps();
		box.selectedIndex = 0;
		target.location = dest;
	}
}

function onlineBanking(On){	// all attention on the sign on area
	if(On){
		if(cookiesEnabled) document.getElementById("cookiewarning").className = "";
		else document.getElementById("cookiewarning").className = "on";
		document.getElementById("signonEntry").className = "selected";
		document.getElementById("signonEntry").style.borderWidth = "1px";
		document.getElementById("signonEntry").style.margin = "0";
		document.getElementById("signonEntry").style.background = "#a7d6ff url(/NewGraphics/newerGraphics/BG.gif) repeat-x 0 -39px";
		document.getElementById("OBHEAD").innerHTML = "User ID:";
		document.getElementById("soOptions").className = "selected";
		document.Logon.User.focus();
		document.getElementById('hint').className='nohint'; 
		document.getElementById('smoke').style.display='block'; 
		if(ie5or6) document.getElementById('ie6SelectLayerFixer').style.display='block'; 
		onlineBanking.open = true;
		hideDetails();
	} else {
		if(cookiesEnabled) document.getElementById("cookiewarning").className = "on";
		else document.getElementById("cookiewarning").className = "";
		if(document.getElementById("signonEntry")) {
			document.getElementById("signonEntry").className = (document.Logon.User.value == "") ? "" : "selected";
			document.getElementById("signonEntry").style.borderWidth = "0";
			document.getElementById("signonEntry").style.margin = (document.Logon.User.value == "") ? "0" : "1px";
			document.getElementById("signonEntry").style.background = "transparent none";
			document.getElementById("OBHEAD").innerHTML = "Online Banking:";
			document.getElementById("soOptions").className = "";
			document.Logon.User.blur();
			document.getElementById('hint').className='showhint'; 
			document.getElementById('hint').innerHTML = (document.Logon.User.value == "") 
				? "<div><span class=\"hint-pointer\"></span>Click in the User ID text field to enter your User ID, then click the &quot;Sign On&quot; button to enter Account Manager.</div>" 
				: "<div><span class=\"hint-pointer\"></span>Click in the white text field for sign on related FAQs and options, or to sign on with a different User ID.</div>"; 
		}
		document.getElementById('smoke').style.display='none'; 
		if(ie5or6) document.getElementById('ie6SelectLayerFixer').style.display=''; 
		onlineBanking.open = false;
		hideDetails();
	}
}
onlineBanking.open = false;

function popDetails(details,title,w,h,buttons){
		document.getElementById("smoke").style.display="block"; 
		document.getElementById("smoke").style.zIndex="71"; 
		if(ie5or6) {
			document.getElementById("ie6SelectLayerFixer").style.display="block"; 
			document.getElementById("ie6SelectLayerFixer").style.zIndex="70";
		}
		var innerDetails = document.getElementById("innerDetails")
		var actualDetails = document.getElementById("details")
		
		// make sure this isn't bigger than the window:
		var winHeight = 100000;
		if(document.documentElement && document.documentElement.clientHeight) winHeight = document.documentElement.clientHeight
		else if (window.innerHeight) winHeight = window.innerHeight
		if(title == "iframe") {
			actualDetails.style.backgroundColor = "#ffffff";
			actualDetails.style.backgroundImage = "url(/NewGraphics/throbber.gif)";
			actualDetails.style.backgroundRepeat = "no-repeat";
			actualDetails.style.backgroundPosition = "center center";
				
			
			innerDetails.getElementsByTagName("H3")[0].style.display = "none";
			innerDetails.style.height = "auto"; 		 
			buttonH = 55 // approximate height of buttons
			if(winHeight < (h + buttonH + 40)) {
				//alert(winHeight +":"+ (h + buttonH))
				h = winHeight - buttonH - 50 // size box to fit in window, with 50px margin around it, and room for buttons.
			} 
			
			var popFrame = document.createElement("iframe");
			popFrame.name = "popupFrame";
			popFrame.id = "popupFrame";
			popFrame.style.margin = "0";
			innerDetails.style.padding = "0";
			popFrame.scroll = "auto";
			popFrame.height = (h);
			innerDetails.style.top = (-((h + buttonH + 10)/2)) + "px";
			popFrame.width = "100%";
			popFrame.frameBorder = "0"; // set to "1" when testing size. Otherwise, "0"
			while (actualDetails.childNodes.length > 0) actualDetails.removeChild(actualDetails.childNodes[0])
			actualDetails.appendChild(popFrame);
			popFrame.src = details;
			buttons = "<a href='#' onclick='hideDetails(); return false;' title='close this box, and return to the page' class='button default'><span>&nbsp;&nbsp;Close&nbsp;&nbsp;<"+"/span><"+"/a>"
		} else {
			actualDetails.style.backgroundColor = "#ffffff";
			actualDetails.style.backgroundImage = "none";
			innerDetails.style.padding = "0 2em";
			innerDetails.style.overflow = "auto"
			innerDetails.style.overflowX = "hidden"
			if(winHeight < h) {
				h = winHeight - 50 // size box to fit in window, with 50px around it.
				innerDetails.style.height = "" + h + "px";
			} else {
				innerDetails.style.height = "auto"; 		 // this lets the box be no bigger than needed
				//innerDetails.style.height = "" + h + "px"; // un-comment this for testing content heights 
															 // (should be just big enough for no scrollbars)
			}
			innerDetails.style.top = parseInt(-(h/2)) + "px";
			
			var headline = innerDetails.getElementsByTagName("H3")[0]
			headline.style.display = "block";
			headline.innerHTML = title;
			actualDetails.innerHTML = details;
		}
		innerDetails.style.width = "" + w + "px";
		
		if(buttons){
			document.getElementById("buttonBox").innerHTML = buttons;
		} else {
			document.getElementById("buttonBox").innerHTML = document.getElementById("OKButton").innerHTML;
		}
		document.getElementById("detailBox").style.display="block";			
		if(navigator.appVersion.indexOf("KHTML") != -1 ) {
			webkitVersion = parseInt(navigator.appVersion.substr(navigator.appVersion.indexOf("AppleWebKit/") + 12,1))
			if(webkitVersion < 5 ) {
				if(title == "iframe") fixIFrames(details)
				else fixMainFrame()
			} 
		}
}

function hideDetails(){
	if(onlineBanking.open == false){
		document.getElementById("smoke").style.display="none"; 
		if(ie5or6) document.getElementById("ie6SelectLayerFixer").style.display="none"; 
	} else {
		document.Logon.User.focus();
	}
	var PopupFrame = document.getElementById("popupFrame");
	if(PopupFrame) {
		theParent = PopupFrame.parentNode;
		if(theParent) theParent.removeChild(PopupFrame);
	}
	document.getElementById("smoke").style.zIndex="51"; 
	if(ie5or6) document.getElementById("ie6SelectLayerFixer").style.zIndex="50";
	document.getElementById("detailBox").style.display="none";			
}

function fixIFrames(url) {	
	// in Safari, if a newly created iframe has the same index in iframes array as destroyed ones, it will have the same location as the first iframe of that index. Can't load a new location until iframe's display != none, and it has already has created for some number of milliseconds (new iframe is not immediately added to the window's "frames" array).
	var thisFrame = window.frames["popupFrame"]
	var x;
	if(thisFrame) {
		thisFrame.location.href = url 
		repaint.oCount = 0
		clearTimeout(x)
		repaint(); 
	}
	else x = setTimeout("fixIFrames('" + url + "')",80); 
}
function fixMainFrame() {	
	// in Safari, the smoke layer can appear before the main frame is drawn, and the frame is painted second instead of first. this fixes that.
	var thisFrame = window.frames["MiddleContent"].frames["PageDisplay"]
	var y;
	if(thisFrame) {
		repaint.oCount = 0
		clearTimeout(y)
		repaint(); 
	}
	else y = setTimeout("fixMainFrame()",80); 
}
function repaint(){
	document.getElementById('smoke').style.opacity = (repaint.oCount % 2 == 0) ? '.6' : '.599';
	repaint.oCount += 1;
	if(repaint.oCount < 100) setTimeout("repaint()",500)
}


function efaqIF(which,w,h) {
	
	popDetails("/AFrames/includes/snippets/faqFrame.asp?faqNum=" + which, "iframe",parseInt(w),parseInt(h))
}

function email() {
	var warning = "You are about to send a message through unsecure e-mail, which could possibly be intercepted enroute. Also, Provident cannot authenticate your identity through e-mail. If you need ask for or give us private information (such as information about your account), please sign onto Account Manager (online banking) instead. Otherwise, press \"OK\" below. Continue?";
	return confirm(warning);
}

function email2(address) {
	if (address.indexOf(":") > -1) address = address.split(":")[1];
	if (address.indexOf("@") == -1) address = address + "@providentcu.org";
	//var warning = "<p>You are about to send a message through unsecure e-mail, which could possibly be intercepted enroute. Also, Provident cannot authenticate your identity through e-mail. If you need ask for or give us private information (such as information about your account), please sign onto Account Manager (online banking) and click on \"Secure E-Mail &amp; Alerts\" instead. Otherwise, press \"Continue\" below.<"+"/p>";
	var warning = "<p>You are about to start an e-mail to \"" + address + "\". If you need to communicate private information, please use \"Secure E-Mail\" in online banking instead, to protect your online security.<"+"/p>";
	var buttons = '<a href="mailto:' + address + '" onclick="hideDetails(); return true;" class="button default" title="Continue with the creation and sending of the e-mail"><span>Continue<'+'/span><'+'/a><a href="#" onclick="onlineBanking(true); return false;" title="Sign On to Account Manager (online banking) to send a secure message." class="button" style="margin-left:2px;"><span>&nbsp;Sign On&nbsp;<'+'/span><'+'/a><a href="#" onclick="hideDetails(); return false;" title="Close this warning, and return to the original page." class="button" style="margin-left:2px;"><span>&nbsp;Cancel&nbsp;<'+'/span><'+'/a>'
	popDetails(warning,"About to Send E-Mail",400,200,buttons);
}