var current_scroller_page = -1;

var animate_working = false;


$(document).ready(function() {
	
	$('div.scroller_post_meta').css("opacity",'0.7')
	
	go_to_scroller_page(0);
	
});


function go_to_scroller_page(page_num) {
	
	if (page_num == current_scroller_page) {
		return;
	}
	
	var dir = 'right';
	
	if (page_num < current_scroller_page) {
		dir = 'left';
	}
	
	
	current_scroller_page = page_num;
	
	$('a.scroller_navigation_link').removeClass('active_page');
	
	$('a#scroller_navigation_' + page_num).addClass("active_page");
	
	
	
	if ($('div.scroller_page:visible').length != 0) {
	
		animate_working = true;
	
		var animate_time = 800;
		
		//we want to show the last three
		$('div.scroller_page:visible').hide();
		$('div.scroller_page:visible').unbind('click');
		
		$('div.scroller_page').removeClass('front_page');
		$('div.scroller_page').removeClass('second_page_back');
		$('div.scroller_page').removeClass('third_page_back');
		
		var front_page = $('div#scroller_page_' + page_num);
		
		front_page.addClass("front_page");
		front_page.css("opacity",'1.0');
		front_page.show();
		
		front_page.animate({
			width: "600px",
			height: "360px",
			marginTop: "60px",
			marginBottom: '0px',
			marginLeft: '0px',
			marginRight: '0px'
		},animate_time);
		
		var second_page = $('div#scroller_page_' + (page_num + 1));
		
		second_page.addClass('second_page_back');
		second_page.css("opacity",'0.7');
		second_page.show();
		
		second_page.click(function() {
			go_to_scroller_page(page_num + 1);
			return false;
		})
		
		second_page.animate({
			width: "550px",
			height: "280px",
			marginTop: "40px",
			marginBottom: '0px',
			marginLeft: '25px',
			marginRight: '25px'
		},animate_time);
		
		var third_page = $('div#scroller_page_' + (page_num + 2));
		
		third_page.addClass('third_page_back');
		third_page.css("opacity",'0.5');
		third_page.show();
		
		third_page.click(function() {
			go_to_scroller_page(page_num + 2);
			return false;
		})
		
		third_page.animate({
			width: "500px",
			height: "260px",
			marginTop: "20px",
			marginBottom: '0px',
			marginLeft: '50px',
			marginRight: '50px'
		},animate_time, function() {
			animate_working = false;
		});
		
		
		
		//setTimeout("function() { animate_working = false; }",8);
		
	} else {
		$('div#scroller_page_' + page_num).show();
	}
	
	
	
	
}
