/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * 
 * written by Alen Grakalic (http://cssglobe.com)
 * 
 * for more info visit http://cssglobe.com/post/1695/easiest-tooltip-and-image-preview-using-jquery
 *
 */
 
this.imagePreview = function(){	
	/* CONFIG */
		
		var xOffset = -30;
		var yOffset = -40;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$(".preview").hover(function(e){

		$(".preview a").removeAttr("title"); // Remove title attribute from link     
		$(".preview a img").removeAttr("title"); // Remove title attribute from image     

	    var str1 = $("p.group_title", this).text();
	    var str2 = $("p.group_members", this).text();
	    var str3 = $("p.group_author", this).text();
		
		$("body").append("<div id='popup_preview'><p><div class='tooltip_top'></div><div class='tooltip_middle'><p>"+ str1 +"</p><p>"+ str2 +"</p><p>"+ str3 +"</p></div><div class='tooltip_bottom'></div></p></div>");								 
		$("#popup_preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("200");						
    },
	function(){
		$("#popup_preview").remove();
    });	
	$(".preview").mousemove(function(e){
		$("#popup_preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};