// JavaScript Document

function switchLabel(action) {
	
	var el = document.getElementById('toc_link');
	
	if (action == 1) {
		// make script say Hide Table of Contents
		el.innerHTML = "Hide Table of Contents";
		var p = document.getElementById('toc_link_show');
		p.id = 'toc_link_hide';
	} else if (action == 0) {
		// make script say Show Table of Contents
		el.innerHTML = "Show Table of Contents";
		var p = document.getElementById('toc_link_hide');
		p.id = 'toc_link_show';
	}
}



/* 
Create the new window 
*/ 
function openInNewWindow() { 
	// Change "_blank" to something like "newWindow" to load all links in the same new window 
	var newWindow = window.open(this.getAttribute('href'), '_blank'); 
	newWindow.focus(); 
	return false; 
} 

/* 
Add the openInNewWindow function to the onclick event of links with a class name of "non-html" 
*/ 
function getNewWindowLinks() { 
	// Check that the browser is DOM compliant 
	if (document.getElementById && document.createElement && document.appendChild) { 
		// Change this to the text you want to use to alert the user that a new window will be opened 
		var strNewWindowAlert = "link opens in a new window"; 
		// Find all links 
		var objWarningText; 
		var strWarningText; 
		var link; 
		var links = document.getElementsByTagName('a'); 
		for (var i = 0; i < links.length; i++) { 
			link = links[i]; 
			// Find all links with a class name of "_blank" 
			if (/\b\_blank\b/.exec(link.className)) { 
				link.title = strNewWindowAlert;
				link.onclick = openInNewWindow; 
			} 
		} 
		objWarningText = null; 
	} 
} 

// A general function to add an event handler
function addHandler(obj, evt, newhandler, captures) {
	if (obj.attachEvent) {
		obj.attachEvent('on' + evt, newhandler);
	}
	else if (obj.addEventListener) {
		obj.addEventListener(evt, newhandler, captures);
	}
	else {
		var oldhandler;
		if (oldhandler = obj['on' + evt]) {
			obj['on' + evt] = function() {
				oldhandler();
				newhandler();
			}
		}
		else {
			obj['on' + evt] = newhandler;
		}
	}
}

addHandler(window, 'load', getNewWindowLinks); 