function loadContent(uri, hide){
	if(!hide && $('.content').length || $('.portcarousel').length == 0){
		return true;
	}

	if(hide){
		hidePortfolio();
		$('.content').detach();
	}

	$('.entrybtn').detach();

	$.get(uri, {ajaxcontent: 1}, function(data){
		$('.content').detach();
		$('.main').append(data);
		$('.content').hide().slideDown(800);
	});
	return false;
}

function showPortfolio(){
	if($('.portcarousel').length){
		return;
	}

	$.get('ajax.html', {porttop: 1}, function(data){
		$('body').prepend(data);
		$('.portcarousel').hide().slideDown(800);
		$('#portmenu').hide().delay(500).slideDown(300);
	});

	$('#menu').animate({top: '-=125'}, 1000);
	$('#header').animate({top: '+=33'}, 1000);
	
	$('.content').slideUp(1000, function(data){
		$(this).detach();
	});
}

function hidePortfolio(){
	if(!$('.portcarousel').length){
		return;
	}

	$('.portcarousel').slideUp(800, function(data){
		$(this).detach();
	});
 
	$('#portmenu').slideUp(300, function(data){
		$(this).detach();
	});

	$('#menu').animate({top: '+=125'}, 800);
	$('#header').animate({top: '-=33'}, 800);
	
	$('.content').slideUp(800, function(data){
		$(this).detach();
	});
}

$(document).ready(function(){
	$('#menu a').click(function(event){
		$('#menu a').removeClass('active');
		$(this).addClass('active');
	});

	var IMGWIDTH = 3500;
	var DIVWIDTH = $(window).width();

	$(window).resize(function(){
		DIVWIDTH = $(window).width();
	});

	$('#header').mousemove(function(event){
		var x = event.pageX / DIVWIDTH;
		x = Math.round((IMGWIDTH - DIVWIDTH) * x);

		$('.headerback').css('background-position', '-'+x+'px 0px');
	});
});

