function getMouseOverImgsrc(imgElem, on) {
    if (on && (imgElem.src.indexOf('_on') != -1 || imgElem.src.indexOf('_in') != -1)) return;
    var path = imgElem.src.substring(0, imgElem.src.length - 4);
    if (on) {
        return path + '_on.gif';
    }
    return path.substring(0, path.length - 3) + '.gif';
}

function preload(imgElem) {
    var s = getMouseOverImgsrc(imgElem, true);
    if (s) {
      (new Image()).src = s;
      imgElem.onload = null;
    }
}

function rollover(imgElem, on) {
    if (on && (imgElem.src.indexOf('_on') != -1 || imgElem.src.indexOf('_in') != -1)) return;
    if (!on && !imgElem.name) return;
    
    imgElem.src = getMouseOverImgsrc(imgElem, on);
    imgElem.name = on;
}
