jQuery(document).ready(function(){
if(location.href.match("#") != "null"){
var hashSection = location.href;
var index = hashSection.indexOf("#");
hashSection = hashSection.substring(index,hashSection.length);
var moves = "";
if(hashSection == "#http://PickADisk.com"){
moves = 0;}
else if(hashSection == "#http://KeyJack.com"){
moves = 1}
if(moves != ""){
for(i = 0; i < moves; i++){
slidepage1("right");}}}

jQuery().everyTime(10000,function() {
var rand;
var classLength = jQuery("div[@id^=yespage0]").attr("class").length;
var current = parseInt(jQuery("div[@id^=yespage0]").attr("class").substring(9,5));
do{
	rand=Math.floor(Math.random()*2);
	}while(current == rand);
	if(current > rand){
		var iterations = current - rand;
		do{
			slidepage1("left");
			iterations--;}while(iterations != 0);}
		else{
			var iterations = rand - current;
			do{
				slidepage1("right");iterations--;
		}while(iterations != 0);
	}});

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

var classLength = jQuery(peeker).attr("class").length;

if(direction == "left"){
if(parseInt(peeker.attr("class").substring(9,classLength)) == (0)){
jQuery(peeker).attr("id","nopage1");
jQuery(".cellpage11").attr("id","yespage1");
jQuery(".tubepage1").animate({left: "+=220"},2000, function(){
jQuery(this).css("display","none");})
.animate({left: "-=660"},"fast", function(){jQuery(this).css("display","block");}).animate({left: "+=220"},2000);}

else{
var classLength = jQuery(peeker).attr("class").length;

var nextLeft = ".cell" + "page1" + (parseInt(jQuery(peeker).attr("class").substring(9,classLength)) - 1);
jQuery(peeker).attr("id","nopage1");
jQuery(nextLeft).attr("id","yespage1");
jQuery(".tubepage1").animate({left: "+=220"},2000);}}

if(direction == "right"){
var peeker = jQuery("div[@id^=yespage1]");
var classLength = jQuery(peeker).attr("class").length;

if(parseInt(peeker.attr("class").substring(9,classLength)) == 1){
jQuery(peeker).attr("id","nopage1");
jQuery(".cellpage10").attr("id","yespage1");
jQuery(".tubepage1").animate({left: "-=220"},2000, function(){jQuery(this).css("display","none");})
.animate({left: "+=660"},"fast", function(){jQuery(this).css("display","block");}).animate({left: "-=220"},2000);}

else{
var classLength = jQuery(peeker).attr("class").length;

var nextRight = ".cell" + "page1" + (parseInt(jQuery(peeker).attr("class").substring(9,classLength)) + 1);
jQuery(peeker).attr("id","nopage1");
jQuery(nextRight).attr("id","yespage1");
jQuery(".tubepage1").animate({left: "-=220"},2000);}
}}

jQuery(".leftpage1").click(function(){
slidepage1("left");});
jQuery(".rightpage1").click(function(){
slidepage1("right");});
});
