// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
jQuery(document).ready(function(){
  
  
  //***************************** PAGE NAVIGATION **************************************
  
  // highlight the current page tab (it has a class that matches the body id)
  var body_id = '.' + $("body").attr('id');
  $(body_id).addClass('current');
    
  // drop down subnavigation when hovering over primary navigation
  // same effect is achieved with css on everything but some versions of IE
  $("#nav>ul>li").hover(
    function(){
      $(this).children(".subnav").css('display', 'block'); // mouseover
    },
    function(){
      $(this).children(".subnav").css('display', 'none');  // mouseout
    }
  );
  
  // make currently clicked on tab .current
  $("#nav>ul>li>a").click(function(){
    $(this).parent().siblings().attr('class', '');
    $(this).parent().attr('class', 'current');
  });
  
  // when a subnav of the current page is clicked on
  // force a page reload
  $(".current ul.subnav li a.internal").click(function(){
    window.location.assign($(this).attr('href'));
    //if($(this).parent().className == 'current') {
    window.location.reload(true);
    //}
  });
  
});
