			//shows the loading gif
			function showLoading(fn) {
				$("#loading").fadeIn(200,fn);
			}
			//hides the loading gif
			function hideLoading(fn) {
				$("#loading").fadeOut(200,fn);
			}
			//loads the specified link and inject the html into the DOM
			function loadItem(link) {
					//show loading icon
					showLoading(function() {
						//fade the contents
						$("#contents").fadeOut(500);
						
						//slide the slider up
						$("#container").slideUp(500,function() {
							$("#container").load(link + " #contents",function(responseText,textStatus,XMLHttpRequest) {
									if (responseText.length == 0 || textStatus != "success")
									{
										$("#container").html(' <div id="contents"><div class="newsheader"><span class="keyword">static void</span> HandleError() { <span class="comments">/* Something went wrong! */</span></div><div class="content"><div class="newsitem"><div class="newscontent"><h1>Error!</h1><p>Unable to load your requested page, check your internet connection and try again later.</p></div></div></div><div class="newsfooter">} <span class="comments">/* end Portfolio() */</span></div></div>');
									}
									else
									{
									}
									
									setTimeout(function() {
										$("#contents").fadeIn(500);
										$("#container").slideDown(500,function() {
											hideLoading();
										});
									},100);
									
								})
						});
					});
			}
			
			$(function() {
				//registers the click for the links, also prevents bubbling
				$("#nav a").click(function() {
					var thishref = $(this).attr("href");
					loadItem(thishref);
					return false;
				});
				//automatically load the root page
				//if ajax has an error, write to error console
				$(document).ajaxError(function(){
					if (window.console && window.console.error) {
						console.error(arguments);
					}
				});
			});