$(function() {
	$("a[rel^='lightbox']").prettyPhoto({theme: 'facebook', showTitle: false});
	$("a[rel!='external']").live('click', ajaxSwitch);
});

function ajaxLoad(href) {

	if (getRelative("") == href) {
		$("#main").animate({'marginTop': -220}, 'slow');
		$("#logo").fadeIn('slow');
		href += 'ajax';
	} else {
		$("#main").animate({'marginTop': -675}, 'slow');
		$("#logo").fadeOut('slow');
		href += '/ajax';
	}

	$.ajax({
			type: 'POST',
			url: href,
			success: ajaxSwitchCallback,
			dataType: 'html'
		});
	
	$('#ajax-loader').show();
	
}

function ajaxSwitch() {
	ajaxLoad($(this).attr("href"));
	return false;
}

function ajaxSwitchCallback(data, txt) {
	if (txt == 'success') {
		$('#ajax-loader').hide();
		$('#ajax').html(data);
	}
}