/********************************
Used to generate DHTML popup menus
Author: Andy Hill
Last updated: 12/9/2005
init(numTabs) is the <body>'s onLoad attribute where numTabs is the number of tabs on the page.
Spaces the tabs evenly and aligns popup menus to the tabs. 
Creation of tabs and popups is in header.cfm and genMenus.cfm 
Greatly modified from http://www.emmanuel.edu/alumni/default.asp

Uses several function defined in dom.js.
********************************/

var activeSub=0;
var SubNum=0;

function reDo(){ 
	window.location.reload() 
}
//window.onresize = reDo;
//Define global variables
var timerID = null;
var timerOn = false;
var timecount = 200;
var what = null;
var numTabs;
var popupY = 0;  //The vertical position of the popup menu

function init(numTabs, pageWidth) {
	this.numTabs = numTabs;
	window.status='';
	popupY = $('#separator').position().top;
	//Dynamically calculates page width
	tabsize = pageWidth / numTabs;
	//assign colors to tabs
	var color = "#770000";
	for (i = 1; i <= numTabs; i++) {
		$('#layer' + i).css('backgroundColor', color);
		$('#tabid' + i).css('width', tabsize);
		$('#layer' + i).css('top', popupY);		
	}
}

// Turns the layers on
function showLayer(layerName){
	//find postion of tab and set layer position accordingly
	var tabIndex = layerName.substr(5, 1);
	var objStr = 'tabid' + tabIndex;
	x = $('#' + objStr).position().left;	
	$('#' + layerName).css('left', x);
	$('#' + layerName).css('visibility', 'visible');
}

function hideAll(){
	for (var i = 1; i <= numTabs; i++) {
		setStyleById('layer' + i, 'visibility', "hidden");
	}
}

function startTime() {
	if (timerOn == false) {
		timerID=setTimeout( "hideAll()" , timecount);
		timerOn = true;
	}
}


function stopTime() {
	if (timerOn) {
		clearTimeout(timerID);
		timerID = null;
		timerOn = false;
	}
}