/*
 * 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 : -18,
			 arrowInc : 33,
			 arrowPositions : [-18, 16, 49, 82, 115, 148, 181, 214, 247, 280, 313, 346, 379, 412, 445, 478, 511, 544, 577, 610, 643, 676]
			};
			
			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.css('marginTop', (options.arrowTop + (index * options.arrowInc)) + 'px');
              //arrow.css('marginTop', options.arrowPositions[index] + 'px');
              //tip.animate({opacity: 0.0}, 300, 'swing', function(){tip.animate({opacity: 1.0}, 300, 'swing');});
              arrow.animate({marginTop: options.arrowPositions[index] + 'px'}, 100, 'swing', cb); // 300
              links.removeClass('selected');
              link.addClass('selected');
            }					
      			var fn = (function(l){ return function(){f.call(l);} })(this);
            var timer = setTimeout(fn, 200); // 200
            $(this).data('timer', timer);
					}, function(){
					 clearTimeout($(this).data('timer'));
          });
					
    		});
    	}
	});
})(jQuery);



