var Imagin = new function() {
    this.src = new Array();
    this.images = new Object();
    
    this.preload = function() {
        if (arguments.length > 0) {
            for (var i = 0; i < arguments.length; i++) {
                var src = arguments[i];
                this.src.push(src);
            }
        }
    }
    
    this.upload = function() {
        if (this.src.length > 0) {
            for (var i = 0; i < this.src.length; i++) {
                var src = this.src[i];
                if (this.images[src] == null) {
                    this.images[src] = new Image();
                    this.images[src].src = src;
                }
            }
        }
    }
    
    this.replace = function(elem, new_src) {
        if (elem.tagName == 'IMG') {
            var old_src = elem.src;
            elem.src = new_src;
            elem.onmouseout = function() {
                elem.src = old_src;
            }
        }
    }
    
    return this;
}();
$(document).ready(function(){
    Imagin.upload();
});
