function Rollovers_swap(id){ // id to swap in an image, null to swap out if (id != null) { var image = document.images[id] if (image == null) return var newimage = this.images[id] if (newimage == null) return this.temp_img = image this.temp_src = image.src image.src = newimage.src } else { if ((this.temp_img != null) && (this.temp_src != null)) this.temp_img.src = this.temp_src this.temp_img = null this.temp_src = null } } function Rollovers(image_list){ this.images = new Object() // Storage for swap-in images this.Install = Rollovers_Install this.swap = Rollovers_swap // Storage for the current swap-out image this.temp_img = null this.temp_src = null for (var i=0; i < image_list.length; i++) { var id = image_list[i][0] var src = image_list[i][1] var image = new Image() image.src = src this.images[id] = image } } function Rollovers_Install() { // Should be called after page is loaded var _this = this var swap_out = function(){_this.swap(null);} var set = function (id){ var image = document.images[id] if (image == null) return image.onmouseover = function(){_this.swap(id);} image.onmouseout = swap_out } for(var id in this.images) set(id); }