/**
 * INFOTAB
 *
 * @uses jQuery
 * @version 1.0
 * @author Martin Walper
 * @link klickhere.com
 *
 */

/*
### CSS:
	#INFOTAB { position:absolute; background:url(../img/various/infoTab.png) no-repeat center bottom; top:0px; left:50%; right:50%; width:350px; height:38px; margin-left:-175px; display:hidden;}
	#INFOTAB .cnt {padding:5px; padding-left:30px; font-size:11px; color:#fff; font-family:tahoma, arial, verdana; line-height:12px; overflow:hidden;}

### IMAGE:
	resource/_fw/img/various/infoTab.png
*/

function infoTabObj()
{
	// element id
	var _id = 'INFOTAB';
	// message
	var _message = '';
	// timeout
	var _timeout = 0;
	// callBack
	var _callBack = null;

	// create html
	this.createTab = function()
	{
		$("#"+_id).remove();
		$('body').append( '<div id="'+_id+'" style="display:none;"><div class="cnt"> </div></div>' );
		$(document).scroll(function ()
		{
			$("#"+_id).css("top", $(this).scrollTop());
    	});
	}
	// openBox
	this.open = function(msg, timesec)
	{
		_message = (msg)?msg:_message;
		_timeout = (timesec)?timesec:_timeout;
		if ($("#"+_id).css('display')!='none')
		{
			this.close(this.open);

		}
		else
		{
			//$.log("_message "+_message);
			$("#"+_id+" .cnt").empty().append(_message);
			$("#"+_id).css('display','block').slideDown();
			if (_timeout>0)
			{
				setTimeout('$.infotab.hide()',_timeout*1000,null);
			}
		}
	}
	// closeBox
	this.close = function(callBack)
	{
		$.log(callBack);
		_callBack = (callBack)?callBack:null;
		$("#"+_id).slideUp('slow',
			function()
			{
				$("#"+_id).css('display','none');
				if (_callBack)
				{
					_callBack.call(this);
				}
			}
		);
	}

	this.createTab();
}
infoTabObj.prototype.show = function(msg, timesec)
{
	this.open(msg, timesec);
}
infoTabObj.prototype.hide = function(callBack)
{
	this.close(callBack);
}
$(document).ready(function()
{
	$.extend({infotab: new infoTabObj()});
});