function buttonOver() {
    if (objExists('wrapper')) {
        thewrap = document.getElementById('wrapper');
        buttons = thewrap.getElementsByTagName('input');
        for (i = 0; i < buttons.length; i++) {
            if(buttons[i].getAttribute('type') == 'image') {
                buttons[i].onmouseover = function() {
                    this.src = this.src.substring(0, this.src.length - 4) + "2.jpg";
                }
                buttons[i].onmouseout = function() {
                    if (this.src.substring( (this.src.length - 5) , (this.src.length) ) == "2.jpg" ) {
                        this.src = this.src.substring(0, this.src.length - 5) + ".jpg";
                    }
                }
            }
        }
    }
}

function imageOver() {
    if (objExists('wrapper')) {
        thewrap = document.getElementById('wrapper');
        images = thewrap.getElementsByTagName('img');
        for (i = 0; i < images.length; i++) {
            if(images[i].className.substring(0, 5) == "hover") {
                images[i].onmouseover = function() {
                    this.src = this.src.substring(0, this.src.length - 4) + "2.jpg";
                }
                images[i].onmouseout = function() {
                    if (this.src.substring( (this.src.length - 5) , (this.src.length) ) == "2.jpg" ) {
                        this.src = this.src.substring(0, this.src.length - 5) + ".jpg";
                    }
                }
            }
        }
    }
}

function objExists(theVal) {
    if (document.getElementById(theVal) != null) {
        return true;
    } else {
        return false;
    }
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func();
        }
    }
}


addLoadEvent(buttonOver);
addLoadEvent(imageOver);