if(!document.quickllook2){ quickllook2 = {} };

(function($) {

    var EVENT_CLASS = "quicklook2";

    $(document).ready(function() {
        init();
    });

    function init() {
        $("#toiletModule").after(
            '<div id="quickLookButton">' +
            '<div><img src="/common/images/quicklookbutton.png" width="70" height="18" border="0" /></div>' +
            '</div>'
        );
        $("div#quickLookButton").css("display", "none");

        $("div#quickLookButton").unbind("mouseout").unbind("mouseover").hover(
            function() {},
            function() {
                $("div#quickLookButton").css({
                    display:"none"
                });
            }
        );

        var addProdImageEvent = function() {

            $("div#quickLookButton").css({
                display:"none"
            });

            $("img.qlProdImg").mouseover(function() {
                var offset = $(this).offset();
                var mainOffset = $("#toiletModule").offset();
                var x = (offset.left - mainOffset.left + 9);
                var y = (offset.top - mainOffset.top + 19);
                var w = $(this).width();
                var h = $(this).height();
                $("div#quickLookButton").css({
                    top: y + "px",
                    left: x + "px",
                    width: w + "px",
                    height: h + "px",
                    display:"",
                    "z-index":9
                });

                var prodId = $(this).attr("prodId");
                var rowId = $(this).attr("row");
                var imgElem = this;
                $("div#quickLookButton img").unbind("click." + EVENT_CLASS).bind("click." + EVENT_CLASS, function(e) {
                    $("div#quickLookButton").css({display:"none"});
                    open(prodId, rowId);
                    e.stopPropagation();
                });

                $("div#quickLookButton").unbind("click." + EVENT_CLASS).bind("click." + EVENT_CLASS, function() {
                    window.location.href = $(imgElem).parent().attr("href");
                });
            });

        }
        $.extend(quickllook2,{addProdImageEvent:addProdImageEvent});

    }


    function open(prodId, row) {
        populateQuickLookDetails(prodId, row);
    }


    window.quicklook = {
        open:open
    };

})(jQuery);


