$(document).ready(function() {



  $('#search_go').html("Search");
  
  if(!$('#side-nav').length > 0){
    //the navigation is not present, raise the topmost widget
    $('#sidebar .widget:eq(0)').css("margin-top", "0");
  }
  

  $('<div id="traildiv"></div>').appendTo('body');

  /* Side navigation */
  $('#side-nav li ul').hide(); /*hide the third level of nav */
  $('#side-nav li.current').parent('ul').show(); /* show the third level if active */
  $('#side-nav li.current ul').show(); /* show the third level for active second level items */
  $('#side-nav li:has(ul)').addClass('more'); /*add a class to second level nav to indicate that there is a third*/
  $('#side-nav > li.more').hoverIntent(function(){ /*there's gotta be a more elegant way than the ifs, but don't show/hide an active third level */
    if(!($(this).find('.current').length || $(this).hasClass('current'))){
      $(this).find('ul').slideToggle();
    }
  },
  function(){
    if(!($(this).find('.current').length || $(this).hasClass('current'))){
      $(this).find('ul').slideToggle();
    }
  });
  

});


$(window).load(function(){
  var sidebarHeight = $('#sidebar').height();
  var contentHeight = $('#content').height();
  
  $('#content').css('min-height', sidebarHeight - 60); //60 - combined padding of content area
  $('#sidebar').css('min-height', contentHeight);
});

