// jQuery code for design.umn.edu's homepage
// Last updated 02.02.2012 by Paul Jarvis

// Window On-load

$(window).load(function(){
	
	// Showcase Stage Features rotation code
    
	$("#featured").hover(  
		function() {  
		$("#featured").tabs("rotate",0,true);  
		},  
		function() {  
		$("#featured").tabs("rotate",5000,true);  
		}  
	); 
	
	// Showcase Stage Gallery thumbnail rollovers
	
	$('.gallery ul li').find('img').css('opacity', 0.3);	// set all images to 30% opacity on page load

	$('.gallery ul li').hover(function(){ 					// on list-item hover
		$(this).find('img').stop().fadeTo(100, 1); 			// ... fade to 100% opacity
	});
	
	$('.gallery ul li').mouseout(function() { 				// on list-item mouseout
		$(this).find('img').stop().fadeTo(100, 0.3); 		// ... fade to 30%
	});
		
	// Showcase stage navigation
	
	$('#stageNav .features').addClass('active');		
	$('#stageNav .features').attr('title', 'active');	
	
	$('#stageNav ul li').click(function () {
		if ($(this).attr('title') != "active") {			// If current list item's title is not "active"
			$('#stageNav ul li').removeClass('active');		// ... remove all active classes from list items
			$('#stageNav ul li').attr('title', '');			// ... 		and remove all titles from list items
			$(this).addClass('active');						// ... set current list item as active
			$(this).attr('title', 'active');				// ...		and set current list item's title as active
	
			$('#stagePane1').fadeOut('fast');				// Fade out all panels
			$('#stagePane2').fadeOut('fast');
			$('#stagePane3').fadeOut('fast');
			$('#stagePane4').fadeOut('fast');
			$('#stagePane5').fadeOut('fast');
			
			panelActive = $(this).attr("class");			// Set clicked nav button to active
			
			if(panelActive == "features active") { $('#stagePane1').fadeIn('fast'); }		// Fade in clicked panel
			if(panelActive == "stories active") { $('#stagePane2').fadeIn('fast'); }		// based on which nav button 
			if(panelActive == "exhibitions active") { $('#stagePane3').fadeIn('fast'); }			// was clicked
			if(panelActive == "gallery active") { $('#stagePane4').fadeIn('fast'); }
			if(panelActive == "initiatives active") { $('#stagePane5').fadeIn('fast'); }
		
			return false;																	 //disable click event	
		}
	});
});
