(function($){  
	$.fn.tooltipRC = function(options) {  	
		return this.each(function() {
			tooltipElement = $(this);
			var t = $(tooltipElement).attr('title');

			$(tooltipElement).hover(
				function(e) {
					$(this).attr('title', "");
					$("body").append("<div id='tooltip'>"+ t +"<div class='arrow-tooltip-simple'></div></div>");
				        xOffset = $("#tooltip").height()+20;
				        yOffset = -10;
				    $(".arrow-tooltip-simple").css({backgroundPosition: -yOffset-10 + 'px -170px'});
			        $("#tooltip")
				        .css("top",(e.pageY - xOffset) + "px")
				        .css("left",(e.pageX + yOffset) + "px")
				        .fadeIn("slow");
				},
				function(e) {
					$(this).attr('title', t);
					$("#tooltip").remove();
				}
			);

			$(tooltipElement).mousemove(
				function(e) {
					$("#tooltip")
						.css("top",(e.pageY - xOffset) + "px")
				        .css("left",(e.pageX + yOffset) + "px");
				}
			);
			
		});
		
	};  
	
	$.fn.tooltipRCBible = function(options) {  	
		return this.each(function() {
			tooltipElement = $(this);
			var t = $(tooltipElement).attr('title');
			
			$(tooltipElement).hover(
				function(e) {
					$(this).attr('title', "");
					$("body").append("<div id='tooltip-bible'><div style='border-left: 1px solid #cfcfcf; border-right: 1px solid #cfcfcf; padding: 3px 10px;'><p style='margin-top: 2px;'>"+ t +"</p><div class='arrow-tooltip'></div></div></div>");
						xOffset = $("#tooltip-bible").height()+19;
				        yOffset = -($("#tooltip-bible").width()-40);
				    $(".arrow-tooltip").css({backgroundPosition: -yOffset-15 + 'px -150px'});
			        $("#tooltip-bible")
				        .css("top",(e.pageY - xOffset) + "px")
				        .fadeIn("slow");
				},
				function(e) {
					$(this).attr('title', t);
					$("#tooltip-bible").remove();
				}
			);
			
			$(tooltipElement).mousemove(
				function(e) {
					$("#tooltip-bible")
						.css("top",(e.pageY - xOffset) + "px")
				        .css("left",(e.pageX + yOffset) + "px");
				}
			);
			
		});
		
	};  
})(jQuery);

$(document).ready(function(){
	$("a.tooltip").tooltipRC();
	$("a.ref-tooltip").tooltipRCBible();
});
