$(document).ready(function(){

    // hide all slidable divs
	$(".toggle_content").hide();
    
    // this shows any active slider when the page loads
    $(".trigger.active").next(".toggle_content").show();

    // if this is omitted then the sliding expansion and contraction is not smooth
    $(".trigger").toggle(function(){
    }, function(){
    });
        
	$("#subColumn .trigger").click(function(){
        var clickedOnContent = $(this).next("#subColumn .toggle_content")
        
        // if the user clicked on a trigger for a hidden area
        if (clickedOnContent.is(":hidden")) {
            // hide all areas
            $("#subColumn .toggle_content").slideUp("slow");
            // deactivate all triggers
            $("#subColumn .trigger").removeClass("active");
        }
        // toggle the content area that the user clicked on
		clickedOnContent.slideToggle("slow");
        // toggle the trigger that the user clicked on
        if ($(this).hasClass("active"))
            $(this).removeClass("active");
        else
            $(this).addClass("active");
	});
	
	$("#navColumn .trigger").click(function(){
        var clickedOnContent = $(this).next("#navColumn .toggle_content")
        
        // if the user clicked on a trigger for a hidden area
        if (clickedOnContent.is(":hidden")) {
            // hide all areas
            $("#navColumn .toggle_content").slideUp("slow");
            // deactivate all triggers
            $("#navColumn .trigger").removeClass("active");
        }
        // toggle the content area that the user clicked on
		clickedOnContent.slideToggle("slow");
        // toggle the trigger that the user clicked on
        if ($(this).hasClass("active"))
            $(this).removeClass("active");
        else
            $(this).addClass("active");
	});
	
	$("#contentColumn .trigger").click(function(){
        var clickedOnContent = $(this).next("#contentColumn .toggle_content")
        
        // if the user clicked on a trigger for a hidden area
        if (clickedOnContent.is(":hidden")) {
            // hide all areas
            $("#contentColumn .toggle_content").slideUp("slow");
            // deactivate all triggers
            $("#contentColumn .trigger").removeClass("active");
        }
        // toggle the content area that the user clicked on
		clickedOnContent.slideToggle("slow");
        // toggle the trigger that the user clicked on
        if ($(this).hasClass("active"))
            $(this).removeClass("active");
        else
            $(this).addClass("active");
	});

});

$(document).ready(function(){
						   
	$(".toggle_text").hide(); 
	
	$(".readmoresummary").click(function(){
		$(this).prev(".toggle_text").slideToggle('slow', callbackFn);
	});
	
	$(".readmoretitle").click(function(){
		$(this).next().next(".toggle_text").slideToggle('slow', callbackFn);
	});
	
	function callbackFn(){
		var $link = $(this).next(".readmoresummary");
		$(this).is(":visible") ? $link.text("Close article «") : $link.text("Read entire article »");
	}

});
