$(document).ready(function(){

	// oh IE, IE, your PNG alpha channel handling is retarded.
	var secondAnimation = ($.browser.msie) ? {
		marginLeft: '2px'
	} : {
		opacity: 0,
		marginLeft: '2px'
	};

	$('#navigation a, a.navigation, .portfolio-navigation a').live('click', function(){

		var href = this.href.substring(this.href.indexOf('/', 9));				

		$newslide = $('<div />').css('opacity',  0);
		$newslide.load(href + ' .slide', function(responseText){
			$('#content-container').prepend(this);
			$(this).animate({ opacity: 1 }, {queue: false, duration: 50});
			var page = href.match(/[\w]+/);
			page = (page) ? page[0] : 'hello';
			$('body').removeClass('hello portfolio contact').addClass(page);
			document.title = 'skinnyfit | website design | ' + page;
		});

		$('.slide').addClass('flip').animate({
			marginTop: '+=150',
			marginLeft: '-3px',
			height: '50%'
		}, {
			duration: 400,
			queue: false
		}).delay(280).animate(secondAnimation, {
			duration: 120,
			complete: function(){
				$(this).remove();
			}
		});

		_gaq.push(['_trackPageview', href]);
		
		return false;
		
	});
	
});
