$(window).load(function(){
		
	$('.post').not('.category-editorial, .category-monatsthema').each(function(){
		$(this).parent().appendTo('#projects');
	});
	
	$('#nav-below').prependTo('#projects');
	
	$('#projects').append('<div id="project-nav-box"><div id="project-nav"></div></div>');
	
	$('#content div:nth-child(3)').addClass('second');
	$('#projects div').removeClass('second');
		
	var projectCount = $('#projects .post').length;
	var pageCount = Math.round( ( projectCount / 12 ) + 0.5 );
	var projectPage = 1;
	
	function projectNavigation(page) {		
		var count = 1; 
		var intervalStart = 12 * page - 11;
		var intervalEnd = 12 * page;		
		$('#projects .post').each(function(){
			if ( count < intervalStart || count > intervalEnd ) {
				$(this).fadeOut(300);
			}			
			else if ( count >= intervalStart && count <= intervalEnd ) {
				$(this).fadeIn(300);
			}
			if (count % 2 == 0){
				$(this).addClass('odd');
			}
			count += 1;			
		});
	}
		
	projectNavigation(1);
	
	for( i = 1; i <= pageCount; i++){
		if (pageCount > 1){
  			$('#content #project-nav').append('<span id="' + i + '">' + i + '</span>');
  		}
	}
	
	$('#content #project-nav span').first().addClass('active');
	$('#content #project-nav span').live('click', function() {
		var page = $(this).attr('id');
		$('html,body').animate({scrollTop:$('#projects').offset().top-150},500);
		setTimeout(function(){projectNavigation(page);},500);
		$('#content #project-nav span').removeClass('active');
		$(this).addClass('active');
	});
	
	$("#twitter").getTwitter({
		userName: "RainerSchmidtLA",
		numTweets: 2,
		loaderText: "Loading tweets...",
		slideIn: true,
		showHeading: false,
		showProfileLink: false
	});
	
	/* TEAM-NAVIGATION */ 
	
	function showTeamContent(teamID) {
		console.log(teamID);
		/*switch (teamID) {
			case 'team-rs':
				$('#team #team-wrapper').css({height:'1350px'});				
				break;
			case 'team-tm':
				$('#team #team-wrapper').css({height:'4530px'});				
				break;
			case 'team-tb':
				$('#team #team-wrapper').css({height:'1610px'});
			/*	setTimeout(function(){
					$('#team-tb-content').append('</br><iframe width="537" height="335" src="http://www.youtube.com/embed/03It_b0JXmE?rel=0" frameborder="0" allowfullscreen></iframe><iframe width="537" height="335" src="http://www.youtube.com/embed/w2aNjMG6_g?rel=0" frameborder="0" allowfullscreen></iframe><iframe width="537" height="335" src="http://www.youtube.com/embed/RR21cR6nZ20?rel=0" frameborder="0" allowfullscreen></iframe>');	
				},400);		*/	
		//		break;
		//}
		
		$('#team-main, #team-content').animate({
			left:'-=600px'
		},400);
		$('.team-content').hide();
		$('#' + teamID + '-content').show();	
		
		var teamContentHeight = $('#team-content').height(); 
		$('#team-wrapper').height(teamContentHeight);	
	}
	
	function hideTeamContent(){
		$('#team-main, #team-content').animate({
			left:'+=600px'
		},400);
		$('#team #team-wrapper').css({height:'1350px'});
		var teamMainHeight = $('#team-main').height(); 
		$('#team-wrapper').height(teamMainHeight);
	}
			
	$('.team-box-link').live('click',function(){
		var teamID = $(this).parent().parent().attr('id');
		showTeamContent(teamID);	
	});	
	
	$('.team-back-link').live('click',function(){
		hideTeamContent();	
	});		
	
	$('#team #team-main .team-box img').live('click',function(){
		$(this).parent().find('.team-box-description p').slideToggle(400);		
		setTimeout(function(){
			var teamHeight = $('#team-main').height(); 
			$('#team-wrapper').height(teamHeight);	
		},400);
	});			
		
	var slide = false;
	$('#team #team-main .team-box h2').live('click',function(){
		$(this).parent().parent().find('.team-box-description p').slideToggle(400);		
		setTimeout(function(){
			var teamHeight = $('#team-main').height(); 
			$('#team-wrapper').height(teamHeight);	
		},400);
	});		
	
});











