/******************************************************************************/
/* Originally created by Christian Heilmann                                   */
/* http://www.onlinetools.org/articles/unobtrusivejavascript/                 */
/******************************************************************************/
function setRollOver() {
  var i,imgs;
  // loop through all images of the document
  imgs=document.getElementsByTagName('img');
  for(i=0;i<imgs.length;i++) {
    // test if the class 'roll' exists
    if(/roll/.test(imgs[i].className)) {
      // add the function roll to the image onmouseover and onmouseout and send
      // the image itself as an object
      imgs[i].parentNode.onmouseover=function() { doRollOver(this); };
      imgs[i].parentNode.onmouseout=function() { doRollOver(this); };
      imgs[i].parentNode.onfocus=function() { doRollOver(this); };
      imgs[i].parentNode.onblur=function() { doRollOver(this); };
    }
  }
}

function doRollOver(o) {
  var i,isnode,src,ftype,newsrc,nownode;
  // loop through all childNodes
  for (i=0;i<o.childNodes.length;i++) {
    nownode=o.childNodes[i];
    // if the node is an element and an IMG set the variable and exit the loop
    if(nownode.nodeType==1 && /img/i.test(nownode.nodeName)) {
      isnode=i;
      break;
    }
  }
  
  // check src and do the rollover
  src = o.childNodes[isnode].src;
  ftype = src.substring(src.lastIndexOf('.'), src.length);
  if(/_over/.test(src)) {
    newsrc = src.replace('_over','');
  } else {
    newsrc = src.replace(ftype, '_over'+ftype);
  }
  o.childNodes[isnode].src=newsrc;
}
/******************************************************************************/

window.onload = function() {
  setRollOver();
}