text: // Scrolls to the selected menu item on the page
  $(document).on('click','.navbar-collapse.in',function(e) {
      if( $(e.target).is('a:not(".dropdown-toggle")') ) {
          $(this).collapse('hide');
      }
  });
  
  $('a[href^="#"]').on('click', function(event) {
      var target = $(this.getAttribute('href'));
      if( target.length ) {
          event.preventDefault();
          $('#myNavbar ul li').each(function () {
              $(this).removeClass("active");
          });
          $(this).closest( "li" ).addClass('active'); 
          animate(target);
      }
  });
  
  function animate(targ) {
      $('html, body').stop().animate({
          scrollTop: targ.offset().top - 50
      }, 1000);
  }
  
  
  //#to-top button appears after scrolling
  var fixed = false;
  $(document).scroll(function() {
      if ($(this).scrollTop() > 250) {
          if (!fixed) {
              fixed = true;
              // $('#to-top').css({position:'fixed', display:'block'});
              $('#to-top').show("slow", function() {
                  $('#to-top').css({
                      position: 'fixed',
                      display: 'block'
                  });
              });
          }
      } else {
          if (fixed) {
              fixed = false;
              $('#to-top').hide("slow", function() {
                  $('#to-top').css({
                      display: 'none'
                  });
              });
          }
      }
  });
  