﻿var docIsLoaded=false;
var alreadyWide=false;
var baseCSS=0;
var wideCSS=0;
var normalFixupCSS=0;
var wideFixupCSS=0;
var ssCount=0;
var ssName="";

function doFixUp() {
var i;
	try{
		if (!docIsLoaded) {										// one-time initialization stuff
			ssCount=document.styleSheets.length;
			for (i=0; i<ssCount; i++) {							// enumerate stylesheets for symbolic reference
				ssName=document.styleSheets[i].title;			// dig out CSS title
				if (ssName=="normal") baseCSS=i;				// set if "normal" CSS
				if (ssName=="wide") wideCSS=i;					// set if "wide" CSS
				if (ssName=="normalFixup") normalFixupCSS=i;	// set if "normalFixup" CSS
				if (ssName=="wideFixup") wideFixupCSS=i;		// set if "wideFixup" CSS
				};
			if (!wideCSS) {
				alert("Error: style sheet name error or missing style sheet");
				}
			document.body.onresize=doFixUp;						// set this as resize handler
			};
			
		var isWide=(document.body.clientWidth>=1100);			// determine if screen is wide
		if (docIsLoaded && (isWide==alreadyWide)) return;		// no change in width required

		var el=document.getElementById("pageFrame").style;		// blank screen while diddling with styles
		el.visibility="hidden";
		document.styleSheets[wideCSS].disabled=true;			// disable wide format (normal format always on)
		var fixUpInPlay=(normalFixupCSS+wideFixupCSS>0)			// determine if ie6/7 kludge in play
		if (fixUpInPlay){
			document.styleSheets[wideFixupCSS].disabled=true;	// disable wide fixup
			document.styleSheets[normalFixupCSS].disabled=false;// enable normal fixup
			};

		if (isWide){ 											// switch to wide window?
			document.styleSheets[wideCSS].disabled=false;		// yes, enable wide format
			if (fixUpInPlay) {									// fixup required?
				document.styleSheets[wideFixupCSS].disabled=false;	// enable wide fixup
				document.styleSheets[normalFixupCSS].disabled=true;	// disable normal fixup
				};
			};

		alreadyWide=isWide;										// capture state
		el.visibility="visible";								// render screen
		}
	catch(E){
		}	
	}
		




