/*
dodac pustego div o id="hint_content", ustawic style
w obrazku dodac title="[opis]" rel="hint"
w body onload="inicjujHint()"
*/

function showHint (text, obj) {

//	alert (obj.getAttribute('title'));
	$('hint_content').innerHTML = text;
	// ustawienie hintu
	var posnX = findPosX (obj);
	var posnY = findPosY (obj);
	
	winSizeW = document.body.offsetWidth;
	
	if ((posnX+150) > winSizeW)
	{
		with ($('hint_content').style) {
		left = (posnX-200)+'px';
		top = (posnY+30)+'px';
		display = 'block';
		}
	} 
	else {

	with ($('hint_content').style) {
	left = (posnX+30)+'px';
	top = (posnY+30)+'px';
	display = 'block';
	
	}	
		}
		
}

function hideHint () {
	with ($('hint_content').style) {
		display = 'none';
	}
}

function findPosX(obj){
		var curleft = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curleft += obj.offsetLeft
				obj = obj.offsetParent;
			}
		}
		else if (obj.x)
			curleft += obj.x;
		return curleft;
	}
	function findPosY(obj){
		var curtop = 0;
		if (obj.offsetParent)
		{
			while (obj.offsetParent)
			{
				curtop += obj.offsetTop
				obj = obj.offsetParent;
			}
		}
		else if (obj.y)
			curtop += obj.y;
		return curtop;
	}


function inicjujHint () {
	for (i=0; (ab=document.getElementsByTagName('img')[i]); i++) { 
		if (ab.getAttribute('rel') == 'hint') {
			obj = ab;
			if (document.all) {
				obj.attachEvent('onmouseover', showHint);
				obj.attachEvent('onmouseout', hideHint);
			} else {
				obj.addEventListener('mouseover', showHint, false);
         	obj.addEventListener('mouseout', hideHint, false);
			}
		}
	}
}

