Preload={ 
    images:[], imagesId:{}, loadedCounter:0, id:0, complete:false, onIncrement:null, onComplete:null, 
    incrementImg : function() {
        this.loadedCounter++;
        this.length=this.images.length;
        this.percent=Math.round((this.loadedCounter/this.length)*100);
        if (this.onIncrement) this.onIncrement();
        if (this.loadedCounter==this.length) this.doComplete();
    },
    doComplete : function() {
        this.complete=true;
        if (this.onComplete) this.onComplete();
    },
    // PUBLIC
    setOnIncrement : function() { 
        var fnc=arguments[0]
        this.onIncrement=(typeof(fnc)=='function')?fnc:null 
    },
    setOnComplete : function(p_func) { 
        var fnc=arguments[0]
        this.onComplete=(typeof(fnc)=='function')?fnc:null 
    },
    getImgById : function() { return this.images[this.imagesId[arguments[0]]]||null },
    getImgByIndex : function() { return this.images[arguments[0]]||null },
    getImgBySrc : function() {
        var oImg=null, aImages=this.images, nL=aImages.length;
        for (var i=0; i<nL; i++) if (aImages[i].src==arguments[0]) oImg=aImages[i];
        return oImg;
    },
    addImg : function() { // ARGS: sId a[0], sSrc a[1]
        var a=arguments;
        var sId=(typeof(a[0])=='string')?a[0]:'pImg_'+(Preload.id++);
        var oImg=new Image(), aImages=this.images, nL=aImages.length;
        aImages[nL]=oImg;
        this.imagesId[sId]=nL;
        oImg.sId=sId;
        oImg.onload=function() {
            this.loaded=true;
            Preload.incrementImg();
        };
        oImg.sSrc=a[1];
    },
    start : function() {
        var oImg, aImages=this.images, nL=aImages.length;
        //alert(nL)
        for (var i=0; i<nL; i++) {
            oImg=aImages[i];
            oImg.src=oImg.sSrc;
        }
    }
};

swapImage=function() { // ARGS: sName a[0], sSrc a[1], sLayerId a[2]
    var a=arguments, sName=a[0], sSrc=a[1];
    var oDoc=(!is.ns4 || typeof(a[2])!='string')?document:getDiv(a[2]).document;
    oDoc.images[sName].src=sSrc;
};
