        $(function() {
        
                function filterPath(string) {
                        return string
                        .replace(/^\//,'')
                        .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
                        .replace(/\/$/,'');
                }
        
                var locationPath = filterPath(location.pathname);
                var scrollElem = scrollableElement('html', 'body');
        
                // Any links with hash tags in them (can't do ^= because of fully qualified URL potential)
                $('a[href*=#]').each(function() {
        
                        // Ensure it's a same-page link
                        var thisPath = filterPath(this.pathname) || locationPath;
                        if (  locationPath == thisPath
                                && (location.hostname == this.hostname || !this.hostname)
                                && this.hash.replace(/#/,'') ) {
        
                                        // Ensure target exists
                                        var $target = $(this.hash), target = this.hash;
                                        if (target) {
        
                                                // Find location of target
                                                var targetOffset = $target.offset().top;
                                                $(this).click(function(event) {
        
                                                        // Prevent jump-down
                                                        event.preventDefault();
        
                                                        // Animate to target
                                                        $(scrollElem).animate({scrollTop: targetOffset}, 200, function() {
        
                                                                // Set hash in URL after animation successful
                                                                location.hash = target;
        
                                                        });
                                                });
                                        }
                        }
        
                });
        
                // Use the first element that is "scrollable"  (cross-browser fix?)
                function scrollableElement(els) {
                        for (var i = 0, argLength = arguments.length; i <argLength; i++) {
                                var el = arguments[i],
                                $scrollElement = $(el);
                                if ($scrollElement.scrollTop()> 0) {
                                        return el;
                                } else {
                                        $scrollElement.scrollTop(1);
                                        var isScrollable = $scrollElement.scrollTop()> 0;
                                        $scrollElement.scrollTop(0);
                                        if (isScrollable) {
                                                return el;
                                        }
                                }
                        }
                        return [];
                }
        
        });


$(document).ready(function() {
    
    //Calculate the height of <header>
    //Use outerHeight() instead of height() if have padding
    var aboveHeight = $('header').outerHeight();
    
    // when scroll
    $(window).scroll(function(){
        
        //if scrolled down more than the header's height
        if ($(window).scrollTop() > aboveHeight){
            
            // if yes, add "fixed" class to the <nav>
            // add padding top to the #content (value is same as the height of the nav)
            $('nav3').addClass('fixed').css('top','0').next().css('padding-top','0px');
        } else {
            
            // when scroll up or less than aboveHeight, remove the "fixed" class, and the padding-top
            $('nav3').removeClass('fixed').next().css('padding-top','0');
        }
    });
});


var menuSlider=function(){
    var m,e,g,s,q,i; e=[]; q=8; i=8;
    return{
        init:function(j,k){
            m=document.getElementById(j); e=m.getElementsByTagName('li');
            var i,l,w,p; i=0; l=e.length;
            for(i;i<l;i++){
                var c,v; c=e[i]; v=c.value; if(v==1){s=c; w=c.offsetWidth; p=c.offsetLeft}
                c.onmouseover=function(){menuSlider.mo(this)}; c.onmouseout=function(){menuSlider.mo(s)};
            }
            g=document.getElementById(k); g.style.width=w+'px'; g.style.left=p+'px';
        },
        mo:function(d){
            clearInterval(m.tm);
            var el,ew; el=parseInt(d.offsetLeft); ew=parseInt(d.offsetWidth);
            m.tm=setInterval(function(){menuSlider.mv(el,ew)},i);
        },
        mv:function(el,ew){
            var l,w; l=parseInt(g.offsetLeft); w=parseInt(g.offsetWidth);
            if(l!=el||w!=ew){
                if(l!=el){var ld,lr,li; ld=(l>el)?-1:1; lr=Math.abs(el-l); li=(lr<q)?ld*lr:ld*q; g.style.left=(l+li)+'px'}
                if(w!=ew){var wd,wr,wi; wd=(w>ew)?-1:1; wr=Math.abs(ew-w); wi=(wr<q)?wd*wr:wd*q; g.style.width=(w+wi)+'px'}
            }else{clearInterval(m.tm)}
}};}();


