Team:TP CC-SanDiego/content-sidebar-JS

$(window).scroll(function(){

 var winheight = $(window).height() - 416;
 var mn = $("#nav-wrapper");
 var mn2 = $("#nav");
 var nextdiv = $("#content-wrapper");
 if($(window).scrollTop() > winheight){
   mn.addClass("fixed");
   mn2.addClass("marginRight")
   nextdiv.css("padding-top", "50px");
 } 
 else{
   mn.removeClass("fixed");
   mn2.removeClass("marginRight")
   nextdiv.css("padding-top", "0px");
 }

});

$(window).scroll(function(){

 var sbheight = $(window).height() - 416;
 var sb = $("#sidebar")
 // var nextdiv = $("#content-wrapper");
 if($(window).scrollTop() > sbheight){
   sb.addClass("sb-fixed");
   //nextdiv.css("padding-top", "50px");
 } 
 else{
   sb.removeClass("sb-fixed")
   //nextdiv.css("padding-top", "0px");
 }

});

// Smooth scroll; NOT WORKING $(function() { $('a[href*=#]:not([href=#])').click(function() {

   if (location.pathname.replace(/^\//,) == this.pathname.replace(/^\//,) && location.hostname == this.hostname) {
     var target = $(this.hash);
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
     if (target.length) {
       $('html,body').animate({
         scrollTop: target.offset().top
       }, 1000);
       return false;
     }
   }
 });

});