/*
 * Image preview script 
 * powered by jQuery (http://www.jquery.com)
 * written by Ebrahim Imami (http://cssglobe.com)
 */
$.fn.imagePreview = function(options){	
	/* CONFIG */
		xOffset = 10;
		yOffset = 30;
		options = options || {};
		default_options = {attr:'href',click:false};
		if(options.attr==null)  options.attr  = default_options.attr ;
		if(options.click==null) options.click = default_options.click;
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	/* END CONFIG */
	if(options.click!=true && options.click!=false)
	{
		$(this).click(options.click);
	}else{
		$(this).click(function(){
			return options.click;
		});
	}
	$(this).hover(function(e){
		this.t = this.title;
		this.title = "";
		var c = (this.t != "") ? "<br/>" + this.t : "";
		$("body").append("<p id='overlay_preview'><img src='"+ $(this).attr(options.attr) +"' alt='Image preview' />"+ c +"</p>");
		$("#overlay_preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function(){
		this.title = this.t;
		$("#overlay_preview").remove();
    });	
	$(this).mousemove(function(e){
		$("#overlay_preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
};

