/**
 * Fluid Standard Scripts - Roll Overs
 * Copyright (c) Fluid Creativity, 2009
 *
 * Requires: MooTools Core v1.2.1
 */

Element.implement({
	applyRollOver: function() {
		if (this.src.test(/\.(gif|jpg|jpeg|png)$/i)) {
			// preload image
			var preload = new Image();
			preload.src = this.src.replace(/\.(gif|jpg|jpeg|png)/, '-over.$1');

			this.addEvents({
				mouseover: function() {
					this.src = this.src.replace(/\.(gif|jpg|jpeg|png)/, '-over.$1');
				},

				mouseout: function() {
					this.src = this.src.replace(/-over\.(gif|jpg|jpeg|png)/, '.$1');
				}
			});
		}

		return this;
	}
});

window.addEvent('domready', function() {
	$$('.rollOver').applyRollOver();
});
