// Vrati objekt
function gId(id)
	{
	return document.getElementById(id);
	}

// if is browser IE
function isIE()
	{
	var browserName=navigator.appName;
	if (browserName=="Microsoft Internet Explorer")
		return true;

	return false;
	}
// returns offset of object
function getOffset(object, pos)
	{
	if(!object)
		return 0;

	var res = 0;
	if(pos == 'x')
		{
		var val = object.offsetLeft;
		if(val == undefined)
			val = 0;
		res += val;
		}
	if(pos == 'y')
		{
		var val = object.offsetTop;
		if(val == undefined)
			val = 0;
		res += val;
		}

	if(isIE())
		res += getOffset(object.offsetParent, pos);

	//alert(object.id + ' ' + object.offsetLeft + ' => ' + res);

	return res;
	}
var lastShown = '';
function showMenu(id)
	{
	if(lastShown.length > 0)
		gId(lastShown + '_sub').style.display = 'none';

	if(!gId(id + '_sub'))
		return;

	posX = getOffset(gId(id), 'x');
	posY = getOffset(gId(id), 'y') + gId(id).offsetHeight;
	if(isIE())
		{
		posParX = getOffset(gId(id).offsetParent, 'x');
		posParY = getOffset(gId(id).offsetParent, 'y');
		posX -= posParX;
		posY -= posParY;
		}
	posY -= 3;
	//alert(posX + 'x' + posY);
	gId(id + '_sub').style.left = posX + 'px';
	gId(id + '_sub').style.top = posY + 'px';
	gId(id + '_sub').style.display = '';
	gId(id + '_sub').style.zIndex = 50000;

	lastShown = id;
	}

var timeout = 0;
function hideMenu(really)
	{
	clearTimeout(timeout);
	if(really == 1)
		gId(lastShown+'_sub').style.display = 'none';
	else
		timeout = setTimeout('hideMenu(1);', 3000);
	}

lastRef = '';
function showRefer(id)
	{
	if(lastRef.length > 0)
		gId(lastRef).style.display = 'none';

	gId(id).style.display = ''
	lastRef = id;
	}
