//FADES!!!!!!!!!!!!
$(document).ready(function() {
	// find the div.fade elements and hook the hover event
	$('.moreButton, .softwoodsButton, .structuralhardwoodsButton, .specialityhardwoodsButton, .hardwoodsButton, .timbergradesButton, .downloadButton').hover(function() {
		// on hovering over find the element we want to fade *up*
		var fade = $('> .hover', this);

		// if the element is currently being animated (to fadeOut)...
		if (fade.is(':animated')) {
			// ...stop the current animation, and fade it to 1 from current position
			fade.stop().fadeTo(500, 1);
		} else {
			fade.fadeIn(500);
		}
	}, function () {
		var fade = $('> .hover', this);
		if (fade.is(':animated')) {
			fade.stop().fadeTo(300, 0);
		} else {
			fade.fadeOut(200);
		}
	});
	

	// get rid of the text
	$('.moreButton > .hover').empty();
	$('.softwoodsButton > .hover').empty();
	$('.structuralhardwoodsButton > .hover').empty();
	$('.specialityhardwoodsButton > .hover').empty();
	$('.hardwoodsButton > .hover').empty();
	$('.timbergradesButton > .hover').empty();
	$('.downloadButton > .hover').empty();
	


    function staticNav() {
        var sidenavHeight = $("#sidenav").height(); //Get height of sidenav
        var winHeight = $(window).height(); //Get height of viewport
        var browserIE6 = (navigator.userAgent.indexOf("MSIE 6")>=0) ? true : false; //Check for IE6

        if (browserIE6) { //if IE6...
            $("#sidenav").css({'position' : 'absolute'});  //reset the sidenav to be absolute
        } else { //if not IE6...
            $("#sidenav").css({'position' : 'fixed'}); //reset the sidenav to be fixed
        }

        if (sidenavHeight > winHeight) { //If sidenav is taller than viewport...
            $("#sidenav").css({'position' : 'static'}); //switch the fixed positioning to static. Say good bye to sticky nav!
        }
    }

    staticNav(); //Execute function on load

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



        $('a[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) {
 
              var targetOffset = $target.offset().top;
  
              $('html,body')

              .animate({scrollTop: targetOffset}, 1000);
 
             return false;

            }
 
          }
 
        });

      });



