﻿function toggleContent() {		
	var hash = window.location.hash;
   	var animating = false;


	// slide-down incoming links
	$("#toggleThis").hide();		// initially hide main body content then
	if (!hash) {					//external links    				
		hideAllExcept('#' + $('#toggleThis > div:first').attr('id')) // only show fist div
		$("#toggleThis").slideDown(1500);		// slide down on page load
	}
	else {			//links to internal anchor, hide all except active link content
		hideAllExcept(window.location.hash);
		$('.hide').hide();
		$("#toggleThis").slideDown(1500);		// slide down on page load
	}
	
	
	// slide in & out links to in-page page anchors
    $('a.toggle').click(function() {
    	if (animating) return false;
        var href = $(this).attr('href');
        if ($(href).is('.hide')) {
       		animating = true;
       		$('.shown').slideUp(1500, function() {
       			hideAllExcept(href);
       			$('.hide').hide();
       			$(href).hide().slideDown(1500, function(){
       				animating = false;
       			});
     		});
       	}
        return false; // prevents the window from scrolling to the anchor
    });
}



function hideAllExcept(el) {
    $(el).removeClass('hide').siblings().addClass('hide');
    $(el).addClass('shown').siblings().removeClass('shown');
    $('a.toggle').removeClass('active');
    $('a[href="' + el + '"]').addClass('active');
}

//                                  2009-03-04
 //   "hide all except one"
//    by charles stuart
//    requires jquery (http://jquery.com/)
//    ** requires rev 1465 or above **
//    ** http://dev.jquery.com/ticket/745 **
    
//    Keep this url with the script:
//    http://enure.net/dev/hide-all-except-one/