/* WB.JS
   Browser detection and size utilities.

    Version Information:
     20010426a = Initial production release.
	 20020520a = Redefined browser type identification to support Netscape 6, Netscape 4.7 and Internet Explorer 5 & 6.
	 20020523a = Re-added isIE and isNS for compatibility with other scripts.
	 20020530a = Modified the get size function due to Netscape 4.7 error.
	 20021122a = Added additional options to winSize.

Copyright 2001, Land Information Access Association
*/

/* Initialize Variables */
var styleObj;
var conHide, conShow;
var winX, winY;
var isIE = 0;
var isNS = 0;

/* Get Browser Name and Version */
var browName = (navigator.appName);
var browVer = parseFloat(navigator.appVersion);
switch (browName) {
	case 'Microsoft Internet Explorer':
		isIE = 1;
	break
	case 'Netscape':
		isNS = 1;
	break
}
//alert(browName + browVer);

/* Assign Variables Based on Browser Capability */
function getStyleObj() {
	if (document.layers) {
		styleObj = 'document.~name~';
		conHide = 'hide';
		conShow = 'show';
	} else if (document.all) {
		styleObj = 'document.all.~name~.style';
		conHide = 'hidden';
		conShow = 'visible';
	} else if (document.getElementById) {
		styleObj = 'document.getElementById("~name~").style';
		conHide = 'hidden';
		conShow = 'visible';
	}
}

/* Get Window Size */
function getSize() {
	if (window.innerWidth) {
		winX = window.innerWidth;
		winY = window.innerHeight;
	} else if (document.body.clientWidth) {
		winX = document.body.clientWidth;
		winY = document.body.clientHeight;
	}
}

function showSize() {
	getSize();
	document.writeln("<input type='hidden' name='Width' value='" + winX + "'>");
	document.writeln("<input type='hidden' name='Height' value='" + winY + "'>");
	//var messAge = "Browser: " + browName + " " + browVer + ", Width: " + winX + ", Height: " + winY;
	//alert(messAge);
}

/* Get Window Size */
function winSize(getParent){
	//Use Parent Frame
	if (getParent == 1) {
		if (document.body.clientWidth) {
			winX = parent.document.body.clientWidth;
			winY = parent.document.body.clientHeight;
		}else if (isNS){
			winX = parent.window.innerWidth;
			winY = parent.window.innerHeight;
		}
	//Use Opener
	} else if (getParent == 2) {
		if (document.body.clientWidth) {
			winX = opener.document.body.clientWidth;
			winY = opener.document.body.clientHeight;
		}else if (isNS){
			winX = opener.innerWidth;
			winY = opener.innerHeight;
		}
	//Get maximum window size
	} else if (getParent == 3) {
		winX = screen.availWidth;
		winY = screen.availHeight;
	//Get current window size
	} else {
		getSize();
	}
	//var messAge = "Browser: " + browName + " " + browVer + ", Width: " + winX + ", Height: " + winY;
	//alert(messAge);
}

function toggleText(spanName, howTo) {
	getStyleObj();
	var theSpan = eval(styleObj.replace("~name~",spanName));
	if (theSpan) {
		var whatVis = theSpan.visibility
		//alert(whatVis);
		if (howTo == 0) {
			theSpan.visibility = conHide;
		} else if (howTo == 1) {
			theSpan.visibility = conShow;
		} else if (whatVis == conShow || whatVis == "" || whatVis == "inherit") {
			theSpan.visibility = conHide;
		} else {
			theSpan.visibility = conShow;
		}
	}
}