// adds proper selection to navigation elements.  relies on common classes between navigation elements and the body tag.
$(function() {
    $("#nav li").each(
      function() {
          if ($(this).hasClass($("body").attr("class"))) {
              $(this).addClass("current")
          }
      }
  )

    // left nav tooltips
    $("#nav li.inactive span").tooltip({
        tip: '.tip',
        position: "bottom right",
        offset: [-7, -30],
        effect: 'fade'
    });

    //contact link tooltips
    $("#nav li.contact span").tooltip({
        tip: '.tip2',
        position: "bottom left",
        offset: [0, 75],
        effect: 'fade'
    });


    // overlay activation

    $(".launch-video[rel]").overlay({ effect: 'apple' });


    // home page rotating content tabs

    if (ie == 0) { // all browsers except IE can handle the fade
        $("ul.tabs").tabs("div.panes > div", {
            effect: 'fade',
            fadeInSpeed: 800,
            fadeOutSpeed: 0,
            rotate: true
        }).slideshow({ autoplay: true, interval: 5000 });
    } else { // IE specific code - no fade effect
        $("ul.tabs").tabs("div.panes > div", {
            effect: 'default',
            rotate: true
        }).slideshow({ autoplay: true, interval: 5000 });
    }
    $("ul.tabs li").click(function() {
        $('ul.tabs').data('slideshow').stop();
    });

    $("#headerwrap, a.logo").click(function() {
        if (location.href.indexOf('watershed-portal.aspx') != -1) {
            $(this).attr('href', '#');
            if (window.opener && !window.opener.closed) {
                window.opener.location.href = '/';
            } else {
                window.open("/");
            }

            self.close();
        }
    });
});

