$(document).ready(function(){

  //pullquote
  var para_count = $("div#mainPage p").size();
  if (para_count > 4)
  {
    $('#pullQuote').insertBefore('div#mainPage p:eq('+(3)+')');
  }

  //hide all children of any parents
  $('#sideNav li.parent a').each(function()
  {
    var o = $(this);
    o.parent('li').next('li').hide();
    //return false;
  });

  //always show everything up from selected
  $('#selected-sideNav').parents('li').show();

  //if item has children, show them too
  $('#selected-sideNav').next('li').show();

  //remove the
  $('#nav-tree li:last a').css({'border' : '0px'});

  $('#nav-tree li').children('ul').children('li:last-child').css({'border-bottom' : '1px solid #d7d7d5', 'padding-bottom' : '5px'});

  //add a click to parents to toggle children
  $('#sideNav img.sideNavArrow').click(function() {

    var o = $(this);

    //change the classes
    o.parent('li').toggleClass('open');
    o.parent('li').toggleClass('closed');

    //change the image
    if(o.parent('li').hasClass('open')){o.attr("src","/images/frontend/sub_nav_arrow_down.gif");}
    else{o.attr("src","/images/frontend/sub_nav_arrow.gif");};

    //hide the children
    o.parent('li').next('li').toggle();
    return false;
  });
});
