function backstory(){
	
jQuery('.showTimeline').click(function(){	
		jQuery('#timeline').animate({
			'left' : '470px'
		},1000);
		
		jQuery('#timeline-bg').animate({
			'left' : '470px',
			'opacity' : 0.55
		},1000, function(){
			
				jQuery('#copy1994').fadeIn('slow');
				jQuery('#red').animate({
					top: '60px',
					height: '137px'
				},'slow');
			
			

		
		});
		
		jQuery('#backstory-overlay').fadeIn('slow');
		jQuery('#grey').fadeIn('slow');
		jQuery('#red').fadeIn('slow');
		
		jQuery('#backstory-overlay').click(function(){
			
			jQuery('#backstory-copy div:visible').fadeOut(function(){	
			
					jQuery('#backstory-overlay').fadeOut();
					jQuery('#grey').fadeOut('slow');
					jQuery('#red').fadeOut('slow');
					jQuery('#timeline').animate({
					'left' : '890px'
				},1000);
				
				jQuery('#timeline-bg').animate({
					'left' : '890px',
					'opacity' : 0
				},1000);
			});
			
			jQuery(this).unbind();
			jQuery('#timeline1994').unbind();
			jQuery('#timeline1996').unbind();
			jQuery('#timeline2002').unbind();
			jQuery('#timeline2007').unbind();	
										
			backstory();
			
		});
		
		jQuery('.showTimeline').unbind();
		
		jQuery('#timeline1994').click(function(){
			jQuery('#backstory-copy div:visible').fadeOut(function(){
			
				jQuery('#copy1994').fadeIn('slow');
				jQuery('#red').animate({
					top: '60px',
					height: '137px'
				},'slow');
			
			});
		});
		
		jQuery('#timeline1996').click(function(){
			jQuery('#backstory-copy div:visible').fadeOut(function(){
			
				jQuery('#copy1996').fadeIn('slow');
				jQuery('#red').animate({
					top: '212px',
					height: '137px'
				},'slow');
			
			});
		});
		
		jQuery('#timeline2002').click(function(){
			jQuery('#backstory-copy div:visible').fadeOut(function(){
			
				jQuery('#copy2002').fadeIn('slow');
				jQuery('#red').animate({
					top: '364px',
					height: '117px'
				},'slow');
			
			});
		});
		
		jQuery('#timeline2007').click(function(){
			jQuery('#backstory-copy div:visible').fadeOut(function(){
			
				jQuery('#copy2007').fadeIn('slow');
				jQuery('#red').animate({
					top: '505px',
					height: '70px'
				},'slow');
			
			});
		});
		
		
		
	});
	

jQuery('.showTimeline').mouseover(function(){
	jQuery('#dates li').css({
		'text-decoration' : 'underline'
	});
}).mouseout(function(){
	jQuery('#dates li').css({
		'text-decoration' : 'none'
	});
});

}


function ourPhilosophy(){

	jQuery('a.philosophy').click(function(){
		
		
		jQuery(':animated').stop();
		
		jQuery('.written_text').css({
			'width' : '0px'
		});
		
		thisId = jQuery(this).attr('id');
		
		thisArrow = '#' + thisId + '_arrow';
		thisText1 = '#' + thisId + '_text1';
		thisText2 = '#' + thisId + '_text2';
		thisText3 = '#' + thisId + '_text3';
		
		thisWidth = jQuery(thisArrow + '>img').attr('width');

		jQuery(thisArrow).animate({'width' : thisWidth}, 1000, function(){
			thisWidth = jQuery(thisText1 + '>img').attr('width');
			jQuery(thisText1).animate({'width' : thisWidth}, 1000, function(){
				thisWidth = jQuery(thisText2 + '>img').attr('width');
				jQuery(thisText2).animate({'width' : thisWidth}, 1000, function(){
					thisWidth = jQuery(thisText3+ '>img').attr('width');
					jQuery(thisText3).animate({'width' : thisWidth}, 1000, function(){
					});
				});
			});
			
		
		
		});
	
	
	
	});

}







function weLoveToThink(cloud, top, left){

	cloudDiv = '#cloud' + cloud;
	
	
	jQuery('#we-love-to-think-text>a').click(function(){
		
			jQuery('#cloud1').next().fadeIn().unbind();
	
			jQuery('#cloud1').unbind().animate({
				'height' : '148px',
				'width' : '295px' ,
				'top' : '93px',
				'left' : '23px'
			},500).click(function(){
				
				jQuery(this).animate({
					'height' : '73px',
					'width' : '145px' ,
					'top' : '130px',
					'left' : '60px'
				},500).unbind();
				
				jQuery(this).next().fadeOut().unbind();
				
				weLoveToThink(1, 130, 60);	
				
			});
				
			jQuery('#cloud1').next().click(function(){
				
				
				jQuery(this).prev().animate({
					'height' : '73px',
					'width' : '145px' ,
					'width' : '145px' ,
					'top' : '130px',
					'left' : '60px'
				},500).unbind();
					
				jQuery(this).fadeOut().unbind();		
				
				weLoveToThink(1, 130, 60);	
				
			});	
		});
		
		
		
		

	jQuery(cloudDiv).mouseover(function(){
	
		jQuery(this).css({
			'height' : '88px',
			'width' : '175px' ,
			'top' : top - 15 + 'px',
			'left' : left - 15 + 'px'
		});
		
		if(cloud === 1){
			jQuery('#we-love-to-think-text>a').css({ 'text-decoration' : 'underline' });
		}
	
	}).mouseout(function(){
	
		jQuery(this).css({
			'height' : '73px',
			'width' : '145px' ,
			'top' : top + 'px',
			'left' : left + 'px'
		});
		
		
		if(cloud === 1){
			jQuery('#we-love-to-think-text>a').css({ 'text-decoration' : 'none' });
		}
	
	}).click(function(){
	
		
		jQuery(this).next().fadeIn();

		jQuery(this).unbind().animate({
			'height' : '148px',
			'width' : '295px' ,
			'top' : top - 37 + 'px',
			'left' : left - 37 + 'px'
		},500).click(function(){
			
			jQuery(this).animate({
				'height' : '73px',
				'width' : '145px' ,
				'top' : top + 'px',
				'left' : left + 'px'
			},500).unbind();
			
			jQuery(this).next().fadeOut().unbind();
			
			weLoveToThink(cloud, top, left);	
			
		});
			
		jQuery(this).next().click(function(){
			
			
			jQuery(this).prev().animate({
				'height' : '73px',
				'width' : '145px' ,
				'width' : '145px' ,
				'top' : top + 'px',
				'left' : left + 'px'
			},500).unbind();
				
			jQuery(this).fadeOut().unbind();		
			
			weLoveToThink(cloud, top, left);	
			
		});
								
	});
}


function pageTurn(bookID,jQuerypageheight,jQuerypagewidth){
	// set constants
   
   /* 
   var jQuerypageheight = 372; // the single page height we're using
   var jQuerypagewidth = 280; // the single page width we're using  
*/
   var jQuerypageYpos = 0; // the current Y position of our  background-image (in both pages)

bookID = '#' + bookID;
   
// When the page is ready  
	/* things in here happen as soon the document is ready */
	 		/* left page turner */
	  jQuery(bookID + " .leftpage").click( function() { 
	  		jQuerypageYpos = jQuerypageYpos + jQuerypageheight;
	  		jQuery(this)
				.css("background-position", "0px "+jQuerypageYpos+"px");	

			jQuery(this).siblings(".flip")
				.css("background-position", "top right");
					
			jQuery(this).siblings(".flip").animate({'background-position' : 'top center'},0, function(){
				setTimeout ('jQuery(".flip").css("background-position", "top center");', 100);
				jQuery(this).siblings(".rightpage").css("background-position", jQuerypagewidth + "px "+ jQuerypageYpos +"px");
			})
			  
		}); // close leftpage click function	
			   
	  /* right page turner */
	  jQuery(bookID + " .rightpage").click( function() { 
	  		jQuerypageYpos = jQuerypageYpos - jQuerypageheight;  // note minus page height 
	  		jQuery(this)
				.css("background-position", jQuerypagewidth + "px "+jQuerypageYpos+"px");	

			jQuery(this).siblings(".flip")
				.css("background-position", "top left");	
			
			
			
			jQuery(this).siblings(".flip").animate({'background-position' : 'top center'},0, function(){
				setTimeout ('jQuery(".flip").css("background-position", "top center");', 100);
				jQuery(this).siblings(".leftpage").css("background-position", "0px "+ jQuerypageYpos +"px");
			})
			  
		}); // close rightpage click function	
}



function detectFlash(){
	if (navigator.mimeTypes ["application/x-shockwave-flash"] == undefined){
    	jQuery(".flashAlt").show();
		jQuery(".flashContent").remove();
	}
	else {
		jQuery('.flashAlt').remove();
		jQuery('.flashContent').show();
	}
	
}
