$('document').ready(function(){
	
//HOME PAGE ANIMATION

	//Bind click and hover to the same function
	$('.partQuote').click(hoverOrClick).hoverIntent(hoverOrClick,doNothing);
		
	function doNothing(){}
	
	function hoverOrClick(e){
		
		e.stopPropagation();

		//Select the full quote from the box
		newContent = $(this).next('div.fullQuote').html();
			
		//Check the main box doesnt already contain the quote
		if($('#mainBoxText').html()!=newContent){
			
			//Fade out current quote, fade in new quote
			$('#mainBoxText').fadeOut(100, function(){
				
				$(this).html(newContent).fadeIn(100);										  
	 		});
		}
	}	
	
	
//JUST INVENT ANIMATION
	
	$("#inventImages img").hoverIntent(mouseOverImg, mouseOutImg);
	
	function mouseOverImg()
	{	
		thisSrc = $(this).attr('src').replace(/-off/,'-on');
		$(this).attr('src', thisSrc);	
	}
	
	function mouseOutImg(){
		
		thisName = $(this).attr('title');
		if(!$('li#'+thisName).is(':visible'))
		{	
			thisSrc = $(this).attr('src').replace(/-on/,'-off');
			$(this).attr('src', thisSrc);	
		}	
	}

	$("#inventImages img").click(function(){
		
		$(this).siblings('img').each(function(){
											  
			oldSrc = $(this).attr('src').replace(/-on/,'-off');
			
			$(this).attr('src', oldSrc);
		});
		
		thisSrc = $(this).attr('src').replace(/-off/,'-on');
		$(this).attr('src', thisSrc);
		
		thisName = $(this).attr('title');
									
		$('li#'+thisName).siblings('li').hide(100, 'swing', function(){								
		
			$('li#'+thisName).show(100, 'swing');
		});
	});
	
//JUST WHO ANIMATION	
	
	$("#whoisimagescontainer img").click(function(){
												  
		thisName = $(this).attr('title');
		
		$('li#'+thisName).siblings('li').hide(50, 'swing', function(){								
		
			$('li#'+thisName).show(50, 'swing');
		});
	});
});

