/*
	User Interface
	==============
*/

/*
	InfoBox
	=======
*/
var fixed_infobox = false;

function init_infobox()
{
	ib = document.createElement("div");
	ib.id = "infobox";
	ib.setAttribute("id", "infobox");
	if(isIE)
		ib.setAttribute("className", "infobox");
	else
		ib.setAttribute("class", "infobox");

	document.getElementsByTagName("body")[0].appendChild(ib);
}

function show_infobox(_event, _html, _width)
{
	if(fixed_infobox)
		return;

	 ib = document.getElementById("infobox");
	 if(ib != undefined && ib != null)
	 {
	 	ib.innerHTML = _html;
	 	locate_infobox(_event);
	 	
	 	ib.style.display = "block";
	 	ib.style.width = _width + "px";
		ib.onclick = toggle_infobox;
	 }
}

function hide_infobox(_event)
{
	if(fixed_infobox)
		return;

	 ib = document.getElementById("infobox");
	 if(ib != undefined && ib != null)
	 {
	 	ib.style.display = "none";
	 }
}

function locate_infobox(_event)
{
	if(fixed_infobox)
		return;

	var posx = 0, posy = 0;

	ib = document.getElementById("infobox");
	if(ib == undefined || ib == null)
		return;

	if(_event == null || _event == undefined)
		_event = window.event;

	if(_event.pageX || _event.pageY)
	{
		posx = _event.pageX;
		posy = _event.pageY;
	}
	else if(_event.clientX || _event.clientY)
	{
		if(document.documentElement.scrollTop)
		{
			posx = _event.clientX + document.documentElement.scrollLeft;
			posy = _event.clientY + document.documentElement.scrollTop;
		}
		else
		{
			posx = _event.clientX + document.body.scrollLeft;
			posy = _event.clientY + document.body.scrollTop;
		}
	}

	ib.style.top = (posy + 10) + "px";
	ib.style.left = (posx - 20) + "px";
}

function toggle_infobox(e)
{
	fixed_infobox = !fixed_infobox;

	if(!fixed_infobox)
		hide_infobox(e);
}

function register_infobox_listeners(_id, _text, _width, _onclick)
{
	show_function = function(e) { show_infobox(e, _text, _width); };

	e = document.getElementById(_id);
	e.onmouseover = show_function;
	e.onmousemove = show_function;
	e.onmouseout = hide_infobox;
	if(_onclick == undefined || _onclick == null || _onclick)
		e.onclick = toggle_infobox;
}

/*
	Linkek
	======
*/
// Ugrás időzítve
function delayed_jump(_url, _delay)
{
	window.setTimeout("top.window.location=\"" + _url + "\";", _delay); 
}

// Megerősítés kérése
function link_confirm(_url, _question)
{
	ans = confirm(_question);

	if(ans)
		location = _url;
}


