$(document).ready(function() {
	var hash = window.location.hash;
	
	(!hash) ?
   		hideAllExcept('#' + $('#toggleThis > div:first').attr('id'))   // Open to first tab when loading page for the first time
 //       $('#toggleThis div.T').addClass('hide');        // close all div/tabs in <div id="toggleThis"> if page is loading for first time
		:hideAllExcept(window.location.hash); 							// otherwise load last selected div/tab on page refresh

    $('.toggle a').click(function() {				// assign a funciton to the click of any <el class="toggle"><a> (the tab headings)
		var href = $(this).attr('href');
		hideAllExcept(href);
		});
});


function hideAllExcept(el) {
    $('#toggleThis div.T').addClass('hide');		// The 'tab' styling is only added if javascript is enabled to ensure proper degradation
    $(el).removeClass('hide');

	$('ul.toggle a').removeClass('current');			// remove the class "current" if it exists from any a.toggle
	$('a[href="' + el + '"]').addClass('current');		// add class "current" to the selected a.toggle

}

/* NOTE:  This plug-in has been modified by EGL for appliation to butididit.com
	Please see the original at the URL at the bottom of the following notes 
	
	I have created two major changes:
		1) if the page is loading for the first time, all divs/tabs are hidden (and instructions are loaded from my html)
		2) a class of "current" is added to indicate which div/tab is being displayed  (he has added this to his code, but it is mine)
		
		Plus some other items unique to the idiosyncrasies of my site design
		
		For the original, please see the author, Charles Stuart's, page:    http://enure.net/dev/hide-all-except-one  */        
		
