/*
 * 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 = 10;
    yOffset = 30;

    // these 2 variable determine popup's distance from the cursor
    // you might want to adjust to get the right result

    /* END CONFIG */
    $j("#article .contentimage").hover(function (e) {
        this.t = this.title;
        this.title = "";
        $j(this).fadeTo("fast", 0.5);

        ///umbraco/ImageGen.ashx?image=/media/50244/dsc_0020.jpg&width=500

        var src = $j(this).attr("alt");
        $j("body").append("<div id='preview'><span class='wrap1'><span class='wrap2'><span class='wrap3'><img src='/umbraco/ImageGen.ashx?image=" +
         src +
          "&width=500' alt='Image preview' /></span></span></span></div>");
        $j("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px")
			.fadeIn("fast");
    },
	function () {
	    this.title = this.t;
	    $j("#article .contentimage").fadeTo("fast", 1);
	    $j("#preview").remove();
	});
    $j("#article .contentimage").mousemove(function (e) {
        $j("#preview")
			.css("top", (e.pageY - xOffset) + "px")
			.css("left", (e.pageX + yOffset) + "px");
    });
};


// starting the script on page load
$j(document).ready(function(){
	imagePreview();
});