$(function(){

	// $('.content').before('');
	$("#loader").animate({opacity:1},200);
	$(window).scroll(checkheadFix).load(function(){
		$('.content').animate({opacity:1},1000);
		$("#loader").remove();
	});
	markMenu();
	
	trackExternal();
	
})


var oldST;
function checkheadFix() {
	st = $(window).scrollTop();

	if(st == oldST)return;
	dir = (st - oldST);
	oldST = st;
	
	if(st >= 174 && !$('.fixedhead').length) {
		$('body').addClass('fixedhead');
	} else if($('.fixedhead').length && st <= 174) {
		$('.fixedhead').removeClass('fixedhead');
	}
}

function markMenu(){
	id = $('body').attr('id');
	$('#nav a.'+id).addClass('selected');
}

function trackExternal() {
	$('a[href^="http://"]').click(function(){
		pageTracker._trackPageview("outgoing/"+$(this).attr('href').substr(7));
		$(this).delay(500).trigger('visit');
		return false;
	}).bind('visit',function(){
		self.location.href = $(this).attr('href');
	})
	
}
