/* Purpose: Find the clicked fancy side panel accordion and handle expand/collapse
   Run when page has loaded.
   Modified: Simon Darcey, 29th January - only the style names. */

jQuery(document).ready(function() {
	// toggle audio/video extra stuff
	jQuery(".accordion-yes .toggle").click(function() {
		if (jQuery(this).next('.accordionContent').is(":hidden")) {
			jQuery(this).addClass("expanded");
		    jQuery(this).parent().addClass("acc-expanded");
			jQuery(this).next('.accordionContent').slideDown("fast");
		} else {
			jQuery(this).removeClass("expanded");
		    jQuery(this).next('.accordionContent').slideUp("fast",function(){
				jQuery(this).parent().removeClass("acc-expanded");
		    });
		}
		return false;
	});
	
	// toggle catalog program sections
	jQuery(".accordion-yes .toggle a").click(function() {
		if (jQuery(this).parent().parent().next().next().is(":hidden")) {
			jQuery(".accordion-yes .toggle a").removeClass("expanded");
			jQuery(".accordion-yes .toggle a").html("View Programs");
			jQuery(this).html("Hide Programs");
			jQuery(this).addClass("expanded");
			jQuery(".accordion-yes .accordionContent").slideUp("fast");
			jQuery(this).parents(".toggle").nextAll(".accordionContent").slideDown("fast");
		} else {
			jQuery(this).removeClass("expanded");
			jQuery(this).html("View Programs");
			jQuery(this).parents(".toggle").nextAll(".accordionContent").slideUp("fast");
		}
		return false;
	})	
	
});
