window.onload = function () {
  var nav = document.getElementById("nav");
  for (var i = 0; i < nav.children.length; i++) {
    nav.children[i].firstChild.onmouseover = function() {
      this.src = this.src.replace("dark", "light");
    }
    nav.children[i].firstChild.onmouseout = function() {
      this.src = this.src.replace("light", "dark");
    }
  }
}

