jQuery(document).ready(function(){

function slidepage0(direction){
var peeker = jQuery("div[@id^=yespage0]");

if(direction == "left"){
if(parseInt(peeker.attr("class").substring(4,5)) == (0)){
jQuery(peeker).attr("id","nopage0");
jQuery(".cell0page0").attr("id","yespage0");
jQuery(".leftpage0").animate({opacity: "1"}, "fast");
jQuery(".leftpage0").css("cursor","pointer");
jQuery(".rightpage0").animate({opacity: "0"}, "fast");
jQuery(".rightpage0").css("cursor","auto");
jQuery(".tubepage0").animate({left: "+=620"},2000, function(){
jQuery(this).css("display","none");})
.animate({left: "-=1240"},"fast", function(){jQuery(this).css("display","block");}).animate({left: "+=620"},2000);}

else{
var nextLeft = ".cell" + (parseInt(jQuery(peeker).attr("class").substring(4,5)) - 1) + "page0";
jQuery(peeker).attr("id","nopage0");
jQuery(nextLeft).attr("id","yespage0");
if((parseInt(jQuery(nextLeft).attr("class").substring(4,5))) == 0){
jQuery(".leftpage0").animate({opacity: "0"}, "fast");
jQuery(".leftpage0").css("cursor","auto");}
jQuery(".rightpage0").animate({opacity: "1"}, "fast");
jQuery(".rightpage0").css("cursor","pointer");
jQuery(".tubepage0").animate({left: "+=620"},2000);}}

if(direction == "right"){
var peeker = jQuery("div[@id^=yespage0]");
if(parseInt(peeker.attr("class").substring(4,5)) == 0){
jQuery(peeker).attr("id","nopage0");
jQuery(".cell0page0").attr("id","yespage0");
jQuery(".leftpage0").animate({opacity: "0"}, "fast");
jQuery(".leftpage0").css("cursor","auto");
jQuery(".tubepage0").animate({left: "-=620"},2000, function(){jQuery(this).css("display","none");})
.animate({left: "+=1240"},"fast", function(){jQuery(this).css("display","block");}).animate({left: "-=620"},2000);}

else{
var nextRight = ".cell" + (parseInt(jQuery(peeker).attr("class").substring(4,5)) + 1) + "page0";
jQuery(peeker).attr("id","nopage0");
jQuery(nextRight).attr("id","yespage0");
jQuery(".leftpage0").animate({opacity: "1"}, "fast");
jQuery(".leftpage0").css("cursor","pointer");
if((parseInt(jQuery(nextRight).attr("class").substring(4,5))) == 0){
jQuery(".rightpage0").animate({opacity: "0"}, "fast");
jQuery(".rightpage0").css("cursor","auto");}
jQuery(".tubepage0").animate({left: "-=620"},2000);}
}}

jQuery(".leftpage0").click(function(){
slidepage0("left");});
jQuery(".rightpage0").click(function(){
slidepage0("right");});
});
