/*
	This script is a modified version of styleswitch.js from Eric Meyer's site:
		http://www.meyerweb.com/eric/

	Eric's version is based on Paul Snowden's styleswitcher.js, which can be found on A List Apart:
		http://www.alistapart.com/stories/alternate/

	It has mainly got the cookie setting code removed.
*/

function setActiveStyleSheet(title) {
	var styleElement;

	if (title) {
		for (var loop=0; (styleElement = document.getElementsByTagName('link')[loop]); loop++) {
			if (styleElement.getAttribute('rel').indexOf('stylesheet') != -1 && styleElement.getAttribute('title')) {
				styleElement.disabled = true;
				if (styleElement.getAttribute('title') == title) styleElement.disabled = false;
			}
		}
	}
}

// the decision to write out the css switching bar using javascript was taken after realising
// that people without javascript couldn't use it anyway, so why have it displaying for them?
// the css files are still linked in to allow (supporting) browsers to handle the switching.
function writeCSSSwitcher() {
	var cssBarHTML = '<p><span class="invisible">The following toolbar lets you change the colour scheme using JavaScript and alternate style sheets (for browsers that support JavaScript and alternate stylesheets)<br /><br /></span>';
	cssBarHTML += '<span class="navBarItem"><a href="javascript:setActiveStyleSheet(\'Default Brown Style\');" class="navBarHrefDefaultBrown" tabindex="101" title="Change the page style to SoTerm Default Brown">&nbsp;Brown&nbsp;</a></span><span class="invisible"> | </span>';
	cssBarHTML += '<span class="navBarItem"><a href="javascript:setActiveStyleSheet(\'Cool Blue Style\');" class="navBarHrefCoolBlue" tabindex="102" title="Change the page style to Cool Blue">&nbsp;Cool Blue&nbsp;</a></span><span class="invisible"> | </span>';
	cssBarHTML += '<span class="navBarItem"><a href="javascript:setActiveStyleSheet(\'Black and White Style\');" class="navBarHrefBlackandWhite" tabindex="103" title="Change the page style to Black and White">&nbsp;Black and White&nbsp;</a></span><span class="invisible"> | </span>';
	cssBarHTML += '<span class="navBarLastItem"><a href="javascript:setActiveStyleSheet(\'White and Black Style\');" class="navBarHrefWhiteandBlack" tabindex="104" title="Change the page style to White and Black">&nbsp;White and Black&nbsp;</a></span></p>';
	document.getElementById('cssMenuBar').innerHTML = cssBarHTML;
}
