$(function() {
  // Add the pointer cursor to any block level element with the mousepointer class
  $(".mousepointer").hover(
    function() { // Mouse Over
      $(this).css("cursor", "pointer");
    },
    function() { // Mouse Out
      $(this).css("cursor", "default");
    }
  );

  $("div.link").hover(
    function() { // Mouse Over
      $(this).css("background-image", "url('"+directoryLevel+"images/cobrand/bt_red_hover_bg.gif')");
    },
    function() { // Mouse Out
      $(this).css("background-image", "url('"+directoryLevel+"images/cobrand/bt_red_bg.gif')");
    }
  );

  // This is encapsulated functionality to handle the ARC search input box at the top
  // Using their own form methodology was just a pain so I took the link out of their form process and 
  // handle it here
  $("form[name='arcSearchForm']").submit(function() {
    var searchString = $("input[name='arcSearchField']").val();
    if( !searchString || searchString == undefined ) { // Don't do anything if there isn't a valid search string
      return false;
    }
    var searchUrl    = "http://www.redcrossblood.org/search/google/[search]?query=[search]&" +
                       "cx=005808443943617205923:_hfl2m-6--m&cof=FORID:9&sitesearch=";
    var searchFullUrl = searchUrl.replace(/\[search\]/g, searchString);
    $(this).attr("action", searchFullUrl);
  });

  // Handler for the magnifiying glass in the search box
  $("img[name='arcSearchImage']").click(function() {
    $(this).parents("form").submit();
  });

  // This will traverse through any link with a image under it and remove the bottom border from the a tag
  $("a").children("img").each(function() {
    $(this).parent("a").css("border", "0");
  });
});
