window.onload = function() {	
	setTimeout(start, 800);
}


var times = [];
var actions = [];
var COLS = 4;
var ROWS = 3;

function $(id) {
		return document.getElementById(id);
	}

function add(action, time) {	
	times.push(time);
	actions.push(action);
}

function addRel(action, time) {
	times.push(parseInt(times[times.length - 1]) + time);
	actions.push(action);
}


function start() {	
	for	(var i=0; i < times.length; i++) {
		//alert(actions[i] + " at " + times[i]);
		setTimeout(actions[i], times[i]);
	}
}


var col = 1;
var row = 1;
function hideAll() {	
	for (var i = 1; i < ROWS+1; i++) {
		for(var j = 1; j < COLS+1; j++) {
			cell(i, j).style.visibility = "hidden";
		}
	}
	col = 1;
	row = 1;
	$("introLogo").style.visibility = "hidden";
	$("introTitle").style.visibility = "hidden";
}


function nextCell() {	
	cell(row, col).style.visibility = "visible";
	
	col = (col == COLS?1:++col);
	row += (col == 1?1:0);
}

function showCell(i, j) {
	cell(i, j).style.visibility = "visible";
}

function cell(i, j) {
	return $("cell"+i+j);
}

function showId(id) {
		$(id).style.visibility = "visible";
	}

function exit() {
	document.location.href="index.html";
}



add("hideAll()", 0);

var GAP = 300;

for (var i = 1; i < COLS+1; i++) {
	add("showCell(" + 1 + "," + i + ")", 100+GAP*i);
	add("showCell(" + 2 + "," + i + ")", 100+GAP*i);
	add("showCell(" + 3 + "," + i + ")", 100+GAP*i);
}


addRel("showId('introLogo')", GAP);
addRel("showId('introTitle')", 0);




/*for (var i =1; i < (ROWS*COLS)+1; i++) {
	add("nextCell()", 100 + 40*(i));
/*	if (i == (ROWS*COLS)) {
		addRel(start, 1000);
	}
}	*/
addRel("exit()", 2000);

