﻿/* include: social-control.ascx */

$(document).ready(function(){
  initSocialControl();
});

function initSocialControl()
{
  // hide section on load
  $("div.socialWrapper").addClass("socialWrapperAdv");
  $("div.socialWrapper div.section:not('.keepOpen')").hide();
  $("div.socialWrapper ul.social li a").each(function(){
    if($("div." + $(this).attr("href").replace("#", "")).is(":visible")) { $(this).addClass("active"); }
  });
  
  // update nav
  $("div.socialWrapper ul.social").prepend("<li class=\"print\"><a href=\"#\">Print this page</a></p>");
  
  // show/hide section based on nav click
  $("div.socialWrapper ul.social li a").unbind("click").live("click", function(){
    if($(this).parent().hasClass("print"))
    {
      window.print();
    }
    else
    {
      $("div.socialWrapper ul.social li a.active").removeClass("active");
      $(this).addClass("active");
      $("div.socialWrapper div.section").hide();
      $("div.socialWrapper div." + $(this).attr("href").replace("#", "")).show();
    }
    return false;
  });
} // initSocialControl()
