function toggleDisplay(id) {  
	var div_arr = new Array();
	div_arr = document.getElementsByTagName('div');
	for(var i = 0; i < div_arr.length; i++) {
	  if (div_arr.item(i).getAttribute('name') == 'div_l1') {
		div_arr.item(i).style.display = 'none';
	  }
	}

	var img_arr = new Array();
	img_arr = document.getElementsByTagName('img');
	for(i = 0; i < img_arr.length; i++) {
	  if (img_arr.item(i).getAttribute('name') == 'img_l1') {
		img_arr.item(i).style.display = 'none';
	  }
	}

	document.getElementById(id).style.display = '';
	document.getElementById(id + '_src').style.display = '';
}

function toggleTR(name) {
	var tr_arr = new Array();
	tr_arr = document.getElementsByTagName('tr');
	for(var i = 0; i < tr_arr.length; i++) {
	  if (tr_arr.item(i).getAttribute('name') == name) {
		if (tr_arr.item(i).style.display == 'none') {
		  tr_arr.item(i).style.display = '';
		  document.getElementById(name + '_src').src = "images/arrow_bottom.png";
		}
		else {
		  tr_arr.item(i).style.display = 'none';
		  document.getElementById(name + '_src').src = "images/arrow_right.png";
		}
	  }
	}
}

function logo(timeout) {
	var td_arr = new Array();
	td_arr = document.getElementsByTagName('td');
	for(var i = 0; i < td_arr.length; i++) {
	  if (td_arr.item(i).getAttribute('name') == 'td_logo') {
		var r = Math.floor(Math.random()*10);
		if (r >= 0 && r <= 3) {
			td_arr.item(i).style.backgroundColor = '';
		}
		if (r >= 4 && r <= 6) {
			td_arr.item(i).style.backgroundColor = 'white';
		}
		if (r >= 7 && r <= 9) {
			td_arr.item(i).style.backgroundColor = '#7D053F';
		}
	  }
	}
	if (timeout > 0) {
		setTimeout("logo(" + timeout + ");", timeout);
	}
}

function logo2(max_y, max_x, timeout) {
	var td_arr = new Array();
	var td_logo_arr = new Array();
	td_arr = document.getElementsByTagName('td');
	for(var i = 0; i < td_arr.length; i++) {
	  if (td_arr.item(i).getAttribute('name') == 'td_logo') {
		td_logo_arr.push(td_arr.item(i).id);
	  }
	}
	var td_logo, t_id, t;
	var t_id_arr, y, x, y2, x2, u;

	td_logo = Math.floor(Math.random()*(td_logo_arr.length - 1));
	t_id = td_logo_arr[td_logo];
	t = document.getElementById(t_id);

	if (t.style.backgroundColor !== '') {
		t_id_arr = t_id.split("_");
		y = t_id_arr[1];
		x = t_id_arr[2];
		y2 = parseInt(y, 10) + Math.floor(Math.random()*3) - 1;
		x2 = parseInt(x, 10) + Math.floor(Math.random()*3) - 1;
					
		if (y2 >= 0 && y2 <= max_y && x2 >= 0 && x2 <= max_x) {
			u = document.getElementById("td_" + y2 + "_" + x2);
			if (u.style.backgroundColor === '') {
				u.style.backgroundColor = t.style.backgroundColor;
				t.style.backgroundColor = '';
			}
		}
	}
	
	setTimeout("logo2(" + max_y + ", " + max_x + ", " + timeout + ");", timeout);
}

function init() {
	toggleTR('tr_education');
	toggleTR('tr_experience');
	toggleTR('tr_languages');
	toggleTR('tr_certificates');
	toggleTR('tr_other');
	logo(0);
	logo2(2, 36, 20);
}
