/*
 * 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 */
		
		
		
		xOffset = 100;
		yOffset = -330;
		mouseX = 0;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	var yOffsetN = 50;
	$(".PhotoGallery").mousemove(function(e){
		mouseX = e.pageX  - this.offsetLeft;
		
		});
	$("a.preview[rel=img]").hover(function(e){
		var offset = $(this).offset();
		var yOffset = offset.left;
		var xOffset = offset.top;
		

		if(mouseX > 300){ var yOffsetN = -390; } else { var yOffsetN = 10; }
		

		yOffsetN = yOffset + yOffsetN;
		this.t = $(this).find(".description").html();
		this.h = this.href;	
		this.i = $(this).find(".image").html();
		var c = (this.t != "") ? "<br/>" + this.t : "";
		
		$("body").append("<p id='preview' rel='img'><img src='"+ this.i +"' alt='Image preview' /><span>"+ c +"</span></p>");	
		
					 
		$("#preview")
		
			.css("top",(xOffset - 50) + "px")
			.css("left",(yOffsetN + 80) + "px")
			.fadeIn("fast");						
    },
	function(){
		//this.title = this.t;	
		$("#preview").remove();
		yOffsetN = 0;
    });	
	
	$("a.preview[rel=txt]").hover(function(e){
		
		xOffset = -30;
		yOffset = -150;
		
		this.t = $(this).find("span").html();
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='preview' rel='txt'><div class='desc'>"+ c +"</div></div>");								 
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		//this.title = this.t;
		$("#preview").remove();
    });				
};

// starting the script on page load
$(document).ready(function(){
	imagePreview();
});




