Event.observe(window, 'load', function() {
	var rollImages = $$('.rollover');
	for (var i = 0; i < rollImages.length; i++) {
		new RollOver(rollImages[i]);
	}
});

var RollOver = Class.create();
RollOver.prototype = {
	initialize: function(element) {
		this.element = element;
		this.imgsrc = this.element.src;
		this.imgsrc_on = this.getOnSrc();
		this.createImageCache();
		Event.observe(this.element, 'mouseover', this.onMouseOver.bind(this));
		Event.observe(this.element, 'mouseout', this.onMouseOut.bind(this));
	},
	onMouseOver: function() {
		this.element.src = this.imgsrc_on;
	},
	onMouseOut: function() {
		this.element.src = this.imgsrc;
	},
	getOnSrc: function() {
		var srcFile = this.imgsrc.split('.');
		var srcLast = srcFile.pop();
		return srcFile.join('.') + '_on.' + srcLast;
	},
	createImageCache: function() {
		this.imgcache = new Image();
		this.imgcache.src = this.imgsrc_on;
	}
}