/*

		rolloverImage.js
		
		Mootools-based class to provide rollover image functionality
		
		Written by:		Ken Kolodziej
		Created on:		October 16, 2007

		USAGE:			Instantiate a new RolloverImage and pass the id of the image to be swapped,
						as well as the id of the trigger object, and finally the src of the rollover image
*/

var RolloverImage = new Class({
	options: {
		imgID:'',
		triggerObjID:'',
		rolloverImageSrc:''
	},
	initialize: function(options){
		this.setOptions(options);
		this.theImage = $(this.options.imgID);
		this.triggerObj = $(this.options.triggerObjID);
		this.oldSrc = '';
		
		if(!this.triggerObj) return;

		this.triggerObj.addEvent('mouseover', function(e){
			e = new Event(e);
			this.oldSrc = this.theImage.src;
			this.theImage.src = this.options.rolloverImageSrc;
			e.stop();
		}.bind(this));
		this.triggerObj.addEvent('mouseout', function(e){
			e = new Event(e);
			this.theImage.src = this.oldSrc;
			e.stop();
		}.bind(this));
	}
});
RolloverImage.implement(new Options, new Events);