// RTM Bespoke Javascript

function changeStyleSheet() {
	var agt=navigator.userAgent.toLowerCase();
	var sheets =  document.getElementsByTagName("link");
	var imgs = document.getElementsByTagName("img");
	
	// Changing the stylesheet creates different problems in different browsers
	// IE	   - PROBLEM:  doesn't redraw the whole screen
	//		   - SOLUTION: hide the BODY and then display it again;
	// Mozilla - PROBLEM:  if the existing stylesheet is disabled or changed, the flash file is reloaded.
	//		   - SOLUTION: simply enable the new stylesheet and ensure it overrules the existing sheets changes. 
	
	if ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)) {
		sheets[3].href = sheets[2].href;
		document.body.style.display = 'none';
		document.body.style.display = 'block';	
	}
	else {
		sheets[2].disabled = false;							
	}
	
	// Now update the dark images (all ending in _dark)
	var reDarkCheck = new RegExp("^(.+)_dark(\..+)$")
	for (i=0; i<imgs.length; i++) {
		s = imgs[i].src
		if (reDarkCheck.test(s)) {
			imgs[i].src = s.replace(reDarkCheck,"$1$2")
		}
	}	
}
