var tooltip_div;
var tooltip_top = 24;
var tooltip_left = 8;

// Global array tooltip_texts MUST BE defined outside with custom tooltips texts
// key value of the arrary is the id of the calling HTML element
tooltip_texts = new Array();
/* For example:
tooltip_texts["tspace"] = 'Aumenta lo spazio a disposizione del tuo sito web';
tooltip_texts["ttraffic"] = 'Aumenta il traffico mensile a disposizione del tuo sito web';
tooltip_texts["tdb"] = 'Aumenta la potenza del database a disposizione del tuo sito web';
tooltip_texts["tfso"] = 'Permette al tuo sito di comunicare direttamente con altri siti';
tooltip_texts["thtaccess"] = 'Permette di modificare le impostazioni delle singole cartelle del tuo spazio web';
*/

function hint_show(obj, event) {
	if (!tooltip_div || !tooltip_div.style) return;
	var str = tooltip_texts[obj.id];

	tooltip_div.innerHTML = str;
	tooltip_div.style.display = 'block';
	hint_move(obj, event);
}

function hint_hide(obj, event) {
	if (!tooltip_div || !tooltip_div.style) return;
	tooltip_div.style.display = 'none';
}

function getMouseXY(e) {
	if (e.pageX !== undefined) {
		return {x: e.pageX, y: e.pageY};
	} else {
		return {x: e.clientX + document.documentElement.scrollLeft - document.documentElement.clientLeft, y: e.clientY + document.documentElement.scrollTop - document.documentElement.clientTop};
	}
}

function hint_move(obj, event) {
	if (!tooltip_div || !tooltip_div.style) return;
	var pos = getMouseXY(event);
	tooltip_div.style.left = (pos.x + tooltip_left) + 'px';
	tooltip_div.style.top = (pos.y + tooltip_top) + 'px';
}