/*
 * Static Tooltip
 * Description: This plugin sets the content of static Tooltip Div, and its moving its left arrow next to the item list 
 * Author: Lukas Pesl
 * 
 */   

(function($){
	$.fn.extend({ 
		staticTooltip: function(options) {

			var defaults = {
			 arrowTop : 14,
			 arrowInc : 31,
			 arrowPositions : [14, 49, 80, 111, 142, 173, 204]
			};
			
			var options = $.extend(defaults, options);
			var selector = this.selector;
		
    		return this.each(function() {
					var obj = $(this);				
					var links = $('a.a', obj);				
          var items = $('.item', obj);
          var tip = $('.tooltip', obj);
          var arrow = $('.arrow', tip);

					links.hover(function() {

            var f = function() {
              var link = $(this);
              var index = links.index(link);
              var cb = function() {
                $('.content', tip).html(link.siblings('.hidden').html());
              }
              arrow.animate({marginTop: options.arrowPositions[index] + 'px'}, 100, 'swing', cb); // 300 pak 100
              links.removeClass('selected');
              link.addClass('selected');
            }					
      			var fn = (function(l){ return function(){f.call(l);} })(this);
            var timer = setTimeout(fn, 100); // 200
            $(this).data('timer', timer);
					}, function(){
					   clearTimeout($(this).data('timer'));
          });
					
    		});
    	}
	});
})(jQuery);



