jQuery.noConflict();

jQuery(document).ready(function(){	

	jQuery("body").addClass("animatethesoup");
	

	
	jQuery(".action").animate({
	rotate: '-15deg'
	},0);
	
	// News page tabbed content - clones titles to aside and tabs to div containing title text
	jQuery("#news .tabbed").hide();
	jQuery("#news  h2").clone().appendTo(".aside");
	jQuery("#news .aside h2:first").addClass("active").show();
	jQuery("#news .tabbed:first").show();
	jQuery("#news .aside h2").click(function() {
		jQuery("#news .aside h2").removeClass("active");
		jQuery(this).addClass("active");
		jQuery("#news .tabbed").hide();
		var story = jQuery('h2.active').text();
		jQuery("#news .tabbed:contains(" + story + ")").slideDown('100');
		return false;
	});
		
		
	// Explore page tabbed content
	jQuery("#explore .tabbed").hide(); //Hide all content
	jQuery("ul#explore-nav li:first").addClass("active").show(); //Activate first tab
	jQuery("#explore .tabbed:first").show(); //Show first tab content
	jQuery("ul#explore-nav li").click(function() {
		jQuery("ul#explore-nav li").removeClass("active"); //Remove any "active" class
		jQuery(this).addClass("active"); //Add "active" class to selected tab
		jQuery("#explore .tabbed").hide(); //Hide all tab content
		var activeTab = jQuery(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
		jQuery(activeTab).slideDown('1200'); //Fade in the active ID content
		return false;
	});
	
	
	// Glossary 
	jQuery("dl.list-gloss:first").before('<a href="#" class="all-trigger">Test yourself! <span>&#9650;</span></a>');
	jQuery('.list-gloss dt').append('<a href="#" class="dd-link">&#9660;</a>');
	jQuery(".list-gloss dt").toggle(function(){
		jQuery(this).addClass('active-dd');
		jQuery('.active-dd a').html('&#9650;');
		}, function () {
		jQuery(this).removeClass('active-dd');
		jQuery(this).find('.dd-link').html('&#9660;');
	});
	jQuery(".list-gloss dt").click(function(){
		jQuery(this).next(".list-gloss dd").slideToggle("fast");
	});
    jQuery(".all-trigger").toggle(function(){
		jQuery(this).html('Show descriptions! <span>&#9660;</span>');
		}, function () {
		jQuery(this).html('Test yourself! <span>&#9650;</span>');
	});
    jQuery(".all-trigger").click(function(){
		jQuery(".list-gloss dd").slideToggle("fast");
	});
	
	
  
	// Making room for some of the tabbed content on Explore page
	jQuery("#explore").addClass("big-book");	
	jQuery("li.glossary").one('click', function(){
	jQuery(".big-book span#book-overlay").animate({height: '255px', top: '217px'},1850);
	jQuery(".big-book a#buy-book").animate({
	rotate: '-27deg',
	scale: '-=.20',
	top: '4px',
	right: '-30px'
	},2000);
	jQuery("#explore").removeClass('big-book');
	});
	jQuery("li.websites").one('click', function(){
	jQuery(".big-book span#book-overlay").animate({height: '255px', top: '217px'},1850);
	jQuery(".big-book a#buy-book").animate({
	rotate: '-27deg',
	scale: '-=.20',
	top: '4px',
	right: '-30px'
	},2000);
	jQuery("#explore").removeClass('big-book');
	});

	
	function homeBook() {
	jQuery("#home .action").animate({
	right: '0'
	},0).delay(3000).animate({
	right: '20px'
	},5000);
	}
	homeBook();
	

	
	function authorBookDown() {
	jQuery("#author a#buy-book, #illustrator a#buy-book").delay(5000).animate({
	rotate: '1deg'
	},300, authorBookUp);
	}
	authorBookDown();
	
	function authorBookUp() {
	jQuery("#author a#buy-book, #illustrator a#buy-book").delay(5000).animate({
	rotate: '0deg'
	},2000, authorBookDown);
	}
	authorBookUp();
	
	function shrimpUp() {	
	jQuery("#shrimp").animate({opacity:"1"},300);	
	jQuery("#shrimp-clone").animate({opacity:"0"},300, shrimpDown);
	}
	function shrimpDown() {	
    jQuery("#shrimp").animate({opacity:"0"},300);
	jQuery("#shrimp-clone").animate({opacity:"1"},300, shrimpUp);	
	}
	shrimpUp();
	
	
	
	function labelUp() {
	jQuery('#book-label').animate({rotate: '-10deg'}, 6000, labelDown);
	}
	function labelDown() {
	jQuery('#book-label').animate({rotate: '25deg'}, 8000, labelUp);
	}
	labelUp();
	

	
	function snailOut() {
    jQuery("#snail-head").animate({width: '53px', top: '0'}, 5000, snailIn).delay(2000);	
	}
	function snailIn() {
	jQuery("#snail-head").animate({width: '33px', top: '12px'}, 5000, snailOut).delay(15000);
	}
	snailOut();


	
	function snailTrail() {
jQuery("#home #snail, #explore #snail").animate({ 
		left: "65%",
        top: "575px"
    }, 20000 ).animate({ 
		left: "55%",
        top: "595px"
    }, 20000 ).animate({ 
		left: "40%",
        top: "605px"
    }, 20000 ).animate({ 
		left: "30%",
        top: "580px"
    }, 20000 ).animate({ 
		left: "15%",
        top: "530px"
    }, 25000 ).animate({ 
		left: "-15%",
        top: "380px"
    }, 60000 ).animate({ 
		left: "100%",
        top: "546px"
    }, 0 );
	}
	snailTrail();

	
	
	function oneBubbleUp() {
	jQuery('.single-bubble').delay(50).animate({bottom: '1500px'}, 16000, oneBubbleDown);
	}
	function oneBubbleDown() {
	jQuery('.single-bubble').delay(5000).animate({bottom: '-300px'}, 0, oneBubbleUp);
	}
	oneBubbleUp();
	
	function doubleBubbleUp() {
	jQuery('.double-bubble').delay(60).animate({bottom: '1500px'}, 15100, doubleBubbleDown);
	jQuery('.little-bubbles-right').delay(6000).animate({bottom: '1500px'}, 14300);
	}
	function doubleBubbleDown() {
	jQuery('.double-bubble').delay(5000).animate({bottom: '-300px'}, 0, doubleBubbleUp);
	}
	doubleBubbleUp();
	
	function bubblesUp() {
	jQuery('.little-bubbles').delay(60).animate({bottom: '1500px'}, 15100, bubblesDown);
	jQuery('.single-bubble-right').delay(6000).animate({bottom: '1500px'}, 14500);
	}
	function bubblesDown() {
	jQuery('.little-bubbles').delay(5000).animate({bottom: '-300px'}, 0, bubblesUp);
	}
	bubblesUp();
	
	function rightBubblesUp() {
	jQuery('.double-bubble-right').delay(5500).animate({bottom: '1500px'}, 15100, rightBubblesDown);
	}
	function rightBubblesDown() {
	jQuery('.double-bubble-right').delay(5500).animate({bottom: '-300px'}, 0, rightBubblesUp);
	}
	rightBubblesUp();
		
	
	function clamShut() {
	jQuery("#clamshut").delay(21000).animate({backgroundPosition: '0 0'}, 0, clamOpen);
	}
	function clamOpen() {
	jQuery("#clamshut").delay(6000).animate({backgroundPosition: '0px -100px'}, 0, clamShut);
	}
	clamShut();
	
	function clamEyes1() {
	jQuery("#clam1-eyes").delay(8000).animate({backgroundPosition: '0 -10px'}, 0, clamEyes2);
	}
	function clamEyes2() {
	jQuery("#clam1-eyes").delay(5500).animate({backgroundPosition: '0px 0px'}, 0, clamEyes1);
	}
	clamEyes1();
	
	function clamEyes3() {
	jQuery("#clam2-eyes").delay(5400).animate({backgroundPosition: '0 -16px'}, 0, clamEyes4);
	}
	function clamEyes4() {
	jQuery("#clam2-eyes").delay(5500).animate({backgroundPosition: '0px 0px'}, 0, clamEyes3);
	}
	clamEyes3();

	
	
	
	
	function soloShrimpUp() {	
	jQuery("#shrimp-solo").animate({opacity:"1"},300);	
	jQuery("#shrimp-solo-clone").animate({opacity:"0"},300, soloShrimpDown);
	}
	function soloShrimpDown() {	
    jQuery("#shrimp-solo").animate({opacity:"0"},300);
	jQuery("#shrimp-solo-clone").animate({opacity:"1"},300, soloShrimpUp);	
	}
	soloShrimpUp();
	
	function soloShrimp() {	
    jQuery("#shrimp-solo-wrap").animate({ 
		scale: '-=.25',
        left: "26%",
		top: "960px"
    }, 9000 );
	jQuery("#arms").delay(6000).animate({ 
		left: "0",
        bottom: "0"
    }, 3800 ).delay(3000).animate({ 
		left: "-350px",
        bottom: "-345px"
    }, 3800 );
	jQuery("#shrimp-solo-wrap").animate({ 
		rotate: '10deg'
    }, 1000 ).animate({ 
		scale: '-=.25',
        left: "-120%",
		top: "200px"
    }, 6000, soloShrimpReturn);
  	}
	function soloShrimpReturn() {	
    jQuery("#shrimp-solo-wrap").delay(30000).animate({ 
		scale: '+=.50',
		rotate: '0',	
        left: "126%",
		top: "1100px"
    }, 0, soloShrimp ); 	
  	}
	soloShrimp();

	
	
	
	
	function goShrimps(){
    jQuery("#home #shrimp-wrap").delay(1000).animate({ 
		scale: '-=.25',
        right: "30%",
        top: "240px",
		rotate: '-6deg'
    }, 3500 ).animate({ 
		rotate: '10deg'
    }, 3500 ).delay(5000).animate({ 
		rotate: '-2deg',
        right: "10%",
		scale: '+=.25',
        top: "600px"
    }, 3500 ).animate({ 
        right: "-130%",
        width: "121px",
		top: "1200px"
	}, 3000, goShrimpsReturn );  
	}
	function goShrimpsReturn(){
    jQuery("#home #shrimp-wrap").delay(28000).animate({ 
        right: "50%",
        width: "60%",
		top: "400px"
	}, 3500);  
	jQuery("#home #bot-right").delay(30000).animate({ 
		right: "0",
        bottom: "0"
    }, 800 ).delay(3000).animate({ 
		right: "-300px",
        bottom: "-352px"
    }, 1800, goShrimps  );
	}
	goShrimps();
	
	jQuery("#explore #shrimp-wrap").delay(28000).animate({ 
        left: "100%",
        width: "121px",
		top: "800px"
	}, 3500);
	

	
	
	jQuery(window).one('scroll',function () {
	jQuery("#bot-right").delay(3000).animate({ 
		right: "0",
        bottom: "0"
    }, 800 ).delay(3000).animate({ 
		right: "-300px",
        bottom: "-352px"
    }, 1800);
	});
	

	
	
	


	jQuery("#video-wrap").click(function() {
	jQuery("div:animated").stop(true);
	});







  
  
  
});

