$(document).ready(function() {
						   
	$('#content').wrap('<div id="content_wrapper"></div>');
						   
	function pageload(hash) {
		if(hash) {
			var href = $(this).attr('href');
			if(href == hash+'.html'){$(this).addClass('active');} // active link

			$("#content_wrapper").load(hash + ".html #content",'',function(){
				
				var theTitle = $('h1').text() + ' - ' + hash;
				document.title = theTitle;
				
				$('#content_wrapper').fadeIn(1000);
				$('#load').fadeOut('normal');
				$('#footer').show('slow');												   
			});
		} else {
			$("#content_wrapper").load("index.html #content"); //default
		}
	}
	$.historyInit(pageload);			   

	$('#nav li a').click(function(){
								  
		$('#nav li a').removeClass('active');
		$(this).addClass('active'); // active link
		
		var hash = $(this).attr('href');
		hash = hash.replace(/^.*#/, '');
		hash = hash.substr(0,hash.length-5);
		
		$('#content_wrapper').fadeOut('fast',function(){$.historyLoad(hash)});
		$('#footer').hide('fast');
		$('#load').remove();
		$('#stage').append('<p id="load">loading...</p>');
		$('#load').fadeIn('normal');
		return false;
		
	});
	
	// inputfield autoclear
	$(':text') 
	    .livequery('focus', function() { 
	        if($(this).val() == this.defaultValue){
				$(this).val('');	
			}
	
	    }); 
	
		$(':text') 
		    .livequery('blur', function() { 
		        if($(this).val() == ''){
					$(this).val(this.defaultValue);	
				}
	
		    });


});
