 
this.imagePreview = function(){	
	/* CONFIG */
		
		xOffset = -150;
		yOffset = 35;
		x=0;
		fw=450;
		DW=$(window).width();
		DH=$(window).height();
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.preview").hover(function(e){
		
		this.t = this.title;
		this.title = "";
		x=(this.rel!="")?this.rel:fw;
		var c = (this.t != "") ? this.t : "";
		$("body").append("<div id='preview' align='center'><img src='"+ this.href +"' alt='Image preview' align='absmiddle' /><div class='previewCaption'>"+ c +"</div></div>");
		
		sw=(e.pageY + xOffset);
		sw=60;
		sh=(e.pageX +yOffset);
		if((sh+fw+yOffset)>=DW)
			sh=e.pageX-fw-50;
		
		$("#preview")
			.css("top",sw + "px")
			.css("left",sh + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#preview").remove();
    });	
	$("a.preview").click(function(e){
		return false;
	});	
	$("a.preview").mousemove(function(e){
		x=(this.rel!="")?this.rel:fw;					 
		
		sw=(e.pageY + xOffset);
		sw=60;
		sh=(e.pageX +yOffset);
		if((sh+fw+yOffset)>=DW)
			sh=e.pageX-fw-50;
		$("#preview")
			.css("top",sw + "px")
			.css("left",sh + "px");
	});			
};


// starting the script on page load
$(document).ready(function(){
	imagePreview();
});
