/*  MCPS Unobtrusive Ektron Menu Fix, version .9 (1/11/2008)
 *  (c) 2008 Montgomery County Public Schools
 *  by Matthew Barger
 *
 *  The MCPS Unobtrusive Ektron Menu Fix uses JavsScript and the DOM to disable
 *  the CSS files that Ektron "helpfully" adds to any Tron page with an Ektron
 *  Menu control.  These CSS files are appended later in the <head> of the 
 *  document causing them to have greater specificity and override our styles.  
 *  Pages with multiple Menu controls will have multiple links to the same extra
 *  CSS file.  This script will disable all <link>s to style sheets being served
 *  from the Ektron workarea.
 * 
 *  Requirements:  
 *    - This is a stand-alone library.  The only requirement is a HTML DOM 
 *      Level 2 compliant browser.
 *  Tested:
 *    (The following browsers were tested directly.)
 *    - IE 6
 *    - Firefox 2
 *    - Safari 3
 *    - Opera 9
/*--------------------------------------------------------------------------*/

/* Unobtrusive JavaScript Helper Functions -------------------------------- */
function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}

function removeEktronStyles() {
	// Look for a "link" element with a href containing
	// '/WorkArea/csslib/global.css' and set the <link>s disabled property
	// to true
	
	var links = document.getElementsByTagName("link");
	var pattern = /WorkArea\/csslib\/global.css/;
	for (var index = 0; index < links.length; ++index) {
		if (pattern.test(links[index].href)) {
			links[index].disabled = true;
		}
	}
}

/* Initialize Load Events ---------------------------------------- */
addLoadEvent(removeEktronStyles);