/*
 * 	Easy Tooltip 1.0 - jQuery plugin
 *	written by Alen Grakalic	
 *	http://cssglobe.com/post/4380/easy-tooltip--jquery-plugin
 *
 *	Copyright (c) 2009 Alen Grakalic (http://cssglobe.com)
 *	Dual licensed under the MIT (MIT-LICENSE.txt)
 *	and GPL (GPL-LICENSE.txt) licenses.
 *
 *	Built for jQuery library
 *	http://jquery.com
 *
 */
 
 $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Malt Sacks</h4><p>The brewing process starts with malt barley stored in sacks.</p>'

		});
	});
 
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks1").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Roller Mill</h4><p>The blend of malts required for a particular recipe is cracked in a roller mill.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks2").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Grist Hopper</h4><p>The milled malt or "grist" is transported to the grist hopper above the brew house.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks3").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Mash Tun</h4><p>Next is the "mashing" where the grist is mixed with hot water in the mash tun. Over the course of a few hours, mashing converts the starches in the malts to sugar.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks4").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Brew Kettle</h4><p>This is followed by lautering in which the sweet liquid called "wort" is drawn of the bottom and pumped into the brew kettle.</p><p>Once the brew kettle is full, the wort is brought to the boil. Bittering hops are added at the beginning of the boil, while hops used for flavouring and aroma are added towards the end. The boil usually lasts one hour.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks5").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Heat Exchanger</h4><p>After the boil and a brief settling period, the wort is cooled by pumping it through a heat exchanger.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks6").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Fermentation Tank</h4><p>The cold wort is then transferred through hoses to temperature controlled fermentation tanks. Yeast is then immediately injected into the tank to initiate "fermentation" during which yeast cells ingest sugars into the wort to produce alcohol and carbon dioxide.</p><p>For lagers e.g Pilsner or Black Lager, fermentation is colder and slower, lasting two to three weeks. Cold conditioning or largering of the beers takes place in the same tank or in special largering tanks. The temperature is held near freezing from anywhere from two weeks to two months, depending on beer style.</p>'

		});
	});
	
  $(document).ready(function(){	
		$("a").easyTooltip();
		$("a#maltsacks7").easyTooltip({
			tooltipId: "easyTooltip2",
			content: '<h4>Conditioning Tank</h4><p>the finished beer is stored in conditioning tanks. From here the beer flows drectly to the bar or is kegged or bottled for take away.</p>'

		});
	});
 
(function($) {

	$.fn.easyTooltip = function(options){
	  
		// default configuration properties
		var defaults = {	
			xOffset: 20,		
			yOffset: 20,
			tooltipId: "easyTooltip",
			clickRemove: false,
			content: "",
			useElement: ""
		}; 
			
		var options = $.extend(defaults, options);  
		var content;
				
		this.each(function() {  				
			var beerprocesslinks = $(this).attr("beerprocesslinks");				
			$(this).hover(function(e){											 							   
				content = (options.content != "") ? options.content : beerprocesslinks;
				content = (options.useElement != "") ? $("#" + options.useElement).html() : content;
				$(this).attr("beerprocesslinks","");									  				
				if (content != "" && content != undefined){			
					$("body").append("<div id='"+ options.tooltipId +"'>"+ content +"</div>");		
					$("#" + options.tooltipId)
						.css("position","absolute")
						.css("top",(e.pageY - options.yOffset) + "px")
						.css("left",(e.pageX + options.xOffset) + "px")						
						.css("display","none")
						.fadeIn("fast")
				}
			},
			function(){	
				$("#" + options.tooltipId).remove();
				$(this).attr("beerprocesslinks",beerprocesslinks);
			});	
			$(this).mousemove(function(e){
				$("#" + options.tooltipId)
					.css("top",(e.pageY - options.yOffset) + "px")
					.css("left",(e.pageX + options.xOffset) + "px")					
			});	
			if(options.clickRemove){
				$(this).mousedown(function(e){
					$("#" + options.tooltipId).remove();
					$(this).attr("beerprocesslinks",beerprocesslinks);
				});				
			}
		});
	  
	};

})(jQuery);
