function init($rel) {
	$rel = $rel || $('body');
	$("a", $rel).unbind().click(function(e) {
		$t = $(this);
		var href = $t.attr('href');
		if(!$t.attr('target') && href.indexOf('wp-admin') < 0) {
			loadPage(href);
			e.stopPropagation();
			return false;
		}
	});
};
function loadPage(href) {
	// frag id stuff
	var loc = window.location.href;
	if(loc.indexOf('#') > -1) {
		loc = loc.split('#')[0];
	}
	window.location.href = loc+'#'+href;
	
	// load new content
	$content = $('#content');
	$content.fadeOut('fast', function() {
		$content.load(href+" #content", {}, function() {
			init($content);
			$content.fadeIn('fast');
			$('#loading').fadeTo('fast', 0);
		});
	});
	$('#loading').fadeTo('fast', .2);
}
$(function() {
	init();
	if(window.location.href.indexOf('#') > -1) {
		$('#content').hide();
		loadPage(window.location.href.split('#')[1]);
	}
	$('#fade_bottom > div').css('height', '100%');
	setTimeout(function() {
		$('#fade_bottom > div').animate({ height:'100px' }, 1500, 'swing').css('overflow', 'visible');
	}, 500);
	// load twitter status
	$.getJSON('http://twitter.com/statuses/user_timeline/landonspringer.json?count=5&callback=?', {}, function(data) {
		var index = /*Math.round(Math.random()*4);*/ 0;
		$('#twitter p').html(data[index].text).fadeTo('fast', .9);
	});
});

