It's a lot simpler than you might think.
(1) $('#header_nav').data('size','small');
In regards to (1), the exact snippet of code you pasted is really just adding a data-attribute which I am guessing you don't need as you found the code online.
(2) $('#header_nav').stop().animate({
In regards to (2), .stop() just stops the animate abruptly without allowing it to finish
The key is to target the event of the mouse entering the div shown below:
$("#header_nav").mouseenter(function(){
and then again when it leaves to give you the mouseover effect shown below:
$("#header_nav").mouseleave(function(){
I've stripped the code to make it as simple as possible for you to read (DEMO below)
It's pretty self explanatory, on mouseenter/mouseleave 'animate' (gradually reduce/increase) the height of the container.