$(function(){
    ul = $('#leftnav > ul');
    ul.css('position', 'relative').css('top', '0px');
    mwidth = ul.css('width');
    mtop = ul.position().top - 10;
    win = $(window);
    fixed = false;
    win.scroll(function(){
        st = win.scrollTop();
        if (st > mtop ){
            if (!fixed){
                ul.css('width', mwidth);
                ul.css('position', 'fixed').css('top', '10px');
                fixed = true;
            }
        } else {
            if(fixed){
                ul.css('position', 'relative').css('top', '0px');
                fixed = false;
            }
        }
    });
    win.trigger('scroll');
});
