/* bbb.js
Code for active elements in the Big Blue Box (BBB) content areas on some internal pages.
*/

function bbbInit() {
	pageInit();
	var secName = getHash();
	if((secName.length==8) && (secName.substring(0,7)=="section")) {
		var sec = +secName.charAt(secName.length-1);
		showSection(sec);
		bbbTurnOff(1);
		bbbmenuReset();
	}
}

// get value of hash at end of url
function getHash() {
	var h = ""+document.location;
	var ha = h.split("#");

	if(ha.length>1) return ha[1];
	return "";
}


currentSection=1;

function showSection(num) {
	if(num==currentSection) return;
	
	document.getElementById("bbbcontent"+currentSection).className="bbbhide";
	document.getElementById("bbbcontent"+num).className="bbbshow";
	
	currentSection=num;
	fixHeight();
}

var resetAbortCode=null;
var currentHighlight=1;

function bbbmenuOver(num) {
	if(resetAbortCode) clearTimeout(resetAbortCode);
	if(num==currentHighlight) return;

	if(currentHighlight>0) bbbTurnOff(currentHighlight);
	bbbTurnOn(num);
	currentHighlight=num;
}

function bbbmenuOut(num) {
	bbbTurnOff(currentHighlight);
	currentHighlight=-1;
	resetAbortCode = setTimeout("bbbmenuReset();", 250);
}
	
function bbbTurnOn(num) {
	if(num==1) document.getElementById("bbbmenuitem"+num).className = "bbbmenufirston";
	else document.getElementById("bbbmenuitem"+num).className = "bbbmenuitemon";
	document.getElementById("bbbmenulink"+num).className = "bbbmenulinkon";
}

function bbbTurnOff(num) {
	if(num==1) document.getElementById("bbbmenuitem"+num).className = "bbbmenufirst";
	else document.getElementById("bbbmenuitem"+num).className = "bbbmenuitem";
	document.getElementById("bbbmenulink"+num).className = "bbbmenulink";
}

function bbbmenuReset() {
	bbbTurnOn(currentSection);
	currentHighlight=currentSection;
}
