jQuery(document).ready(function( $ ) {

	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		queue:true,
		offset: -77,
		duration:1500
	});
	

	$.localScroll({
		queue:true,
		duration:1000,
		hash:true,
		offset: -77,
		onBefore:function( e, anchor, $target ){
			// The 'this' is the settings object, can be modified
		},
		onAfter:function( anchor, settings ){
			// The 'this' contains the scrolled element (#content)
		}
	});


  $(".nav_list").slideToggle(400);



function hideDiv() { 
      $("#hideshow").fadeOut();	
}


  $("#list_popup_close").click(function () {
	hideDiv();
    });

  $("#fade").click(function () {
	hideDiv();
    });


 $("#categories").click(function () {
      $("#blog_categories_list").slideToggle(400);
    });
 $("#archive").click(function () {
      $("#blog_archive_list").slideToggle(400);
    });


 $("#this_category").click(function () {
 	 $(".nav_list").slideToggle(400);
    });


   function staticNav() {
        var sidenavHeight = $("#sidenav").height(); //Get height of sidenav
        var winHeight = $(window).height(); //Get height of viewport


        if (sidenavHeight + 77 > winHeight) { //If sidenav is taller than viewport...
            $("#sidenav").css({'position' : 'absolute'}); //switch the fixed positioning to static. Say good bye to sticky nav!
            $("#sidenav").css({'top' : '0'}); 
//            $("#sidenav_popup_space").css({'display' : 'none'});                        
        } else if (sidenavHeight + 77 < winHeight) { //If sidenav is shorter than viewport...
            $("#sidenav").css({'position' : 'fixed'}); //switch the static positioning to fixed. Say hello to sticky nav!
            $("#sidenav").css({'top' : '77px'});                        
//            $("#sidenav_popup_space").css({'display' : 'visible'});             
        }
    };



    $(window).resize(function () { //Each time the viewport is adjusted/resized, execute the function
        staticNav();
    });


	$(window).scroll(function(){
        staticNav();
    });
    
    
 $("#nav_contact").click(function () {
      $("#contact_popup_space").slideDown(400);
      $("#popup").slideDown(400);      
      $("#contact_popup_content").animate({ top:"8px" } , 400);     
      $("#list_popup_content").animate({ top:"-27px" } , 400);         
      $(".sidenav_popup_space").slideDown(400);

    }); 
 $(".contact_popup_close").click(function () {
      $("#contact_popup_space").slideUp(400);
      $("#popup").slideUp(400);      
      $("#contact_popup_content").animate({ top:"-25px" } , 400);   
      $("#list_popup_content").animate({ top:"-27px" } , 400);         
      $(".sidenav_popup_space").slideUp(400);
   
    }); 
 $("#nav_list").click(function () {
      $("#contact_popup_space").slideDown(400);
      $("#popup").slideDown(400);      
      $("#list_popup_content").animate({ top:"0" } , 400);  
      $("#contact_popup_content").animate({ top:"-25px" } , 400);          
      $(".sidenav_popup_space").slideDown(400);
      $("#mce-error-response").fadeOut(400);      
      $("#mce-success-response").fadeOut(400);            
      

    }); 
 $(".response").click(function () {
      $("#contact_popup_space").slideUp(400);
      $("#popup").slideUp(400);      
      $("#list_popup_content").animate({ top:"-27px" } , 400);         
      $(".sidenav_popup_space").slideUp(400);
    }); 



});