/*

jQuery version of show/hide script.

Author: Gerry Quach

Version 1.1
Date: 12 Feb 2010

*/





$(document).ready(function(){
	$(".show-content").hide();		// hide content blocks on load

	$(".individual.hide-button").removeClass("hide-button").addClass("show-button");
	$(".individual.small-hide-button").removeClass("small-hide-button").addClass("small-show-button");

	// handle individual show/hide buttons
	$("a.individual.show-button").live("click", function() {
		$(this).parent().next(".show-content").slideDown();
		$(this).removeClass("show-button").addClass("hide-button");
		return false;		
	});	
	
	$("a.individual.hide-button").live("click", function() {
		$(this).parent().next(".show-content").slideUp();						
		$(this).removeClass("hide-button").addClass("show-button");			
		return false;		
	});	

	$("a.individual.small-show-button").live("click", function() {
		var resultset = $(this).parent().next(".show-content");
		if (resultset.length < 1)
			$(this).next().next(".show-content").slideDown();					// site map has different layout and code	
		else
			$(this).parent().next(".show-content").slideDown();
		$(this).removeClass("small-show-button").addClass("small-hide-button");
		return false;
	});	

	$("a.individual.small-hide-button").live("click", function() {							  
		var resultset = $(this).parent().next(".show-content");
		if (resultset.length < 1)		
			$(this).next().next(".show-content").slideUp();					// site map has different layout and code	
		else
			$(this).parent().next(".show-content").slideUp();
		$(this).removeClass("small-hide-button").addClass("small-show-button");
		return false;
	});	


/*
	$("a.individual.small-hide-initial-button").live("click", function() {							  
		var resultset = $(this).parent().next(".show-initial-content");
		if (resultset.length < 1) {		
			$(this).next().next(".show-initial-content").slideUp();		
			$(this).next().next(".show-initial-content").removeClass(".show-initial-content").addClass("show-content");
		}
		else {
			$(this).parent().next(".show-initial-content").slideUp();
			$(this).parent().next(".show-initial-content").removeClass(".show-initial-content").addClass("show-content");
		}
		$(this).removeClass("small-hide-initial-button").addClass("small-show-button");
		return false;
	});	
*/


	//handle show all/hide all buttons
	$("a.toggle-all-show.show-button,a.toggle-all-show.small-show-button").click(function() {
		$("a.toggle-all-show.show-button,a.toggle-all-show.small-show-button").hide();
		$("a.toggle-all-hide.hide-button,a.toggle-all-hide.small-hide-button").show();
//		$(".show-content").slideDown("fast");		
		$(".show-content").show();
		$(".individual.show-button").removeClass("show-button").addClass("hide-button");
		$(".individual.small-show-button").removeClass("small-show-button").addClass("small-hide-button");		
		return false;		
	});
	
	$("a.toggle-all-hide.hide-button,a.toggle-all-hide.small-hide-button").click(function() {
		$("a.toggle-all-hide.hide-button,a.toggle-all-hide.small-hide-button").hide();
		$("a.toggle-all-show.show-button,a.toggle-all-show.small-show-button").show();		
//		$(".show-content").slideUp("fast");	
		$(".show-content").hide();
		$(".individual.hide-button").removeClass("hide-button").addClass("show-button");
		$(".individual.small-hide-button").removeClass("small-hide-button").addClass("small-show-button");		
		return false;		
	});
	
});


