Fret, what about just adding a class? Keep the CSS, in the CSS
if ( ypos > max_scroll) {
$('#primary-navigation').addClass("sticky");
} else {
$('#primary-navigation').removeClass("sticky");
}
#primary-navigation {
/*default*/
}
#primary-navigation.sticky {
position:fixed;
bottom:0;
}
The jQuery probably isn’t right, but the concept is there.