function mouseOver() {
   var backMenu = document.getElementById("back");
   var nextMenu = document.getElementById("next");
   var ltMenu = document.getElementById("lt");
   var gtMenu = document.getElementById("gt");
   var menuColor = "rgb(255,255,255)";
   var redColor = "rgb(255,0,0)";
   
   if (this.id === "back" || this.id === "lt") {
      backMenu.style.color = menuColor;
      ltMenu.style.color = redColor;
   } else if (this.id === "next" || this.id === "gt") {
      nextMenu.style.color = menuColor;
      gtMenu.style.color = redColor;
   }
}

function mouseOut() {
   var backMenu = document.getElementById("back");
   var nextMenu = document.getElementById("next");
   var ltMenu = document.getElementById("lt");
   var gtMenu = document.getElementById("gt");
   var linkColor = "rgb(64,64,64)";
   
   if (this.id === "back" || this.id === "lt") {
      backMenu.style.color = linkColor;
      ltMenu.style.color = linkColor;
   } else if (this.id === "next" || this.id === "gt") {
      nextMenu.style.color = linkColor;
      gtMenu.style.color = linkColor;
   }
}

function assignHandlers() {
   var backElem = document.getElementById("back");
   var nextElem = document.getElementById("next");
   var ltElem = document.getElementById("lt");
   var gtElem = document.getElementById("gt");
   
   backElem.onmouseover = mouseOver;
   nextElem.onmouseover = mouseOver;
   ltElem.onmouseover = mouseOver;
   gtElem.onmouseover = mouseOver;
   backElem.onmouseout = mouseOut;
   nextElem.onmouseout = mouseOut;
   ltElem.onmouseout = mouseOut;
   gtElem.onmouseout = mouseOut;  
}

window.onload = assignHandlers;
