// JavaScript Document
var idx = 0;
var boxes;
var auto = true;

function initBoxes(arrBoxes) {
	boxes = arrBoxes;
}

function changeBox() {
	if (!auto) return;
	
	idx = (idx == boxes.length - 1) ? 0 : idx + 1;
	setBox(idx, true);
}

function setBox(idx, setAuto) {
	auto = setAuto;

	var header;
	var box;
	var tab;

	for (i=0; i<boxes.length; i++) {
		header = document.getElementById('box_header_' + boxes[i]);
		box = document.getElementById('box_body_' + boxes[i]);
		tab = document.getElementById('tab_' + boxes[i]);
		
		if (header) {
			header.style.display = (i == idx) ? "block" : "none";
		}
		box.style.display = (i == idx) ? "block" : "none";
		tab.className = (i == idx) ? "on" : "off";
	}
}
