﻿function InitMouseovers() {
  var ptrImgs = document.getElementsByTagName("img");
  for (i = 0; i < ptrImgs.length; i++) {
    if (ptrImgs[i].className == "swapable") {
      ptrImgs[i].onmouseover = function() {
        MouseOver(this.id);
      }
      ptrImgs[i].onmouseout = function () {
       MouseOut(this.id);
      }
    }
  }
}

function MouseOver(strId) {
  var ptrImg = document.getElementById(strId);
  var strSrc = ptrImg.src;
  var intIndex = strSrc.lastIndexOf(strId);
  var strNew = strSrc.slice(0,intIndex) + strId + "_over.gif";
  ptrImg.setAttribute("src", strNew);
}

function MouseOut(strId) {
  var ptrImg = document.getElementById(strId);
  var strSrc = ptrImg.src;
  var intIndex = strSrc.lastIndexOf(strId);
  var strNew = strSrc.slice(0,intIndex) + strId + "_link.gif";
  ptrImg.setAttribute("src", strNew);
}

function InitContact() {
  var ptrLink = document.getElementById("contact");
  var strFirst = "mai";
  var strSecond = "lto";
  var strThird = ":jon";
  var strFourth = "@";
  var strFifth = "apeiros";
  var strSixth = ".";
  var strSeventh = "com";
  var strHref = strFirst + strSecond + strThird + strFourth + strFifth + strSixth + strSeventh;
  ptrLink.href=strHref;
}

function InitPage() {
  InitMouseovers();
  InitContact();
}

window.onload = InitPage;