/**********************************************************
					SHOW ONLY
***********************************************************
		
Pieced together from various code snippets.

To use, add the class "Hidden_Content" to items with a 
matching class (e.g. "Video") that need to be hidden.

Insert like such: 
	<a href="javascript:ShowOnly('1','Video','1');">Introduction</a>
to only show that content. Should work like a charm!

Assembled and modified by Stephen Shaw, shshaw@gmail.com
I found large portions of the code given for free, and
Jesus was a big fan of sharing, so it's only fair that I 
allow you to use / copy this code as you see fit.

**********************************************************/


// Hide all inactive content with the class ".Hidden_Content"
document.write("<style type=\"text/css\">.Hidden_Content { display: none; }</style>");

/* HIDE ALL function 
Hides all of a specific class */
var allPageTags = new Array(); 
var allPageTags=document.getElementsByTagName("*");

function hideAll(theClass) {	
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className.search(theClass)!=-1) { allPageTags[i].style.display = 'none';	}
	}
}

/* ADD CLASS function
Adds a specific class to an object */
function AddClass(id, strClass) {
	var n=document.getElementById(id);
	if(n) { n.className+=n.className?' Highlight':'Highlight'; }
}

/* REMOVE CLASS function
Remove class from an object */
   
function RemoveClass(objElement, strClass) {
   if ( objElement.className ) { // if there is a class
		var arrList = objElement.className.split(' '); // the classes are just a space separated list, so first get the list
		var strClassUpper = strClass.toUpperCase(); // get uppercase class for comparison purposes
	
		for ( var i = 0; i < arrList.length; i++ ) { 	// find all instances and remove them
			if ( arrList[i].toUpperCase() == strClassUpper ) { // if class found
				arrList.splice(i, 1); // remove array item
				i--;
			}
		 }
		 objElement.className = arrList.join(' '); // assign modified class name attribute
   }
}

/* HIGHLIGHT function
Adds a class to on object, and removes the class from the others */
function Highlight(id) {	
	for (i=0; i<allPageTags.length; i++) {
		if (allPageTags[i].className.search('Highlight')!=-1) { RemoveClass(allPageTags[i],'Highlight'); }
	}
	
	AddClass(id,'Highlight');	
}

/* SHOW ONLY function
This is the meat & potatoes, shows only one item of the certain class, and if you so choose, highlights the activation link. */

function ShowOnly(id,className, highlightHeader) {
	var content = document.getElementById(id);
	
	hideAll(className);
	
	if(content.style.display == 'block') { content.style.display = 'none'; }
	else { content.style.display = 'block'; }
	
	if(highlightHeader) { Highlight(id); }
}

/* Bonus Function!
SHOWHIDE allows you to show or hide one specific item */
function ShowHide(id) {
	var content = document.getElementById(id);
	
	if(content.style.display == 'block') { content.style.display = 'none'; }
	else { content.style.display = 'block'; }
}