window.onload = function() {
	var BOX_HEIGHT = 200;
	
	var div = document.getElementById('xtramain05');
	var ul = div.getElementsByTagName('ul')[0];
	var lis = ul.getElementsByTagName('li');
	
	// Style DIV
	div.style.position = 'relative';
	
	// Style UL
	ul.style.position = 'relative';
	ul.style.height = "" + (BOX_HEIGHT + 25) + "px";
	
	// Add counter
	var counter = document.createElement('div');
	counter.id = 'jsCounter';
	div.appendChild(counter);
	
	// Add buttons
	var b1 = document.createElement('div');
	b1.id = 'jsBt1';
	div.appendChild(b1);
	var b2 = document.createElement('div');
	b2.id = 'jsBt2';
	div.appendChild(b2);
	
	// Apply styles and event handlers
	var li;
	for (var i=0, l=lis.length ; i<l ; i++) {
		li = lis[i];
		// LI
		li.style.background = '#fff';
		li.style.position = "absolute";
		li.style.left = "0";
		li.style.top = "0";
		li.style.width = "340px";
		li.style.height = BOX_HEIGHT + "px";
		li.style.overflow = "auto";
		li.style.display = "none";
		if (!document.all) li.style.borderBottomWidth = "2px";
	}
	
	// Select first tab
	homeShowBlock(0);
}

var currBlock = 0;

function homeShowBlock(index) {
	var lis = document.getElementById('xtramain05').getElementsByTagName('li');

	// Button states
	var bt1 = document.getElementById('jsBt1');
	var bt2 = document.getElementById('jsBt2');
	if (index == 0) {
		bt1.className = "";
		bt1.onclick = null;
	}
	else {
		bt1.className = "enabled";
		bt1.onclick = function() {homeShowBlock(index - 1)};
	}
	
	if (index == (lis.length - 1)) {
		bt2.className = "";
		bt2.onclick = null;
	}
	else {
		bt2.className = "enabled";
		bt2.onclick = function() {homeShowBlock(index + 1)};
	}

	lis[currBlock].style.display = "none";
	lis[index].style.display = "block";
	currBlock = index;
	
	document.getElementById('jsCounter').innerHTML = (index + 1) + "/" + lis.length;
}
