var aryPix, objImg, objDescr, curTab;
var aryTabs, aryTimgs, aryTabBoxes;
var imgGrayCorner, imgGrayBkgrnd, imgBlueCorner, imgBlueBkgrnd;
var tmDelay = 6000;
var numTabs = 4;

function rotateTabs() {
	if (curTab == numTabs) { curTab = 0; } //start over from the top.
	ActivateTab(curTab);
	curTab++; 
	setTimeout('rotateTabs()',tmDelay);
}

function ActivateTab(tabNum) {
	//To change a tab:
	// 1. change the background color to blue_top, change corner image to blue corner, change text color to white, change the content div display to block
	// 2. change the other tabs to gray text, gray_top, gray_corner, and display to none.
	for (var i=0; i<numTabs; i++) {
		if (tabNum == i) { //make this one blue
			aryTabs[i].style.backgroundImage = "url(" + imgBlueBkgrnd.src + ")";
			aryTabs[i].style.color = "#FFF";
			aryTabs[i].style.borderColor = "#016698";
			aryTimgs[i].src = imgBlueCorner.src;
			aryTimgs[i].style.borderBottom = "1px solid #016698";
			aryTabBoxes[i].style.display = "block";
		} else { //make it gray
			aryTabs[i].style.backgroundImage = "url(" + imgGrayBkgrnd.src + ")";
			aryTabs[i].style.color = "#CCC";
			aryTabs[i].style.borderColor = "#DFE5F3";
			aryTimgs[i].src = imgGrayCorner.src;
			aryTimgs[i].style.borderBottom = "1px solid #DFE5F3";
			aryTabBoxes[i].style.display = "none";
		}
	}
}

function initMainPage() {
	aryTabs = new Array(numTabs);
	aryTabs[0] = getObject("tab0");
	aryTabs[1] = getObject("tab1");
	aryTabs[2] = getObject("tab2");
	aryTabs[3] = getObject("tab3");
	aryTimgs = new Array(numTabs);
	aryTimgs[0] = getObject("timg0");
	aryTimgs[1] = getObject("timg1");
	aryTimgs[2] = getObject("timg2");
	aryTimgs[3] = getObject("timg3");
	imgGrayCorner = new Image(17,24);
	imgGrayCorner.src = "_style/img/tab_gray_corner.png";
	imgBlueCorner = new Image(17,24);
	imgBlueCorner.src = "_style/img/tab_016698_corner.png";
	imgGrayBkgrnd = new Image(6,35);
	imgGrayBkgrnd.src = "_style/img/tab_gray_top.png";
	imgBlueBkgrnd = new Image(6,35);
	imgBlueBkgrnd.src = "_style/img/tab_016698_top.png";
	aryTabBoxes = new Array(numTabs);
	aryTabBoxes[0] = getObject("tcontent0");
	aryTabBoxes[1] = getObject("tcontent1");	
	aryTabBoxes[2] = getObject("tcontent2");
	aryTabBoxes[3] = getObject("tcontent3");
	curTab = 0;

	//rotateTabs();
}

