// JavaScript Document

window.onload = function () {
	if (document.getElementById && document.getElementById('actors')) buildActorsMenu();
}

function buildActorsMenu() {
	var anchors = document.getElementById('actors').getElementsByTagName('a');
	
	var actorTables = document.getElementById('actors_info').getElementsByTagName('table');
	
	var actors = anchors.length;
	
	for (var i = 0; i < actors; i++) {
		if (!actorTables[i]) break;
		
		actorTables[i].style.display = 'none';
		actorTables[i].id = 'actor_'+i+'_tbl';
		anchors[i].id = 'actor_'+i;
		
		anchors[i].onclick = function () { showInfo(this.id) };
		anchors[i].href = 'javascript:void(0);';
	}
	
	var selected = Math.floor(Math.random() * (i - 1));
	
	showInfo('actor_'+selected);
}

function showInfo(i) {
	closeAll();
	document.getElementById(i+'_tbl').style.display = 'block';
	document.getElementById(i).className = 'selected';
}

function closeAll() {
	var actorTables = document.getElementById('actors_info').getElementsByTagName('table');
	
	for (var i = 0; i < actorTables.length; i++) {
		actorTables[i].style.display = 'none';	
		
		if (!document.getElementById('actor_'+i)) break;
		document.getElementById('actor_'+i).className = 'unselected';
	}
}
