document.getElementsByTagName('html')[0].className='js';

if (window.location.hash==""){
	var filename = location.pathname.substr(location.pathname.lastIndexOf("/")+1,location.pathname.length);
		//filename = filename.substr(0,filename.lastIndexOf("."));
	if (filename!=''){
		window.location.replace("./#"+filename);
	}else{
		window.location.replace("./#index");
	}
}

$(document).ready(function() {
	
     contentWrapID = 'ajax';
        if(!$('#load').get(0)) {
            $('#masthead').append('<div id="load">LOADING...</div>');
        }
        $('#load').fadeIn('normal');

    function showNewContent() {
        $("#" + contentWrapID).show({duration: 1000, easing:'easeInCubic'} );
        $('#load').fadeOut(1000);   
    }
    
    function pageload(hash) {
        if(hash) {
            $("#" + contentWrapID).load(hash + "",'',function(){
				 showNewContent();
            });
		} else {
			//$("#" + contentWrapID).load("index");
        }
    }
    $.historyInit(pageload);
    
    $('.ajax').livequery('click', function() {
        var hash = $(this).attr('href');
		if(hash=="./"){hash="index"};
        hash = hash.replace(/^.*#/, '');
		hash = hash.substr(0,hash.length);
        $("#" + contentWrapID).slideUp(500,function(){
            $.historyLoad(hash);
        });
        $('#load').fadeIn('normal');
        return false;
    });
		
});
