if (document.layers) var doc = 'document.', vis = '.visibility', left = '.left', top = '.top', zed = '.zIndex';
if (document.all) var doc = 'document.all.', vis = '.style.visibility', left = '.style.pixelLeft', top = '.style.pixelTop', zed = '.style.zIndex';
window.onerror=null;				// CHECKS TO SEE WHICH BROWSER VERSION
var netsgood = 0; 
var goodIE = 0;
browserName = navigator.appName.substring(0,8);
browserVer = parseFloat(navigator.appVersion);
//if (browserName == "Netscape" && browserVer>=4.5 && browserVer<5) { netsgood = 1; }
if (browserName == "Netscape" && browserVer>=4.5 && browserVer<5) { netsgood = 1; }
if (browserName == "Microsof" && browserVer>=4.0) { goodIE = 1; }
if (!(netsgood||goodIE)) document.location = '/eb/messages/probbrowser.shtml';
dom=(document.getElementById) ? true : false;	// MORE SNIFFING!
ie=(document.all) ? true : false;
nn=(document.layers) ? true : false;
ie4=ie && !dom;
mac=(navigator.appVersion.indexOf("Mac") != -1);
ie4mac=ie4 && mac;
ie5mac=dom && mac;
ie5=dom && ie;
nnmac=nn && mac;
iemac=ie && mac;
if (document.layers) {	
    var origWidth = innerWidth;		// vars for nn4 resize bug workaround
    var origHeight = innerHeight;
}
function reDo() {	// fixes nn resize bug - alternative to do onResize=Reload
	if (nn) {
		if (innerWidth != origWidth || innerHeight != origHeight) location.reload();
	} else {
		location.reload();
	}
}
function swap(img,isrc) {	// ROLLOVER FUNCTION
	document.images[img].src = isrc;
}
function swap2(img,isrc,layerName) {			// rollover function to cope with NN layers
	if ((document.all) || (layerName == '')) {		// if IE or no layers'
		document.images[img].src = isrc;
	} else {										// else NS with layers
		var swapThis = 'document.' + layerName + '.document.images["' + img + '"].src = "' + isrc + '"';
		eval(swapThis);
	}
}
function statusText(text){	// DO CONDITIONAL FOR FOLLowING - ONE FOR PC IE/NN, ONE FOR MAC IE (& nn??)
	if (mac && ie) window.status=text;						// this works for MAC IE (sometimes)
	window.setTimeout('window.status="' + text + '"', 1); 	// timeout allegedly fixes IE5 bug (?) - this works for nn (mac and pc) and iepc
	return true;
}
openWins = new Array();
curWin = 0;
moreWins = new Array();
curMWin = 0;
wibWins = new Array();
//alert(wibWins.length);
curWWin = -1;
lastWWin = 0;
function newWinOpen(childWin,url,windowName,width,height,directories,location,menubar,scrollbars,toolbar,resizable,positionX,positionY) {
	if (!positionX) {	// this statement makes central opening the default
		positionX = width/2;
		positionY = screen.height/5;	// reduce this, or do a more sophisticted calculation based on window height??
	} 	// ARE SCREEN.HEIGHT/WIDTH THE RIGHT THINGS TO USE? - not ideally - will be central to screen rather than window, but OK-ish
	var relativeX = (screen.width/2) - positionX;	// half screen width less passed value
	var features =
		'width=' + width +
		',height=' + height +
		',directories=' + directories +
		',location=' + location +
		',menubar=' + menubar +
		',scrollbars=' + scrollbars +
		',toolbar=' + toolbar +
		',resizable=' + resizable +
		',screenX=' + relativeX +
		',screenY=' + positionY +
		',left=' + relativeX +
		',top=' + positionY;
	if (childWin == 1) {
		openWins[curWin++] = window.open(url,windowName,features);
		openWins[openWins.length - 1].focus();	// SHOULD THIS BE -1 OR JUST LENGTH??
	} else if (childWin == 2){
	
    		
    		
    		lastWWin = curWWin;	// note previously opened window

			wibWins[curWWin + 1] = window.open(url,windowName,features);
			//wibWins[wibWins.length - 1].focus();	// SHOULD THIS BE -1 OR JUST LENGTH??
			curWWin = curWWin + 1;	// increment variable
			//alert(wibWins.length);
			if ((wibWins.length>1) && (!document.wibWinForm.multWins.checked)) wibWins[lastWWin].close();	// close previous window

	} else {
		moreWins[curMWin++] = window.open(url,windowName,features);	
		moreWins[moreWins.length - 1].focus();
	}
}
function closeChildWins() {	// can probably remove the < && !openWins[i].closed > from second if/else clause
	for(i=0; i<wibWins.length; i++) {	// close WIB windows (over-ride irrelevant)
		if (wibWins[i] && !wibWins[i].closed) {
			wibWins[i].close();			
		}
	}	
	for(i=0; i<openWins.length; i++) {	// close other windows
		if (openWins[i] && !openWins[i].closed) {	// this goes here to prevent "callee (server)" error if window already closed
			if (!openWins[i].document.forms['autoCloseForm']) {	// if window has NO autocloser...
				openWins[i].close();
			} else {					// else if autocloser...
				if (!openWins[i].document.forms[0].override.checked) openWins[i].close();
			}
		}
	}
}
function formReset(theForm,theImg) {
	eval('document.' + theForm + '.reset()');
	if (theImg != '') {
		swap(theImg,'/eb/graphics/space.gif');
		setTimeout("swap('" + theImg + "','/eb/graphics/space.gif')",200);		// otherwise doesn't always work - something to do with the transparency
	}
}
function glossary(term){
	if (netsgood||goodIE){
		if (term != "") {
			var glosshref = "/eb/glossary.shtml?popup=1#" + term;
			newWinOpen(1,glosshref,'glossaryPopupWin',400,100,0,0,0,1,0,0,200,20);
		} else {
			var glosshref = "/eb/glossary.shtml?popup=0";
			newWinOpen(0,glosshref,'glossaryWin',400,500,0,0,0,1,0,0,200,20);
		}
	}
}
function glossStatus(term) {
	window.setTimeout('window.status="Look up \'' + term + '\'' + '"', 1); // timeout fixes IE5 bug (apparently)
	return true;
}
var currentButton = 'undefined';			// keep track of currently depressed button
function buttonOver(button,msg,layerName) {
	statusText(msg);
	if (currentButton != button) {
		swap2(button + 'Img','/eb/buttons/' + button + '2.gif',layerName);
	}
}
function buttonDown(button,msg,layerName,arrayPos) {
	statusText(msg);
	if (currentButton != button) {
		swap2(button + 'Img','/eb/buttons/' + button + '3.gif',layerName);
	}
}
// Use this instead of the buttonClick function for buttons which do not need to 'toggle'
function buttonUp(button,msg,layerName,arrayPos) {
	statusText(msg);
	if (currentButton != button) {	// need this??
		swap2(button + 'Img','/eb/buttons/' + button + '2.gif',layerName);
	}
}
function buttonOut(button,msg,layerName) {
	statusText(msg);
	//alert(currentButton);
	if (currentButton != button) {
		swap2(button + 'Img','/eb/buttons/' + button + '1.gif',layerName);
	}
}
function buttonClick(button,msg,layerName,arrayPos) {
	statusText(msg);
	if (currentButton != button) {							// need this to prevent toggle-style on/off operation
		swap2(button + 'Img','/eb/buttons/' + button + '3.gif',layerName);
		if (currentButton != 'undefined') {
			swap2(currentButton + 'Img','/eb/buttons/' + currentButton + '1.gif',layerName);
		}
	}
	currentButton = button;
}