/*
 * 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(origPathFragment, newPathFragment, yOffsetVal, xOffsetVal){	
	/* CONFIG */
		
		
		yOffset = yOffsetVal;
		xOffset = xOffsetVal;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$j("a.preview IMG").hover(function(e){
		
		this.t = this.alt;
		this.alt = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		var origImage = $j(this).attr("src");
		//manipiuate existing image src to path to big image path - requires image be same name in different folder!!
		var bigImage = origImage.replace(origPathFragment, newPathFragment)
		
		$j("body").append("<p id='preview'><img id='largeImage' src='"+ bigImage +"' alt='Image preview' />"+ c +"</p>");
				
		$j("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.alt = this.t;	
		$j("#preview").remove();
    });	
	$j("a.preview").mousemove(function(e){
		$j("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};


