if (typeof Kokel == "undefined" || !Kokel) {
    var Kokel = new function () {
        this.ZoomImagesOnHover = function (imgs, closestRowSelector, scaleFactor) {
            $(imgs).each(function () {
                var img = $(this);
                var width = img.width();
                var height = img.height();
                var container = img.closest(closestRowSelector);
                var pos = img.position();
                container.hover(function() {
                    $(this).css({'z-index' : '10'});
                    var zoomTimeMs = 200;
                    var marginTop = '-' + (height * scaleFactor / 2 - pos.top) + 'px';
                    var marginLeft = '-' + (width * scaleFactor / 2 - pos.left) + 'px';
                    img.stop().animate({
                        marginTop: marginTop,
                        marginLeft: marginLeft,
                        top: '50%',
                        left: '50%',
                        width: (width * scaleFactor) + 'px',
                        height: (height * scaleFactor) + 'px'
                    }, zoomTimeMs);
                }, function () {
                    $(this).css({'z-index' : '0'});
                    var dezoomTimeMs = 400;
                    img.stop().animate({
                        marginTop: '0',
                        marginLeft: '0',
                        top: pos.top + 'px',
                        left: pos.left + 'px',
                        width: width + 'px',
                        height: height + 'px',
                    }, dezoomTimeMs);
                });
            });
        };
    };
}

