function lazyLoad(){
    if(/chrome|safari/i.test(navigator.userAgent)){return {}}
    this.index.apply(this,arguments)    
}
lazyLoad.prototype={
    index:function (){
        var images = document.images, list=[], sys=this;
        var dr=this.getRect();
        for (var i =  images.length; i--;) {
            var o = images[i], or=this.getRect(o);
            if (o.complete || or.top<dr.bottom ||this.isIntersect(dr, or)) {continue}
            o.setAttribute('rel',o.src);
            o.removeAttribute('src');
            list.push(o)
        }
        this.list=list;
        if (list.length>0) {
            this.on(window,'scroll',function (){
                if(list.length==0){return}
                clearTimeout(sys.lazyTimer);
                sys.lazyTimer=setTimeout(function() {
                    sys.loadImg()
                },200)
            })
        }
    },
    get:function (el){
        return typeof el=="string" ? document.getElementById(el) : el;
    },
    on: function(el, type, fn) {
        el.attachEvent ? el.attachEvent('on' + type,function() {
            fn.call(el, event)
        }) : el.addEventListener(type, fn, false);
    },
    loadImg:function (){
        var list=this.list, noload=[], dr=this.getRect();
        for (var i =  list.length; i--;) {
            var o=list[i];
            if (this.isIntersect(dr, this.getRect(o))) {
                o.src=o.getAttribute('rel');
                continue;
            }
            noload.push(o)
        }
        this.list=noload
    },
    isIntersect:function (r1, r2){
         return !(r1.right<r2.left||r1.top>r2.bottom||r1.left>r2.right||r1.bottom<r2.top)
    },
    getRect:function (el){
        if (el) {
            var el=this.get(el), t=el, x=0, y=0;
            do{
                x+=t.offsetLeft;
                y+=t.offsetTop                
            }while(t=t.offsetParent)
            return {left:x, top:y, right:x+el.offsetWidth,bottom:y+el.offsetHeight}
        }else{
            var d = document, dd = d.documentElement, db = d.body, M = Math.max;    
            var doc = d.compatMode == "CSS1Compat" ? dd: db;
            var x=M(dd.scrollLeft, db.scrollLeft),y=M(dd.scrollTop, db.scrollTop);
            return {left:x,top:y,right:x+doc.clientWidth,bottom:y+doc.clientHeight}
        }
    }
};
