/*
jQuery Bubble Plugin.
More or less like tooltip plugin but with a less pc-ish name and some customized behavior that we needed
Patrik Engborg, 2009
*/

(function($) {
	 
	$.fn.bubble = function(options)
	{
		var defaults =
		{
			selector: 'div.bubble' // default selector to search for (the bubble to toggle)
		};
		  
		var opts = $.extend(defaults, options); // Extend defaults with options
		
		return this.each(function()
		{
			var $this = $(this);
			
			var container_height = parseInt($this.css('height')) -20; // Get height of bubbles container and subtract with 20 (px)
			
			var $bubble = $this.find(opts.selector); // The presumed bubble we wanna toggle
			
			if ($bubble.size()) // Check if it exists
			{
				$bubble.css('top',container_height); // Add top value to place it nicely
				
				$this.hover(function() // Show bubbe on mouseover, hide on mouseout
				{				
					$bubble.show();
				},
				function()
				{
					$bubble.hide();
				});
			}
		});
	};
	
})(jQuery);