////
//// support code for MIT IPC site
////

//
// required:
//   jquery.js (version 1.3.2+) (see jquery.com)
//   jquery.preloadImg.js
//

$(document).ready(function(){

  // function gets the on version of the specified image src
  //
  var getOnSrc = function(src) {
    return src.replace(/_off/, '_on');
  }
  //
  // navigation mouseovers and preloads
  //
  $("img[src*='_off'], input[src*='_off']")
    .each( function(i) {
      // set up two versions of image, and save both values in the image itself
      this.src1 = this.src;
      this.src2 = getOnSrc(this.src1);
      // preload mouseover version
      $.preloadImg.add(this.src2);
      // respond to mouseover/mouseout
      $(this).hover(
        function () { // mouseover function
          this.src = this.src2;
        },
        function () { // mouseout function
          this.src = this.src1;
        }
      );
    });
  // start preload
  $.preloadImg.start();


});
