// function library for changing broswer 
// css settings 
// ##################################### 
// Coded by ACN for AHC 04/03/2003 
// Last Updated by ACN on 18/03/2003 
// Supports IE456 NS6/7 MOZ1.4 NA: ns4.x 
// Does not work in opera, but is handled 
// ##################################### 

// RUN FROM HERE [START AUTO EXECUTED CODE] ================

// load current access mode status for the active session 
var accessMode = getCookie("PRAAccessStatus");

// if no cookie preset, default style sheet mode is normal.
if (accessMode == null) {
	acessMode = "normal";
}

// Check value in cookie
if (accessMode == "access"){
	setCSS(true)  // disable style sheets  (set disabled to true)
}
else {

	setCSS(false) // enable style sheets (set disabled to false)
}


// END AUTO EXECUTED CODE ================================


// whatever the status of the style sheet, invert it.
function toggleCSS(){

	// Handle early broswers
	if (!document.getElementById) {
	alert ("Your browser cannot toggle the accessibility mode. \n\n"+
			"It can only render the content in the current form. \n"+
			"For richer content please upgrade your browser.")
		return;
	}
	
	// Handle Opera broswers
	if(navigator.appName.indexOf("Opera") != -1) {
		alert ("Opera cannot support modification of Stylesheets via script.  \n\n"+
		        "Please use the style options on the view menu instead, \n" +
				"select User Mode or Author Mode")
		return;	
	}

	// ensure that the DOM of the non opera browser 
	// can cope with script to stylesheet modifications
	if (document.styleSheets) {

		// start at SECOND sheet
		// THIS IS VERY IMPORTANT to ensure that styles that are required 
		// in the access version are preserved.
		var currentSheet=1;
		if(document.styleSheets.length>0 && document.styleSheets){
			
			// invert enabled status 
			// - currentSheet indicative of all sheet's status
			cs=!document.styleSheets[currentSheet].disabled;
			
			// store current status
			if (cs == false){ accessMode = "normal"} else {accessMode = "access" }
			setCookie('PRAAccessStatus', accessMode, explongyear);

			//loop through all sheets applying inverted enabled status.
			for(currentSheet; currentSheet < document.styleSheets.length;currentSheet++) {
				 document.styleSheets[currentSheet].disabled=cs;
			} // End loop
			
		}
	}
} // End toggleCSS


// set CSS status
// status - boolean true = disable, false = enabled
function setCSS(status){

	// Handle early broswers
	if (!document.getElementById) {
		return;
	}
	// Handle Opera broswers
	if(navigator.appName.indexOf("Opera") != -1) {
		return;	
	}

	// ensure that the DOM of the non opera browser 
	// can cope with script to stylesheet modifications
	if (document.styleSheets) {
		//  start at SECOND sheet
		//  THIS IS VERY IMPORTANT to ensure that styles that are required 
		//  in the access version are preserved.
		var currentSheet=1;
		if(document.styleSheets.length>0 && document.styleSheets){
			if (status == false){ 
				accessMode = "normal"
			} 
			else {
				accessMode = "access"
			}
			setCookie('PRAAccessStatus', accessMode, explongyear)
			//loop through all sheets applying status.
			for(currentSheet; currentSheet < document.styleSheets.length;currentSheet++) {
				 document.styleSheets[currentSheet].disabled=status;
			}
		}
	}
} // End setCSS

// Netscape Opera and Mozilla window resize fix. ================

if(!window.saveInnerWidth) {

  window.onresize = resizeWindow;
  window.saveInnerWidth = window.innerWidth;
  window.saveInnerHeight = window.innerHeight;
} 

function resizeWindow() {
    if (saveInnerWidth < window.innerWidth || 
        saveInnerWidth > window.innerWidth || 
        saveInnerHeight > window.innerHeight || 
        saveInnerHeight < window.innerHeight ) 
		{
		// refresh this window
        window.history.go(0);
    }
} // End resizeWindow

//EOF cssFunctions.js

