////
//// support code for Harvard Office for the Arts site
////

//
// required:
//   jquery.js (version 1.3.2+) (see jquery.com)
//   jquery.ifixpng.js
//

//
// include the styles needed when javascript is active
//
document.writeln('<link rel="stylesheet" href="/ofa/styles/ofa_dynamic.css" type="text/css" media="all" />');


$(document).ready(function(){

  ////
  //// fix png images for IE6
  ////
  $.ifixpng('/ofa/img/spacer.gif');
  $('img[src$=.png]').ifixpng();

  ////
  //// clear search on initial activation
  ////
  $('#q').focus( function() {
    if (!this.searchstarted) {
      this.value = "";
      this.searchstarted = true;
    }
  });

  ////
  //// preload nav backgrounds
  ////
  $("#divprimarynav > ul > li").each( function() {
    var bkgimg = $(this).css("background-image"); // in form "url(xxx)"
    var regexp = /url\((.*)\)/;
    var result = regexp.exec(bkgimg); // extract xxx, which is the image url
    if (result[1]) {
      bkgimg = result[1];
      bkgimg = bkgimg.replace(/_off/, "_on");
      $.preloadImg.add(bkgimg);
    }
  });
  // start preload
  $.preloadImg.start();


  ////
  //// activate tabs
  ////
  $('div.divtabs').tabs({selected: 0});

});
