var imgs = new Object();

for(var i=0; i<2; i++) {
	var temp = i ? (document.getElementsByTagName ? document.getElementsByTagName('input') : (document.all ? document.all.tags('input') : [])) : document.images;

	for(var j=0; temp[j]; j++) {
		var thisimg = temp[j];

		if(thisimg.getAttribute) {
			thisimg.srchover = thisimg.getAttribute('srchover'); thisimg.srcclick = thisimg.getAttribute('srcclick');
		}

		if(thisimg.srchover || thisimg.srcclick) {
			if(!imgs[thisimg.src]) {
				imgs[thisimg.src] = new Image(); imgs[thisimg.src].src = thisimg.src;
			}

			thisimg.srcroot = thisimg.src;
			thisimg.onmouseout = function() { this.src = this.srcroot; };
		}

		if(thisimg.srchover) {
			if(!imgs[thisimg.srchover]) {
				imgs[thisimg.srchover] = new Image(); imgs[thisimg.srchover].src = thisimg.srchover;
			}

			thisimg.onmouseover = function() { this.src = this.srchover; };
		}

		if(thisimg.srcclick) {
			if(!imgs[thisimg.srcclick]) {
				imgs[thisimg.srcclick] = new Image(); imgs[thisimg.srcclick].src = thisimg.srcclick;
			}

			thisimg.onmousedown = function(e) {
				e = e ? e : window.event;
				if(e.button > 1 || e.which > 1) { return; }

				this.src = this.srcclick;
			};

			thisimg.onmouseup = function(e) {
				e = e ? e : window.event;
				if(e.button > 1 || e.which > 1) { return; }

				this.src = this.srchover ? this.srchover : this.srcroot;
			};
		}
	}
}

