function init() {
	var mapAreas = document.getElementById("mapa");
	mapAreas = mapAreas.getElementsByTagName("area");	
	for (var i=0; i<mapAreas.length;i++) {
		var id = mapAreas[i].getAttribute("id");
		var name = mapAreas[i].getAttribute("alt");
		mapAreas[i].title=name;
		mapAreas[i].onmouseover=function(){tramOver(this);};
	    mapAreas[i].onmouseout=function(){tramOut(this);};
		mapAreas[i].onfocus=function(){tramOver(this);};
	    mapAreas[i].onblur=function(){tramOut(this);};		
	}
	//genFullMap();
}

function tramOver(obj) {
	window.status = obj.alt;
	var popupDiv = document.getElementById("dataPopUp");
	popupDiv.innerHTML = '<p>' + obj.alt + '</p>';
	popupDiv.style.visibility = 'visible';
}

function tramOut(obj) {
	popupDiv = document.getElementById("dataPopUp");
	popupDiv.style.visibility = 'hidden';
}

// Funció per a generar l'imageMap amb title i alt per a que surti el tooltip en passar per sobre
// No s'utilitza en producció

function genFullMap() {
	var mapAreas = document.getElementById("mapa");
	mapAreas = mapAreas.getElementsByTagName("area");
	var st='';
	for (var i=0; i<mapAreas.length; i++) {
		st += '<area';
		st += ' shape="' + mapAreas[i].shape + '"';
		st += ' coords="' + mapAreas[i].coords + '"'; 
		//st += ' org="' +  mapAreas[i].alt + '"';
		st += ' alt="'+ mapAreas[i].alt + '"';
		st += ' />\n';
	}
	var textArea = document.createElement('TEXTAREA');
	textArea.rows = 20;
    textArea.cols = 80;
	//alert(st);
	textArea.value = st;
	document.body.appendChild(textArea);
}
