

var infoBox = function(){

	// -=- begin saját változók

	this.divText=null;
	this.divCaption=null;
	this.divBox=null;
	this.lastTarget=null;
	this.lastText=null;
	this.frameColor='#1D5F85';
	this.initDone = false;
	this.sizeReference = document.body;

	this.popped = 0;


	this.on = false;

	// -=- e n d

	this.onShow = function(){}
	this.onHide = function(){}


	// -=- begin infó ablak mutatása
	this.showInfo = function(target,text,properties)
	{
		/*
			a lastTarget azért kell, hogy az ablak ne villogjon több ráhívás esetén (pl onmouseover eseménykor felléphet ilyesmi)
		*/
		properties = typeof(properties)!='object' ? {template:properties} : properties;


		if(properties.template=='blue')
		{
			this.divBox  = $$('#infobox_blue');
			this.divText = $$('#infobox_blue div.infobox_body');
		}
		else
		{
			this.divBox  = $$('#infobox_white');
			this.divText = $$('#infobox_white div.infobox_body');
		}

		this.initDone = true;

		if(this.lastTarget==target && this.lastText==text)
			return;

		this.lastTarget = target;
		this.lastText = text;
		this.popped = 0;

		var pos = $(target).size() ? $(target).offset() : {top:0,left:0};

		if(typeof(text)=='object' && typeof(text.nodeName)=='string')
		{
			this.divText.innerHTML='';
			this.divText.appendChild(text.cloneNode(true));
			this.divText.firstChild.style.display='';
		}
		else
		{
			this.divText.innerHTML = text;
		}

		this.onShow();
		this.on = true;

		this.divBox.style.display = 'block';

		switch(properties.hPos)
		{
			case 'right'  : pos.left += target.clientWidth+2;break;
			case 'left'   : pos.left -= this.divBox.clientWidth-1;break;
			case 'center' : pos.left += (target.clientWidth/2)+2;break;
			case 'smart'  : pos.left += ( pos.left > this.sizeReference.clientWidth/2 ? -this.divBox.clientWidth+1 : target.clientWidth+2);
		}

		var rootPos = {top:0,left:0};
		switch(properties.vPos)
		{
			case 'under'  : pos.top+=target.clientHeight+1;break;
			case 'smart'  : pos.top += ( ( rootPos.top+this.divBox.clientHeight < pos.top && pos.top >= this.sizeReference.clientHeight-this.divBox.clientHeight) ? target.clientHeight-this.divBox.clientHeight+2 : 0);
			default  : pos.top-=this.divBox.clientHeight+1;pos.top+=8;break;
		}

		if(typeof(properties.hPlus)!='undefined')
			pos.left+=properties.hPlus;

		if(typeof(properties.vPlus)!='undefined')
			pos.top+=properties.vPlus;

		this.divBox.style.left = pos.left+'px';
		this.divBox.style.top  = pos.top+'px';

		if(document.all)
		{
			if(this.divText.firstChild.nodeName=="#text")
				$(this.divBox).width(10+this.divText.innerHTML.length*7);
			else
				$(this.divBox).width(12+$(this.divText.firstChild).width());
		}

		window.setTimeout('infoBox.popped = 1',200);

	}
	// -=- e n d



	// -=- begin infó ablak elrejtése
	this.hide = function()
	{
		if(!this.initDone)
			return;

		this.divBox.style.display = 'none';
		this.lastTarget = null;
		this.onHide();
		this.on = false;
	}
	// -=- e n d
}

// -=- egyke létrehozása
infoBox = new infoBox();
