﻿$(document).ready(function () {
    $("#lbPreload1").onImagesLoaded(function (_this) { });
    $("#lbPreload2").onImagesLoaded(function (_this) { });
    $("#lbPreload3").onImagesLoaded(function (_this) { });
    $("#lbPreload4").onImagesLoaded(function (_this) { });
    $(".hpZoomFotoEfekt").imgToolTip();
});
jQuery.fn.onImagesLoaded = function (_cb) {
    return this.each(function () {
        var $imgs = (this.tagName.toLowerCase() === 'img') ? $(this) : $('img', this),
            _cont = this,
            i = 0,
            _done = function () {
                if (typeof _cb === 'function') _cb(_cont);
            };
        if ($imgs.length) {
            $imgs.each(function () {
                var _img = this,
                    _checki = function (e) {
                        if ((_img.complete) || (_img.readyState == 'complete' && e.type == 'readystatechange')) {
                            if (++i === $imgs.length) _done();
                        }
                        else if (_img.readyState === undefined) {
                            $(_img).attr('src', $(_img).attr('src'));
                        }
                    };
                $(_img).bind('load readystatechange', function (e) { _checki(e); });
                _checki({ type: 'readystatechange' });
            });
        } else _done();
    });
};
