var RollOver = Class.create({
  initialize: function(el, options)
  {
    this.__setOptions(options);
    this.__element = $(el);

    if (this.__element)
    {
      this.__element.addClassName(this.__options.activeClassName);
      this.__addEvents();
    }
  },
  __setOptions : function(options)
  {
    this.__options = Object.extend({
      activeClassName : 'rollover',
      basePath        : ''
    }, options || {});

    if (!this.__options.basePath.empty())
    {
      var opt = this.__options;
      opt.mouseover = opt.basePath + opt.mouseover;
      opt.mouseout  = opt.basePath + opt.mouseout;
    }
  },
  __addEvents : function()
  {
    if (this.__element)
    {
      this.__element.observe('mouseover', function() {
        this.__element.src = this.__options.mouseover;
      }.bind(this));

      this.__element.observe('mouseout', function() {
        this.__element.src = this.__options.mouseout;
      }.bind(this));
    }
  }
});
