// UIR (Unobtrusive Image Rollover) v2.00.050805
if (document.getElementById) {
   function initUIR() {
      actImgTag = "_on";
      selImgTag = "_sel";
      clsRoll = "roll";
   
      imgList = '';
      var images = document.getElementsByTagName('img');
   
      for (var i=0; i<images.length; i++) {
         if (eval('/' + clsRoll + '/').test(images[i].className)) {
            imgList += images[i].src + ",";
            setEvents(images[i]);
         }
      }
      
      imgList = imgList.substring(0, imgList.length-1);
      preload(imgList.split(","));
   }
   
   function setEvents(element) {
      element.parentNode.onmouseover = function() { roll(this); }
      element.parentNode.onmouseout = function() { roll(this); }
      element.parentNode.onfocus = function() { roll(this); }
      element.parentNode.onblur = function() { roll(this); }
   }
   
   function preload(imgList) {
      activeImages = new Array(imgList.length);
      inactiveImages = new Array(imgList.length);
      
      for (var i=0; i<imgList.length; i++) {
         activeImages[i] = new Image();
         activeImages[i].src = getBaseName(imgList[i]) + actImgTag + getExt(imgList[i]);
         inactiveImages[i] = new Image();
         inactiveImages[i].src = getBaseName(imgList[i]) + getExt(imgList[i]);
      }
   }
   
   function getBaseName(filename) {
      if (eval('/'+actImgTag+'\./').test(filename)) filename = filename.replace(actImgTag+'.', '.');
      if (eval('/'+selImgTag+'\./').test(filename)) filename = filename.replace(selImgTag+'.', '.');
      return filename.substring(0, filename.lastIndexOf('.'));
   }
   
   function getExt(filename) {
      return filename.substring(filename.lastIndexOf('.'), filename.length);
   }
   
   function getImage(imageName, isActive) {
      (isActive==0) ? images = inactiveImages : images = activeImages;
      for (var i=0; i<images.length; i++) {
         if (getBaseName(imageName) == getBaseName(images[i].src)) {
            return images[i];
            break;
         }
      }
   }
   
   function roll(element) {
      var src, newSrc;
      var node, currNode;
      
      for (var i=0; i<element.childNodes.length; i++) {
         currNode = element.childNodes[i];
         if (currNode.nodeType==1 && /img/i.test(currNode.nodeName)) {
            node = i;
            break;
         }
      }
      src = element.childNodes[node].src;
      if (!(eval('/'+selImgTag+'\./').test(src))) {
         newSrc = getImage(src,!(eval('/'+actImgTag+'\./').test(src))).src;
      }
      if (!(typeof(newSrc)=='undefined')) element.childNodes[node].src = newSrc;
   }
   
   window.onload = function() { initUIR(); }
} // (C) 2005 Emanuele Rodriguez @ TangentDigital (http://www.tangent.es)
