$(document).ready(function() {
	
	$(".teammember").live("mouseover", function(){
		$('#quotes').text($(this).find('.quote').text());
		$('img.member_pic').each(function() {
			$(this).attr('src',"/images/crew/" + $(this).parent('.teammember').attr('id') + '.jpg');
		});
		$(this).find('img.member_pic').attr('src',"/images/crew/" + $(this).attr('id') + '-col.jpg');
		$('#quote_tail').remove();
		$(this).prepend("<div id='quote_tail'></div>");
	});
	$(".teammember").live("mouseout", function() {
		$(this).find('img.member_pic').attr('src',"/images/crew/" + $(this).attr('id') + '.jpg');
	});
	
	$('#projects_list li a').live("click",function() {
		if (!$(this).hasClass('selected')) {
			$('#projects_list li a').removeClass('selected');

			$('#project_tmp').load("/portfolio/" + $(this).attr('class'), function() {
				$('#project_tmp .project:first img:first').hide();
				if($('#project_screenshot img').length == 0) {
					$('#project_screenshot').html($('#project_tmp .project:first img:first'));
					$('#project_screenshot img').fadeIn(300);
				} else {
					$('#project_screenshot img').fadeOut(300, function() {
						$('#project_screenshot').html($('#project_tmp .project:first img:first'));
						$('#project_screenshot img').fadeIn(300);
					});
				} 
				$('#project_description').animate({left: '-400px'})
					.html($('#project_tmp .project:first .description:first'))
					.animate({left: '0px'});
			});
			$(this).addClass('selected');
		}
		return false;
	});
	
	$('#tweets').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 6000,
		type: 'sequence'
	});
		
	function loadBehavior() {
		$('a.fancy').fancybox({
			'hideOnContentClick': false,
			'frameWidth': 700,
			'frameHeight': 450,
			'overlayOpacity': 0.7,
			'callbackOnShow': loadBehavior
		});
		$(".teammember:first").mouseover();	
		$("#projects_list li a:first").click();
	}
	
	loadBehavior();
	
	/* $(window).bind('resize load', function() {
		$('#contentWrapper').vAlign();
	}); */
	
	$('#menu ul').ajaxcontent({
		callbackOnLoad: loadBehavior
	});
	
});