﻿

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 */
    $("a.preview").bind("click", function(e) {
        this.t = this.title;
        /*this.title = "";*/
        var c = (this.t != "") ? "<br/>" + this.t : "";
        $("body").append("<a  href='' id='preview'><img src='" + this.getAttribute("largeImg") + "' border='0' />" + c +
         "</a>");
        var y = 0;
        if (self.pageYOffset) // all except Explorer
        {
            y = self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop)
        // Explorer 6 Strict
        {
            y = document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
            y = document.body.scrollTop;
        }

        if (y < 240)
            y = 240;

        y += 63;

        $("#preview")
            .css("top", (y) + "px")
            .css("margin-left", (this.getAttribute("largeWidth")) ? "-" + (this.getAttribute("largeWidth") / 2) + "px" : "-300px")
			.fadeIn("fast");

        $("#preview").bind("click", function(e) {
            $("#preview").fadeOut("slow").remove();
            return false;
        });
        return false;
    });
};


// starting the script on page load
$(document).ready(function() {
    imagePreview();
});