var full_width = 0;
	var rotate_page_num = 0;
	var rotate_page_num_max = 0;

$(function(){
	
	$(".rotate_content > div > div").each(function(){
		full_width += $(".rotate_content").width();
		rotate_page_num_max++;
		$(this).width($(".rotate_content").width());
		
		
		
	});
	$(".rotate_content > div").width(full_width);
	$("#rotate_previous").animate({opacity:0}, 1);
	
	$("#rotate_previous ,#rotate_next, #rotate_toc").mouseover(function(){
		$(this).css('cursor', 'pointer');
	});
	
	$("#rotate_previous").click(function(){
		rotate_page_num--;
		if(rotate_page_num < 0){
			rotate_page_num = 0;	
		}else{
			$("#rotate_next").animate({opacity:1}, 100);	
		}
		$(".rotate_content > div").animate({left:-$(".rotate_content").width()*rotate_page_num}, 800);	
		if(rotate_page_num < 1){
			$("#rotate_previous").animate({opacity:0}, 100);	
		}
	});
	
	
	$("#rotate_next").click(function(){
		rotate_page_num++;
		if(rotate_page_num > rotate_page_num_max-1){
			rotate_page_num = rotate_page_num_max-1;	
		}else{
			$("#rotate_previous").animate({opacity:1}, 100);	
		}
		$(".rotate_content > div").animate({left:-$(".rotate_content").width()*rotate_page_num}, 800);	
		if(rotate_page_num >= rotate_page_num_max-1){
			$("#rotate_next").animate({opacity:0}, 100);	
		}
	});
	
	
	$("#rotate_toc").click(function(){
		rotate_to(0);							
									
	});
	
	
});


function rotate_to(id){
		rotate_page_num = id;
		
		if(rotate_page_num < 0){
			rotate_page_num = 0;	
		}else{
			$("#rotate_next").animate({opacity:1}, 100);	
		}
		
		if(rotate_page_num > rotate_page_num_max-1){
			rotate_page_num = rotate_page_num_max-1;	
		}else{
			$("#rotate_previous").animate({opacity:1}, 100);	
		}
		
		$(".rotate_content > div").animate({left:-$(".rotate_content").width()*rotate_page_num}, 800);	
		if(rotate_page_num >= rotate_page_num_max-1){
			$("#rotate_next").animate({opacity:0}, 100);	
		}
		if(rotate_page_num < 1){
			$("#rotate_previous").animate({opacity:0}, 100);	
		}
}


