/*
 * JavaScript code to detect Microsoft Internet Explorer, and switch to an
 * alternate stylesheet if it is found.
 *
 * vim:ft=javascript
 *
 * (C)Copyright Scott Wunsch, 2002
 * You may use and redistribute the contents of this file only under the
 * terms of the GNU GPL, a copy of which may be found at:
 *   http://www.losurs.org/COPYING
 */

// ===========================================================================

/* Yes, I know that detecting specific browsers is generally a bad idea.
 * Unfortunately, until Internet Explorer improves it's support for web
 * standards, I need to feed it a degraded stylesheet. */
function detectIE() {
	var agt = navigator.userAgent.toLowerCase();

	if ( (agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1) ) {
		/* We have Microsoft Internet Explorer */
		setActiveStyleSheet("Degraded stylesheet compatible with Microsoft Internet Explorer");
	}
}

/* This function was taken from http://www.alistapart.com/stories/alternate/.
 * It walks through the <Link> tags in the document, disabling the undesired
 * stylesheets and enabling the desired ones. */
function setActiveStyleSheet(title) {
	var i, a, main;
	for(i=0; (a = document.getElementsByTagName("Link")[i]); i++) {
		if (a.getAttribute("Rel").indexOf("Style") != -1 && a.getAttribute("Title")) {
			a.disabled = true;
			if(a.getAttribute("Title") == title) a.disabled = false;
		}
	}
}
