$(document).ready(function() {
	
	$thisclick=0;
	$totalclicks=2;
		
	
	
	
	
	$animation=false;
	
	$intro1 = $('#intro1').height() + 8;
	$intro2 = $('#intro2').height() + 8;
	$intro3 = $('#intro3').height() + 8;
	
	$('#maincontent').css({
		height: $intro1+'px',
		overflow: 'hidden',
		position: 'relative'
	});
	$('#scroller').css({
		position: 'absolute',
		left: 0,
		top: 0
	});

	
	$('#readmore').click(function(){
		if($thisclick==3) {
			return false;
		}
		if(!$animation) {
			$animation=true;
			$thisclick++;
			scrollvertical();
		}
		return false;
	});
	
	function scrollvertical() {
		if($thisclick==1) {
			$newpos='-'+$intro1+'px';
			$('#scroller').animate({
				top: $newpos
				}, 800, function() {
				$animation=false;
			});
			$('#maincontent').animate({
				height: $intro2+'px'
			});
		}
		if($thisclick==2) {
			$newintro=$intro1+$intro2;
			$newpos='-'+$newintro+'px';
			$('#scroller').animate({
				top: $newpos
				}, 800, function() {
				$animation=false;
				$('#readmore a').html('Back to top');
			});
			$('#maincontent').animate({
				height: $intro3+'px'
			});
		}
		if($thisclick==3) {
			$('#scroller').animate({
				top: '0px'
				}, 800, function() {
				$thisclick=0;
				$animation=false;
				$('#readmore a').html('Read more');
			});
			$('#maincontent').animate({
				height: $intro1+'px'
			});
		}
		
	}
	
	
});



		
	
