window.onload = scriptsInit;

function scriptsInit() {
  for (var i=0; i<document.links.length; i++) {
    var linkObj =  document.links[i];
    
    if (linkObj.id) {
        var imgObj = document.getElementById(linkObj.id + "-img");
        if (imgObj) {
          setupRollover(linkObj,imgObj);
        }
      }
    }
  }



function setupRollover(thisLink,thisImage) {
  thisLink.imgToChange = thisImage;
  thisLink.onmouseout = rollOut;
  thisLink.onmouseover = rollOver;  
  
  thisLink.outImage = new Image();
  thisLink.outImage.src = "buttons/" + thisLink.id + ".gif";

  thisLink.overImage = new Image();
  thisLink.overImage.src = "buttons/" + thisLink.id + "-over.gif";

}

function rollOut() {
  this.imgToChange.src = this.outImage.src;
}

function rollOver() {
  this.imgToChange.src = this.overImage.src;
}

