$(document).ready(function () {

    // set the active horse state if a nav item is active

    var navBgPos = "0px 0px";

    if ($(".nav #words").hasClass("active")) {
        $(".nav").css("backgroundPosition", "0px -84px");
        navBgPos = "0px -84px";
    }

    if ($(".nav #pictures").hasClass("active")) {
        $(".nav").css("backgroundPosition", "0px -252px");
        navBgPos = "0px -252px";
    }

    if ($(".nav #coad").hasClass("active")) {
        $(".nav").css("backgroundPosition", "0px -420px");
        navBgPos = "0px -420px";
    }

    // hover interaction swaps out the horse states

    $(".nav #words").hover(
	  function () {
	      $(".nav").css("backgroundPosition", "0px -168px");
	  },
	  function () {
	      if ($(this).hasClass("active")) {
	          $(".nav").css("backgroundPosition", "0px -84px");
	      } else {
	          $(".nav").css("backgroundPosition", navBgPos);
	      }
	  }
	);

    $(".nav #pictures").hover(
	  function () {
	      $(".nav").css("backgroundPosition", "0px -336px");
	  },
	  function () {
	      if ($(this).hasClass("active")) {
	          $(".nav").css("backgroundPosition", "0px -252px");
	      } else {
	          $(".nav").css("backgroundPosition", navBgPos);
	      }
	  }
	);

    $(".nav #coad").hover(
	  function () {
	      $(".nav").css("backgroundPosition", "0px -504px");
	  },
	  function () {
	      if ($(this).hasClass("active")) {
	          $(".nav").css("backgroundPosition", "0px -420px");
	      } else {
	          $(".nav").css("backgroundPosition", navBgPos);
	      }
	  }
	);

	  var notesContent = $("#notes_container").html();

      var re1='(\\S+)';	//check for non whitespace.

      var p = new RegExp(re1,["i"]);
      var m = p.exec(notesContent);
      if (notesContent == null || m == null)
      {
          $("#notes_wrap").hide();
      }

});
