function swapDivs() {
	// -----------  EDIT #1  ----------- //
	// Find div. Exit if it's not there
	var container = document.getElementById("slideshow"); // Swap ("slideshow") with your div id
	// -----------  END EDIT  ---------- //

    // Find all content divs. Hide them first...
    var reset = container.getElementsByTagName("div");
    for (var m = 0; m < reset.length; m++) {
        if (reset[m].getAttribute("id")) {
            reset[m].className = "hide";
        }
    }
    // ...then set the active div
    var activeDiv = document.getElementById(this.className);
    if (activeDiv) {
        activeDiv.className = "show";
    }

    // -----------  EDIT #3  ----------- //
    // Uncomment next line if action is on click
    return false;
    // -----------  END EDIT  ---------- //

}

function slideshow() {
	if (!document.getElementsByTagName || !document.getElementById) return false;

	// Find the unordered list
	var slideNav = document.getElementById("slideNav");
	if (!slideNav) return false;
	// Find the list items
   var lis = slideNav.getElementsByTagName("li");
		// Find the link
		for (var j = 0; j < lis.length; j++) {
			var links = lis[j].getElementsByTagName("a");
			for (var k = 0; k < links.length; k++) {
			     var link = links[k];

				// -----------  EDIT #2  ----------- //
				link.onclick = swapDivs;
                // -----------  END EDIT  ---------- //
			}
		}
};


/* addEvent function from http://www.quirksmode.org/ */
function addEvent( obj, type, fn ) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn ) {
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent) {
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}

///////////////////////////////////////////////////////////////////////////////////////////////////////
//																																																	 //
// The following is a combination of two scripts																										 //
// giving users a choice of opening links in a new window:																					 //
//																																																	 //
// Part 1: Insert a toggle, save selection on a cookie																							 //
// Author: Unknown																																									 //
// URL: http://test.newplasticarts.co.uk/flag-offsite-links/																				 //
//																																																	 //
// Part 2: Open links in new window																																	 //
// Author: Roger Johansson																																					 //
// URL: http://www.456bereastreet.com/archive/200605/opening_new_windows_with_javascript_version_11/ //
//																																																	 //
///////////////////////////////////////////////////////////////////////////////////////////////////////


function getNewWindowLinks() {
	if (!document.getElementById && !document.getElementsByTagName && !document.createElement && !document.appendChild) return false;

	makeToggler();
	checkCookie();
}

// Function:	Add the toggler to the page.
function makeToggler() {
	var togglerParent = document.getElementById('footer');
	var labelObj = document.createElement('label');
	var checkboxObj = document.createElement('input');
		checkboxObj.type = 'checkbox';
		checkboxObj.id = 'targetSwitcher';
		checkboxObj.onclick = function() { checkTargets() }
	var newText = document.createTextNode('Open external links in new window?');
		labelObj.appendChild(checkboxObj);
		labelObj.appendChild(newText);
		(togglerParent.childNodes.length > 0) ? togglerParent.insertBefore(labelObj,togglerParent.childNodes[0]) : togglerParent.appendChild(labelObj);
}

// Function:	Check Cookie
function checkCookie() {
	if (readCookie(window.location.hostname+'-offsiteLinks') == 'yes' || !readCookie(window.location.hostname+'-offsiteLinks')) {
		toggleExt();
		if (document.getElementById('footer')) {
			document.getElementById('targetSwitcher').checked = (readCookie(window.location.hostname+'-offsiteLinks'));
	//		checkTargets();
		}
	} else if (readCookie(window.location.hostname+'-offsiteLinks') == 'no') {
		toggleInt();
	}
}

// Function:	Toggler function for checkbox
function checkTargets() {
	(document.getElementById('targetSwitcher').checked == true) ? toggleExt() : toggleInt() ;
}

// Function: Create the new window
function openInNewWindow(e) {
	var event;
	if (!e) event = window.event;
	else event = e;
	// Abort if a modifier key is pressed
	if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) {
		return true;
	}
	else {
		// Change "_blank" to something like "newWindow" to load all links in the same new window
	    var newWindow = window.open(this.getAttribute('href'), '_blank');
		if (newWindow) {
			if (newWindow.focus) {
				newWindow.focus();
			}
			return false;
		}
		return true;
	}
}

// Function:	Toggle new windows on
function toggleExt() {
	createCookie(window.location.hostname+'-offsiteLinks','yes',365);

	// Find all links
	var links = document.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++) {
		var link = links[i];
		// Find all links with a rel name of "external"
		if (/\bexternal\b/.test(link.getAttribute('rel'))) {
			// Swap rel external with new-window
			link.setAttribute("rel", "new-window");
		}
		// Now that we've swapped, continue
		if (/\bnew-window\b/.test(link.getAttribute('rel'))) {
			link.setAttribute("title", "Opens in a New Window");
			link.onclick = openInNewWindow;
		}

		// Now find all links with a reverse relationship of "advertisement"
		if (/\badvertisement\b/.test(link.getAttribute('rev'))) {
			// Create the span element
			var span = document.createElement('span');
			span.appendChild(document.createTextNode('(Opens in a new window)'));
			span.className = "new-window-warning";

			// Insert span
			link.appendChild(span);
			link.removeAttribute("title");
		}

		// for IE 6
		if (/\bexternal\b/.test(link.className)) {
			// Cheat. Stupid IE! DIE IN A FIRE!!! BLARGH!!!!! ~!
			link.className = link.className.replace(" external", " new-window");
		}

	}
}

// Function:	Toggle new windows off
function toggleInt() {
	createCookie(window.location.hostname+'-offsiteLinks','no',365);

	// Find all links
	var links = document.getElementsByTagName('a');
	for (var i = 0; i < links.length; i++) {
		var link = links[i];
		// Find all links with a rel name of "new-window"
		if (/\bnew-window\b/.test(link.getAttribute('rel'))) {
			// Swap rel new-window with external
			link.setAttribute("rel", "external");
			link.removeAttribute("title");
			link.onclick = function() {
				return true;
			}

			// for IE 6
			if (/\bnew-window\b/.test(link.className)) {
				// Cheat. Stupid IE! DIE IN A FIRE!!! BLARGH!!!!! ~!
				link.className = link.className.replace(" new-window", " external");
			}

			// Now find all links with a reverse relationship of "advertisement"
			if (/\badvertisement\b/.test(link.getAttribute('rev'))) {
				var spans = link.getElementsByTagName('span');
				for (var k = 0; k < spans.length; k++) {
					var span = spans[k];
					// Remove span
					link.removeChild(span);
				}
			}
		}
	}
}

// Function:	Create New Windows Cookie
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days*24*60*60*1000));
		var expires = '; expires=' + date.toGMTString();
	}
	else var expires = '';
	document.cookie = name + '=' + value + expires + '; path=/';
}

// Function:	Read New Windows Cookie
function readCookie(name) {
	var nameEQ = name + '=';
	var ca = document.cookie.split(';');
	for(var i=0, c; c = ca[i];i++) {
	while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


//--- [  toggle Side Panels  ] --------------------------------------------------------------------|
function togglePanel(bTid, tMid, sMid) {//v1.0 dp
  var tM, sM, args = arguments;
	if ((tM = document.getElementById(tMid)) != null) {
		if ((sM = document.getElementById(sMid)) != null) {
			var tr = tM.childNodes[0];
			sM.style.display = "none";
			tr.onclick = function() {
				var ds = sM.style.display;
				var tS = (tM.childNodes[0].className);
				if(document.getElementById(args[0]) != null || document.getElementsByTagName("BODY").item(0).getAttribute("id") == bTid) {
    			sM.style.display = (ds == "block") ? "none" : "block";
					return false;
				}
			};
			tr.onfocus = function() {
				this.blur();
			};
		}
	}
	if(document.getElementById(args[0]) != null) {
		document.getElementById(args[2]).style.display = "block";
	}
}

//--- [  Initiation  ] ------------------------|
var init = function() {
	    togglePanel("bm1", "industry", "industrySub");
	    togglePanel("bm2", "itComp", "itCompSub");
	    togglePanel("bm3", "equip", "equipSub");
	    togglePanel("bm4", "hlthCare", "hlthCareSub");
      };



///////////////////////////////////////////////////////////////////////////////////////////////////////


// addEvent(window, 'load', getNewWindowLinks);

// Add onload events here. Function serves so all events fire without error.
addEvent(window, 'load', slideshow);
addEvent(window, 'load', getNewWindowLinks);
addEvent(window, 'load', init);
