$(document).ready(function() {
	/* CONFIG */
	
		xOffset = 100;
		yOffset = 30;
	
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
	
	/* END CONFIG */
	$("a.resize").hover(function(e){
		this.t = $($(this).children('div')[0]).children('img')[0].title;
		this.title = "";	
		var c = (this.t != "") ? "<br /><p>" + this.t + "</p>": "";
		$("body").append("<div id='preview'><img src='"+ this.href +"' alt='Image preview' />"+ c +"</div>");								 
		$("#preview")
			.css("position", "absolute")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
		$("#preview img")
			.css("display", "block")
			.css("max-height", "250px")
			.css("max-width", "250px")
			.css("border", "2px solid #666666")
			.css("margin-left", "auto")
			.css("margin-right", "auto");
		$("#preview p")
			.css("margin", "0")
			.css("text-align", "center")
			.css("background-color", "#666666")
			.css("font-family", "Impact")
			.css("letter-spacing", "2px");
		$("#preview")
			.hide()
			.fadeIn(1000);
	},
	function(){
		this.title = this.t;	
		$("#preview").remove();
	});	
	$("a.resize").mousemove(function(e){
		$("#preview")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});
	
	$("a.resize img").each(function() {
		$(this).wrap("<div></div>").parent().css({'padding': '6px', 'background-color': '#555555'}).corner();
	});
});
