// Code for the creation of the header
// Edgar Gonz�lez i Pellicer

// Items
var items  = [ 'index', 'papers', 'soft', 'stuff' ];
var labels = [ 'Information', 'Publications', 'Software', 'Stuff' ];

// Who we are
var who;

// Inside an item
function inside(item) {
    document.getElementById(item).bgColor = "#5B0F5E";
}

// Clicked on an item
function clicked(item) {
    if (item != who) {
	window.location = "./" + item + ".html";
	//window.location = "http://www.lsi.upc.edu/~rasin/" + item + ".html";
    }
}

// Left an item
function outside(item) {
    if (item != who) {
	document.getElementById(item).bgColor = "#182060";
    }
}

// Write the header
function writeHeader(item) {
    // Remember who you are
    who = item;

    // Number of elements
    var n = items.length;

    // Start the table
    document.write('<table rows="2" cols="' + n + '" cellpadding="5" ' +
		   'cellspacing="5" border="0" width="90%" align="center">');
    document.write('<colgroup span="' + n +
		   '" width="' + Math.floor(100 / n) + '%"></colgroup>');
    
    // My name
    document.write('<tr><td colspan="' + n + '" bgcolor="#182060">');
    document.write('<table rows="1" cols="1" cellpadding="30" border="0">');
    document.write('<tr><td align="center"><font size="+3" color="#ffffff">' +
		   'Roberto Javier As&iacute;n Ach&aacute;</font></td></tr>');
    document.write('</table></td></tr>');

    // Each section
    document.write('<tr>');
    for (var i = 0; i < n; ++i) {
	var cur = items[i];
	document.write('<td id="' + cur + '" bgcolor="' +
		       (cur == who ? '#5B0F5E' : '#182060') +
		       '" onmouseover="javascript:inside(\'' + cur + '\')" ' +
		       'onclick="javascript:clicked(\'' + cur + '\')" ' +
		       'onmouseout="javascript:outside(\'' + cur + '\')" ' +
		       'align="center"><font color="#ffffff">' + labels[i] +
		       '</font></td>');
    }
    document.write('</tr></table>');
}




