//=============================================
//=== Gets browser and platform information ===
//=============================================
function Is() {
    var agent = navigator.userAgent.toLowerCase();
		this.major = parseInt(navigator.appVersion);
    this.NN  = ((agent.indexOf('mozilla')!= -1) && ((agent.indexOf('spoofer')==-1) && (agent.indexOf('compatible') == -1)));
    this.IE   = (agent.indexOf("msie") != -1);
    this.WIN = (agent.indexOf("win") != -1);
    this.IE5 = (this.IE && (agent.indexOf('5') != -1));
}


//===================================================
//=== Initializes stuff, depending on the browser ===
//===================================================
var is = new Is();
var firstInd = null;
var pre = new Image();
pre.src = "images/sm_arrow_down.gif";
isExpanded = true;
var theTitle = "Using ArcIMS 9.2"; //Book title

function findBannerHeight()
{
	var theBanner = document.getElementById("nsbanner");
	var theText = document.getElementById("nstext");
	var oBody = document.getElementById("theBody");
	oBody.style.paddingTop = theBanner.offsetHeight;
	theBanner.style.height = theBanner.offsetHeight;
	try{theText.setActive();} //allows scrolling from keyboard as soon as page is loaded. Only works in IE 5.5 and above.
	catch(e){}
}

function initIt() {
		divColl = document.getElementsByTagName("DIV");
		for (i=0; i<divColl.length; i++) {
			currentDiv = divColl[i];
			if (currentDiv.className.indexOf("subc") != -1) {
				if (!isExpanded)
					currentDiv.style.display = "none";
			}
			
			if (currentDiv.id.indexOf("how") == -1) {
				if (!isExpanded && currentDiv.className.indexOf("subh") != -1)
						currentDiv.style.display = "none";
			} else if (currentDiv.className.indexOf("subh") != -1) {
				if (!isExpanded)
					currentDiv.style.display = "none";
				}
		}
}


function expandIt(div) {
	if (div.indexOf("Sub") != -1) {
		whichDiv = document.getElementById(div + "Content");
		whichIm = document.getElementById(div).getElementsByTagName('img')['imEx'];
			if (whichDiv.style["display"] == "none") {
				whichDiv.style["display"] = "block";
				whichIm.src = "images/sm_arrow_down.gif";
			} else {
				whichDiv.style["display"] = "none";
				whichIm.src = "images/small_arrow_up.gif";
			}
		}
	else { // div has sub divs.  Expand/collapse them too.
		whichIm = document.getElementById(div).getElementsByTagName('img')['imEx'];
		if (whichIm.src.indexOf("down") != -1){
				whichIm.src = "images/arrow_up.gif";
		} else {
				whichIm.src = "images/arrow_down.gif";
		}

		var subDivsArray = new Array();
		divColl = document.getElementsByTagName("DIV");		
		for (i=0; i<divColl.length; i++) {
			if (divColl[i].id != null) {
				if (divColl[i].id.indexOf(div) != -1) {
						subDivsArray.push(divColl[i]);
				}
			}
		}
		
		for (i=0; i<subDivsArray.length; i++) {
			whichDiv = subDivsArray[i];

			if ((whichDiv.id.indexOf(div + "Sub") != -1) && (whichDiv.id.indexOf("Content") == -1)) {
				if (whichDiv.style.display == "none") {
					whichDiv.style.display= "block";
				} else {
					whichDiv.style.display = "none";
					if (whichDiv.id.indexOf("Text") == -1) {
						whichOtherIm = document.getElementById(whichDiv.id).getElementsByTagName('img')['imEx'];
						whichOtherIm.src = "images/small_arrow_up.gif";
					}
				}
			} else if ((whichDiv.id.indexOf(div + "Sub") != -1) && (whichDiv.id.indexOf("Content") != -1)) {
					whichDiv.style.display = "none";
			}
		}			
	}
}

function expandAll() {
	newExpSrc = (isExpanded) ? "images/expand.gif" : "images/collapse.gif";
	arrowSrc = (isExpanded) ? "images/arrow_down.gif" : "images/arrow_up.gif";
	smallArrowSrc = (isExpanded) ? "images/small_arrow_up.gif" : "images/sm_arrow_down.gif";

	parentExists = 0;
	document.getElementById('imgExpColl').src = newExpSrc;
	
	divColl = document.getElementsByTagName("DIV");
	for (i=0; i<divColl.length; i++) {
		whichDiv = divColl[i];
		
		if (whichDiv.id.indexOf("Sub") == -1) {
			if (whichDiv.getElementsByTagName('img')['imEx']) {
				whichDiv.getElementsByTagName('img')['imEx'].src = arrowSrc;
				parentExists++;
			}
		}
		
		if (whichDiv.id.indexOf("Sub") != -1 && (whichDiv.id.indexOf("Content") == -1)) {
			if (whichDiv.id.indexOf("Text") == -1) {
				whichDiv.getElementsByTagName('img')['imEx'].src = smallArrowSrc;
			}
			if (parentExists > 0) {
				whichDiv.style.display = (isExpanded) ? "none" : "block";
			}
		}
		
		if (whichDiv.id.indexOf("Content") != -1) {
			whichDiv.style.display = (isExpanded) ? "none" : "block";
		}
	}
	isExpanded = !isExpanded;
}
