// 預設值
_lazy_win = $jQuery(window),
_lazy_t   = _lazy_win.scrollTop(),
_lazy_b   = _lazy_t + _lazy_win.height();

function lazyload()
{
    // 重置圖片
    $jQuery(_lazy_obj).each(function() {
        _this = $jQuery(this);
     
        /* 取得對應位置 */
        _img_t = _this.offset().top,
        _img_b = _img_t + _this.height();
        if (_lazy_t > _img_b || _lazy_b < _img_t)
        {
            _this.attr('lazyori', _this.attr('src')).attr('src', _lazy_def).attr('top', _img_t).attr('bottom', _img_b);
        }
    });

    // 視窗移動處理效果
    _lazy_win.bind('scroll resize', function() {
        /* 重新計算位置 */
        _lazy_t = _lazy_win.scrollTop(),
        _lazy_b = _lazy_t + _lazy_win.height();
     
        /* 顯示圖片 */
        $jQuery('img[lazyori]').each(function() {
            _this = $jQuery(this);
        
            /* 取得對應位置 */
            if (_this.attr('top') >= _lazy_t && _this.attr('top') <= _lazy_b)
            {
                _this.hide().attr('src', _this.attr('lazyori')).removeAttr('lazyori')[_lazy_effect](_lazy_speed);
            }
        });
    });
}
