Smoth Scrolling Nav bar
===

I'm planning to have a nav bar that remains at a fixed position until the nav bar reaches the top of the browser window while scrolling.

I was able to achieve this with jquery but it isn't smooth

  

          $(window).scroll(function()
         {     var box = document.getElementById('box'), 
               scroll = $(window).scrollTop();     
               if (scroll <= 598) { $("#box").css("top",598); }  
              else { $("#box").css("top",scroll); }
       });


How can the motion be smooth [like here www.simonemaranzana.com/themeforest/wp/eruption/][1].

  [1]: http://simonemaranzana.com/themeforest/wp/eruption/