Hi there,

I am trying to optimize a website's performance and one of the suggestions is to combine some of the javascript code.

I'm a newbie to javascript so I wonder if I could get some advice on this...

Here is the current javascript code from the page's <head>

Code JavaScript:
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script> 
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20068031-1']);
  _gaq.push(['_trackPageview']);
 
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();
</script>
 
<script type="text/javascript">
sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
</script>
 
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" type="text/javascript"></script>
 
<script> 
            function switchContent(obj) { 
                obj = (!obj) ? 'today' : obj; 
 
                var contentDivs = document.getElementsByTagName('div'); 
                for (i=0; i<contentDivs.length; i++) { 
                    if (contentDivs[i].id && contentDivs[i].id.indexOf('today' && 'tomorrow' && 'yesterday') !== -1) { 
                        contentDivs[i].className = 'hide'; 
                    } 
                } 
                document.getElementById(obj).className = ''; 
            } 
 
            function checkTab() { 
                $('a').each(function() { 
                    $(this).click(function() { 
                        tab = $(this).attr('href').split('#'); 
                        switchContent(tab[1]); 
                        $('.current').attr('class',''); 
                        $(this).attr('class','current'); 
                    }); 
                }); 
            } 
 
            window.onload = function() { 
                checkTab(); 
            }; 
 
        </script>

Would a JS Guru please help me combine these into 1 script?

Many thanks.