////
//// support code for Deb Roy site
////

//
// required:
//   jquery.js (version 1.2.6+) (see jquery.com)
//   jquery.ifixpng.js
//

$(document).ready(function(){

  //
  // fix png images for IE6
  //
  $.ifixpng('/~dkroy/img/spacer.gif');
  $('img[src$=.png]').ifixpng();


  //
  // replace current section's nav button with on version
  //
  $("body.research").find("#divprimarynav li.research img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.project").find("#divprimarynav li.research img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.teaching").find("#divprimarynav li.teaching img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.publications").find("#divprimarynav li.publications img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.media").find("#divprimarynav li.media img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.seminars").find("#divprimarynav li.seminars img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });
  $("body.bio").find("#divprimarynav li.bio img").each( function() {
      this.src = this.src.replace(/_off/, "_on");
    });


  //
  // navigation mouseovers and preloads
  //
  // function gets the mouseover version of the specified image src
  var getMouseoverSrc = function(src) {
    return src.replace(/_off|_on/, '_ro');
  }
  $("#divprimarynav li img")
    .each( function(i) {
      // set up two versions of image, and save both values in the image itself
      this.src1 = this.src;
      this.src2 = getMouseoverSrc(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();

  //
  // stripe seminar table
  //
  $("table.seminartable tr:even").addClass("even");

});
