//  Author: Christopher W. Baran
//
//  Written: December 10, 2008
//
//  Global Mouse Over Script
//  Based on jQuery


$(document).ready(function() {

  // *************** Button Mouse Over Swapping *******************
  // Any img tags on the page with src names that contain _off.
  //  will mouse over to the same base name _ovr.
  $('[src*="_off."]').each(function() {
    // Preload Images
    jQuery("<img>").attr("src", $(this).attr('src').replace( /(.*?)_off(\..*)/, '$1_ovr$2' ) );

    $(this).hover(function () {
      $(this).attr('src', $(this).attr('src').replace( /(.*?)_off(\..*)/, '$1_ovr$2' ) );
    },
    function () {
      $(this).attr('src', $(this).attr('src').replace( /(.*?)_ovr(\..*)/, '$1_off$2' ) );
    });
		
	  if ( $(this).parents(".nav").length == 1 ) {
	    parents = $(this).parents("a");
	    
	    if (parents.length == 1) {
	      this_link = parents.get(0);
				
			  if (this_link.pathname.search(/^\//) < 0) {
          this_link_location = '/' + this_link.pathname;
        } else {
					this_link_location = this_link.pathname;
				}
	      
	      if (this_link_location == document.location.pathname) {
	        $(this).attr('src', $(this).attr('src').replace(/(.*?)_off(\..*)/, '$1_loc$2'));
	      }
	    }
	  }
  });
	

});
