//	In setVars you can setup as many different tooltips as you want.
//	w = width, loc = object the tooltip is positioned relative to,
//	top = top offset, left = left offset, m = margin between the tooltip and its locator element.
//	Identifying the object is done with name tag (prevents browsers own tooltip from showing).
//	Tooltip div must have id tip+object name and appear in html code before the object.
//	The delay for tooltips to appear is set in setTimeout function in milliseconds.

function tooltipperEvents() {
	var mosaic = document.getElementById("mosaiikki");
	var linkies = mosaic.getElementsByTagName("img");
	for (var i=0; i < linkies.length; i++) {
		linkies[i].onmouseover = function() { tooltip(this,1); return false; };
		linkies[i].onmouseout = function() { hidetip(this); }
	}
}

function setVars(obj,x) {
	if (x == 1) { var w = 253, loc = obj, top = -190, left = -55, m = 0; }
	return [w,loc,top,left,m];
}

function tooltip(obj,x) {
	vars = setVars(obj,x);
	var tipid = "tip" + obj.getAttribute("name");
	tip = document.getElementById(tipid);
	tip.style.width = vars[0] + 'px';
	var coors = findPos(vars[1]);
	tip.style.top = coors[1] + vars[2] + 'px';
	tip.style.left = coors[0] + vars[3] - 10 + 'px';
	timer = setTimeout("tip.style.display = 'block'",500);
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function hidetip(obj) {
	clearTimeout(timer);
	var tipid = "tip" + obj.getAttribute("name");
	tip = document.getElementById(tipid);
	tip.style.display = 'none';
}

