function isDefined(property) {
  return (typeof property != 'undefined');
}

//Image.prototype.offImage = 'none';
//Image.prototype.onImage = 'none';
var rolloverInitialized = false;
function rolloverInit() {
  if (!rolloverInitialized && isDefined(document.images)) {
     // get all images (including all <input type="image">s)
     // use getElementsByTagName() if supported
     var images = new Array();
     if (isDefined(document.getElementById) && isDefined(document.getElementsByTagName)) {
        //menu = document.getElementById('menu');
        //images = menu.getElementsByTagName('img');
        images = document.getElementsByTagName('img');
       }

     for (var i = 0; i < images.length; i++) {
      var image = images[i];
      if (image.src.indexOf("/menu/menu") == -1 || image.src.indexOf("_active") != -1) {
        continue;
      }
      // store the off state filename in a property of the image object
      image.offImage = new Image();
      image.offImage.src = image.src;

      // store the on state filename in a property of the image object
      // (also preloads the on state image)
      image.onImage = new Image();
      image.onImage.imageElement = image;

      // add onmouseover and onmouseout event handlers once the on state image has loaded
      // Safari's onload is screwed up for off-screen images; temporary fix
      if (navigator.userAgent.toLowerCase().indexOf('safari') != - 1) {
         image.onmouseover = function() {
            this.src = this.onImage.src;
         };
         image.onmouseout = function() {
            this.src = this.offImage.src;
         };
      }
      else {
         image.onImage.onload = function() {
            this.imageElement.onmouseover = function() {
               this.src = this.onImage.src;
            };
            this.imageElement.onmouseout = function() {
               this.src = this.offImage.src;
            };
         };
      }

      // set src of on state image after defining onload event handler
      // so cached images (that load instantly in IE) will trigger onload
      image.onImage.src = image.src.replace(/\.png/, '_active.png');

    }
  }
  rolloverInitialized = true;
}

// call rolloverInit when document finishes loading
if (isDefined(window.addEventListener)) {
   window.addEventListener('load', rolloverInit, false);
}
else if (isDefined(window.attachEvent)) {
   window.attachEvent('onload', rolloverInit);
}

