this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = -30;
		yOffset = 10;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	var height = $(window).height();
	$("a.preview").hover(function(e){
		if((e.pageY + 445) > height){
			newHeight = height - 445 - 80;
		}
		else
			newHeight = e.pageY + xOffset;
			
			
		this.t = this.title;
		this.title = "";	
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='preview'><img src='"+ this.href +"' alt='Image preview' height='415' width='350' />"+ c +"</p>");
		$("#preview")
			.css("top",(newHeight) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
    
	$("a.preview").mousemove(function(e){
		if((e.pageY + 415) > height)
			newHeight = e.pageY - 325;
		else
			newHeight = e.pageY + xOffset;
			
			
		$("#preview")
			.css("top",(newHeight) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
	
	$('a.preview').click(function(){
		return false;
	})
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
