$(document).ready(function(){

	$('div#biography').columnize({ columns:3 });
	
	$('div#biography div.column').css('width', '349px');
	
	$('div#portfolio div.block p.more').toggle(function(){
		$('a.readmore', this).text('Read less...');
		$(this).stop().animate({'background-color':'#ffffff'}, 200);
		$('p.description', $(this).parents('div.block')).slideDown(200);
		$('span.overlay p.description', $(this).parents('div.block')).show();
		$(this).parents('div.block').switchClass('normal', 'expanded', 0);
		$('span.overlay', $(this).parents('div.block')).fadeTo(200, 1);
	}, function(){
		$('a.readmore', this).text('Read more...');
		$(this).stop().animate({'background-color':'#eeeeee'}, 200);
		$('p.description', $(this).parents('div.block')).slideUp(200);
		$('span.overlay p.description', $(this).parents('div.block')).hide();
		$(this).parents('div.block').switchClass('expanded', 'normal', 0);
		$('span.overlay', $(this).parents('div.block')).fadeTo(200, 0);
	});
	
	$('div#portfolio div.block.normal').live('mouseover mouseout', function(event){
		if(event.type == 'mouseover'){
			$(this).css('cursor', 'pointer');
			$('span.overlay', this).stop().fadeTo(200, 0);
			$('p.title', this).stop().animate({left:'-20em'}, 400);
			$('p.tagline', this).stop().animate({left:'-20em'}, 400);
			$('p.more', this).stop().animate({'background-color':'#eeeeee'}, 200);
		}
		else{
			$(this).css('cursor', 'normal');
			$('span.overlay', this).stop().fadeTo(200, 1);
			$('p.title', this).stop().animate({left:'1em'}, 400);
			$('p.tagline', this).stop().animate({left:'1em'}, 400);
			$('p.more', this).stop().animate({'background-color':'#ffffff'}, 200);
		}
	});
	
	var _location = 0;
	
	$('img#rightarrow').show();
	
	$('img#rightarrow').hover(function(){
		$(this).css('cursor', 'pointer');
	});
	$('img#leftarrow').hover(function(){
		$(this).css('cursor', 'pointer');
	});
	
	$('div#portfolio').css({
		'position':'relative',
		'width':'1080px',
		'height':'262px'
	});
	
	$('div#portfolio_container').css({
		'position':'relative',
		'width':'1080px',
		'height':'262px'
	});
	
	$('div#portfolio_container div.block').css({
		'position':'absolute',
		'margin':'0'
	});
	
	$('div#portfolio_container div.block').each(function(){
		$(this).wrap('<div class="block_container"></div>');
	});
	
	var _number = $('div#portfolio_container div.block_container').size();
	
	$('div#portfolio_container div.block_container').css({
		'overflow':'hidden',
		'overflow-y':'hidden',
		'position':'absolute',
		'height':'262px',
		'width':'365px'
	});
	
	$('div#portfolio_container div.block_container').each(function(){
		var _index = $(this).index('div.block_container');
		$(this).css({'left':_index*365, 'top':'0'});
		$(this).removeClass('last');
	});
	
	$('img#rightarrow').click(function(){
		if(_location < (_number - 3)){
			$('div#portfolio_container div.block_container').each(function(){
				$(this).animate({'left':'-=365px'}, 400);
			});
			_location = _location + 1;
			if(_location > 0){
				$('img#leftarrow').show();
			}
			if(_location == (_number - 3)){
				$('img#rightarrow').hide();
			}
		}
	});
	
	$('img#leftarrow').click(function(){
		if(_location > 0){
			$('div#portfolio_container div.block_container').each(function(){
				$(this).animate({'left':'+=365px'}, 400);
			});
			_location = _location - 1;
			if(_location == 0){
				$('img#leftarrow').hide();
			}
			if(_location < (_number - 3)){
				$('img#rightarrow').show();
			}
		}
	});
	
	$('div.block p.more').html('<a href="" class="readmore" title="Read more about this design">Read more...</a>');
	
	$("a.single_image").fancybox({
		'transitionIn'	:	'elastic',
		'transitionOut'	:	'elastic',
		'speedIn'		:	600,
		'speedOut'		:	200
	});

});