
// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will 
// be attatched to it.
var stacks = {};


// this call to jQuery gives us access to the globaal
// jQuery object. 
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other 
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);

// Javascript for stacks_in_20_page2
// ---------------------------------------------------------------------

// Each stack has its own object with its own namespace.  The name of
// that object is the same as the stack's id.
stacks.stacks_in_20_page2 = {};

// A closure is defined and assined to the stack's object.  The object
// is also passed in as 'stack' which gives you a shorthand for refering
// to this object from elsewhere.
stacks.stacks_in_20_page2 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
$(document).ready(function() {
	//Set default open/close settings
	$('#stacks_in_20_page2 .acc_container').hide(); //Hide/close all containers
	$('#stacks_in_20_page2 .acc_trigger:nth(-1)').addClass('active').next().show(); //Add "active" class to first trigger, then show/open the immediate next container

	//On Click
	$('#stacks_in_20_page2 .acc_trigger').click(function(){
		if( $(this).next().is(':hidden') ) { //If immediate next container is closed...
			$('#stacks_in_20_page2 .acc_trigger').removeClass('active').next().slideUp({
			duration:1000,
			});
	 //Remove all "active" state and slide up the immediate next container
			$(this).toggleClass('active').next().slideDown({
			duration:1000,
			}); //Add "active" state to clicked trigger and slide down the immediate next container
		}
		else {
		$(this).removeClass('active').next().slideUp({
			duration:1000,
			})
		}
		return false; //Prevent the browser jump to the link anchor
	});


});
	return stack;
})(stacks.stacks_in_20_page2);



