﻿var RollOver = new Class({
    initialize: function(cls, ext) {
        this.cls = cls;
        this.ext = ext;
        this.update();
    },
    
    update: function() {
        var cls = this.cls;
        var ext = this.ext;
        $(document.body).getElements('img.' + cls).each(function(el) {
            if (el.src.indexOf(ext) != -1) {
                el.removeEvents('mouseenter');
                el.removeEvents('mouseleave');
                el.addEvents({
                    'mouseenter': function() {
                        if (this.src.indexOf('_ov') == -1 && !this.hasClass('active')) this.src = this.src.replace(ext, '_ov' + ext);
                    },
                    'mouseleave': function() {
                        this.src = this.src.replace('_ov' + ext, ext);
                    }
                });
            }
        });
    }
});