//==============================================================================
//------------------------------------------------------------------------------
function tip()
{
	//----------------------------------------------------------------------
	// nagenerovani konfigurace pro tootipy
	
	// spolecny zaklad
	this.config =
		[{
			 offset: [1, 0]
			 , effect: "toggle"
			 , opacity: 0.98
			 , position: "bottom center"
			 , relative: true
			, predelay: 140
		 }];
	
	// rozkopirovani
	for ( var i = 1; i <= 9; ++ i )
	{
		this.config[i] = [];
		for ( var a in this.config[0] )
		{
			this.config[i][a] = this.config[0][a];
		}
	}
	
	// dodatecne nastaveni pro kazdy druh
	this.config[1].position = "top center";
	this.config[2].position = "center right";
	
	this.config[8].relative = false;
	this.config[9].relative = false;
	this.config[9].position = "top center";
}

//======================================================================
//------------------------------------------------------------------------------
// inicializacni funkce
tip.prototype.bind = function()
{
	var o = this;
	$(".tip").each(function()
	{
		var a = [];
		var c = $(this).attr('class').split(" ");
		// vyhledame si class tip-X nebo tip-X-Y
		for ( var i = 0; i < c.length; ++ i )
		{
			if ( c[i].substr(0,4) != 'tip-' ) continue;
			a = c[i].substr(4).split("-");
			break;
		}
		if ( ! a[0] ) return;
		if ( a.length < 2 || ! o.config[a[1]] ) a[1] = 0;
		var x = o.config[a[1]];
		x.tip = "#tip-" + a[0];
		$(this).tooltip( x );
	});
}

//==============================================================================
var tip = new tip();

$(document).ready(function(){ tip.bind(); });

