/***********************************************************************\
*                      EXTERNAL EXPANDO SECTIONS                        *
\***********************************************************************/

function createExpandoFrameObject ( divObj, filename ) {
	this.FrameName = expando_getFrameName( top.GLOBALFRAMES.Expandos++ );
	this.File = filename;
	this.DivObj = divObj;
	this.IFrameObj = null;
	this.Loading = false;
	this.Loaded = false;
}

// ------------------------------------------------------------------- \\
// -----            "ON-LOAD" AND "ON-CHILD-LOAD" CODE           ----- \\

function expando_doStartup() {
	if (parent && parent != self) {
		document.body.style.margin = top.GLOBALFRAMES.ExpandoMargin;
		document.body.style.padding = top.GLOBALFRAMES.ExpandoPadding;
	}

	if (parent && parent != self && parent.expando_childLoaded ) {
		parent.expando_childLoaded( self.name );
	}

	if (!parent || parent == self) {
		// ----- Only the top window gets resized by humans
		window.onresize = expando_onresizeBrowser;
	} else {
		// window.onresize = expando_onresizeFrame;	// empty function now
		// ----- check if we're in an ordered list
		var framething = top.GLOBALFRAMES.Expando[self.name];
		if (framething && framething.DivObj) {
			var tobj = framething.DivObj;
			while ( tobj.parentNode && tobj.nodeName != "OL") { tobj = tobj.parentNode; }
			if ( tobj.nodeName == "OL" ) {
				var oltype = getNextOrderedListStyle( tobj );


			}
		}
	}
}


function getNextOrderedListStyle ( obj ) {
	var listings = new Array();
	listings[0] = "decimal";
	listings[1] = "lower-alpha";
	listings[2] = "lower-roman";
	listings[3] = "upper-alpha";
	listings[4] = "upper-roman";
	var idx = 0;

	//----- test for list style information of any kind ----- \\
	var oltype = "decimal";								// default
	if (obj.style.listStyleType)	{ oltype = obj.style.listStyleType; }		// in-line style
	if (obj.type)			{ oltype = obj.type; }				// HTML attribute

	switch (oltype) {
	case "1":	case "decimal":
		idx = 0;
		break;
	case "a":	case "lower-alpha":	case "lower-latin":
		idx = 1;
		break;
	case "i":	case "lower-roman":
		idx = 2;
		break;
	case "A":	case "upper-alpha":	case "upper-latin":
		idx = 3;
		break;
	case "I":	case "upper-roman":
		idx = 4;
		break;
	default:
		idx = 0;
	}

	idx++;
	if (idx > 4) { idx = 0; }

	return listings[idx];
}


function expando_childLoaded ( frameName ) {
	if ( frameName ) {
		var framething = top.GLOBALFRAMES.Expando[frameName];
		var divObj = framething.DivObj;
		window.clearTimeout(divObj.externalWatchID);

		expando_resizeExternalChildFrame( frameName );
		framething.Loading = false;
		framething.Loaded = true;

		if (divObj.firstChild.nodeName == "#text") {
			// ----- "Loading" message; remove
			divObj.removeChild( divObj.firstChild );
		}
	}
}


function expando_isAllLoaded() {
	for ( var n=1; n <= top.GLOBALFRAMES.Expandos; n++ ) {
		var framenom = expando_getFrameName(n);
		var framething = top.GLOBALFRAMES.Expando[framenom];
		if (framething && framething.Loading) {
			return false;
		}
	}
	return true;
}


// ------------------------------------------------------------------- \\
// -----              TURN LINKS INTO EXPANDO LINKS              ----- \\

function makeExpandoLink ( linkObj, divID ) {
	var tDivObj = expando_findExpandoDiv( linkObj, divID );

	// -----  If there's no valid target zone for this link,       ----- \\
	// -----  then we don't activate the href, and it's just text. ----- \\
	if (tDivObj) {

		// ----- is there a specific icon= being asked for? ----- \\
		var tMyIcon = linkObj.getAttribute( "icon" );
		if ( !tMyIcon || !EXPANDO_GRAPHICS.Color[tMyIcon] ) {
			tMyIcon = EXPANDO_GRAPHICS.Default;
		}
		if (tMyIcon) tMyIcon = tMyIcon.toLowerCase();

		// ----- does it default to open or closed? ----- \\
		var tStartOpen = false;
		if ( linkObj.getAttribute("open") != null ) {				// ----- HTML, transitional
			tStartOpen = true;
		}
		var tSwitch = linkObj.getAttribute( "type" ).toLowerCase();		// ----- XHTML, strict
		if ( tSwitch == "open" || tSwitch == "static" ) {
			tStartOpen = true;
		}

		// ----- also force open if it's the bookmark target ----- \\
		if ( linkObj.name ) {
			tStartOpen = (linkObj.name.toUpperCase() == getBookmark().toUpperCase() );
		}

		// ----- set up custom attributes for Anchor and DIV ----- \\
		linkObj.divObj = tDivObj;
		linkObj.startOpen = tStartOpen;
		linkObj.iconColor = tMyIcon;
		linkObj.unloadedFileList = new Array();

		linkObj.divObj.linkObj = linkObj;
		linkObj.divObj.startOpen = tStartOpen;
		linkObj.divObj.external = false;


		// ----- prepare the DIV ----- \\
		if ( !expando_divPrep( tDivObj ) ) {
			return;
		}


		// ----- avoid IE 5.5 redraw bug when sections are auto-open ----- \\
		if ( tStartOpen && tDivObj.ie55 ) {
			return;
		}


		if ( tSwitch != "static" ) {
			// ----- add open/close graphic to link and set color ----- \\
			var imgObj = document.createElement("IMG");
			var iconObj = EXPANDO_GRAPHICS.Color[linkObj.iconColor];
			imgObj.src = (tStartOpen) ? iconObj.Close.src : iconObj.Open.src;
			// crop if too large (= graphic is missing, usually)
			if (imgObj.width > 16 || imgObj.width == 0) { imgObj.width = 12; imgObj.height = 12; }
			imgObj.border = 0;
			imgObj.style.marginRight = 4;
			imgObj.style.marginBottom = 2;
			linkObj.insertBefore( imgObj, linkObj.firstChild );
			linkObj.style.color = "#000099";

			// ----- activate the link ----- \\
			linkObj.href = "javascript:nothing()";
			linkObj.onclick = expandoText;
			linkObj.onmouseover = expandoMouseOver;
			linkObj.onmouseout = expandoMouseOut;

		} else {
			// Static Expando - cluk
			// remove the border width of the expando
			  tDivObj.style.borderWidth = 0;
		}
	}
}

function makeMultiExpandoLink ( linkObj, divBaseID ) {
	// ----- works like radio buttons do: if the generic divBaseID = "block", then
	// ----- each actual <DIV ID=""> would be "block(1)", "block(2)", etc.
	// ----- multiExpandos require an explicit ID in the DIV; no anonymous blocks.

	if (!(window.EXPANDO_MULTILINKS[divBaseID])) { EXPANDO_MULTILINKS[divBaseID] = 0; }
	var tID = ++EXPANDO_MULTILINKS[divBaseID];

	var tDivObj = document.getElementById( divBaseID+"("+tID+")" );

	// -----  If there's no valid target zone for this link,       ----- \\
	// -----  then we don't activate the href, and it's just text. ----- \\
	if (tDivObj) {

		// ----- does it default to open or closed? ----- \\
		var tStartOpen = false;
		if ( linkObj.getAttribute("open") != null ) {		// ----- HTML, transitional
			tStartOpen = true;
		}
		var tSwitch = linkObj.getAttribute( "type" );		// ----- XHTML, strict
		if ( tSwitch.toLowerCase() == "open" ) {
			tStartOpen = true;
		}
		// ----- also force open if it's the bookmark target ----- \\
		if ( linkObj.name ) {
			tStartOpen = (linkObj.name.toUpperCase() == getBookmark().toUpperCase() );
		}

		// ----- set up custom attributes for Anchor and DIV ----- \\
		linkObj.divObj = tDivObj;
		linkObj.startOpen = tStartOpen;
		linkObj.unloadedFileList = new Array();
		linkObj.divBase = divBaseID;
		linkObj.divIndex = tID;

		linkObj.divObj.linkObj = linkObj;
		linkObj.divObj.startOpen = tStartOpen;
		linkObj.divObj.external = false;


		// ----- prepare the DIV ----- \\
		if ( !expando_divPrep( tDivObj ) ) {
			return;
		}

		// ----- add radio button to link and set color ----- \\
		var rkoObj = document.createElement("INPUT");
		rkoObj.type = "radio";
		rkoObj.name = divBaseID;
		rkoObj.id = "_"+divBaseID+"_"+tID;
		linkObj.insertBefore( rkoObj, linkObj.firstChild );
		linkObj.style.color = "#000099";

		// ----- activate the link ----- \\
		linkObj.href = "javascript:nothing()";
		linkObj.onclick = multiExpandoText;
	}
}

function makeIncludoBlock( divObj ) {
	divObj.startOpen = true;
	expando_divPrep ( divObj );
}

// ------------------------------------------------------------------- \\

function expando_divPrep ( divObj ) {

	tFile = divObj.getAttribute("file");

	if (tFile) {
		// ----- need to set up an iframe container for the external file ----- \\
		if ( !expando_createExternalFrame( divObj, tFile ) ) {
			// ----- failure; hide DIV (in case it's visible now)
			divObj.style.display = "none";
			return false;
		}

		if ( divObj.startOpen ) {
			if ( !expando_attachToDisplayParent( divObj ) ) {
				// ----- there was no hidden parent to attach to, ergo ----- \\
				// ----- this segment is currently displayed; load it! ----- \\
				expando_loadExternalFiles( divObj );
				trackExpandoUsage( "AUTO", divObj.externalFile );
			}
		}
		
		divObj.external = true;
	}
		
	if ( divObj.startOpen ) {
		// ----- Start this expando block open ----- \\
		divObj.style.display = (divObj.nodeName == "SPAN") ? "inline" : "block";
	} else {
		divObj.style.display = "none";
	}
		
	return true;
}

function expando_findExpandoDiv ( anchorTag, divID ) {
	// ----- If there's a "divID", then find that DIV ID. Otherwise,  ----- \\
	// ----- search forward in the DOM for the next valid target tag. ----- \\
	// ----- Valid:  DIV/SPAN tag or LI tag with "expando" class      ----- \\
	var divTag = null;

	if (divID) {
		divTag = document.getElementById(divID);
	} else {
		var tgs = document.getElementsByTagName("*");
		// ----- accomodate IE 5.5 ----- \\
		if ( tgs.length == 0 ) {
			if ( document.all ) {
				tgs = document.all;
			}
		}
		// ----------------------------- //
		var postAnchor = false;
		for ( var j=0; j<tgs.length; j++ ) {
			var thisObj = tgs[j];
			if (!postAnchor) {
				if (thisObj == anchorTag) {
					postAnchor = true;
				}
			} else {
				if ( (thisObj.tagName == "DIV" || thisObj.tagName == "SPAN" || thisObj.tagName == "LI") &&
				     (thisObj.className.toLowerCase() == "expando" ||
				      thisObj.className.toLowerCase().substring(0,8) == "expando_") ) {
					divTag = thisObj;
					break;
				}
			}
		}
	}

	return divTag;
}


// ------------------------------------------------------------------- \\
// -----       "ONCLICK" OPERATING CODE FOR EXPANDO EVENTS       ----- \\


function expandoText(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;
	var divObj = anchor.divObj;
	var subList = anchor.unloadedFileList;


	if (divObj) {

		if ( ( divObj.externalFile && !divObj.externalLoaded ) || anchor.unloadedFileList.length > 0 ) {
			// ----- need to load external files ----- \\
			expando_loadExternalFiles( divObj );
		}

		// ----- Find the open/close image in the link, if there is one  ----- \\
		tPicObj = "";
		for ( j=0; j < anchor.childNodes.length; j++ ) {
			if (anchor.childNodes[j].tagName == "IMG") {
				var tAnchor = unescape(anchor.childNodes[j].src);
				if ( ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].Open.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].Close.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src) )
				  || ( tAnchor == unescape(EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src) )
				) {
					tPicObj = anchor.childNodes[j];
					break;
				}
			}
		}
		// ----- Use the .style.display property to determine open/closed status    ----- \\
		// ----- It must be set explicitly by the setup code; it defaults to blank. ----- \\
		tShowMode = (divObj.nodeName == "SPAN") ? "inline" : "block";
		if (divObj.style.display == "none") {
			divObj.style.display = tShowMode;
			if (tPicObj) {
				tPicObj.src = EXPANDO_GRAPHICS.Color[iconColor].Close.src;
			}
		} else if (divObj.style.display == tShowMode) {
			divObj.style.display = "none";
			if (tPicObj) {
				tPicObj.src = EXPANDO_GRAPHICS.Color[iconColor].Open.src;
			}
		}

		// ----- need to roll up existing parental expandos.
		expando_nestedFramesResize ( divObj );
	}
}


function multiExpandoText(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var tDivBase = anchor.divBase;
	var tDivIndex = anchor.divIndex;

	// ----- change the state of every DIV in the radio button array
	for (var i=1; i <= EXPANDO_MULTILINKS[tDivBase]; i++) {
		var tRadioButton = document.getElementById( "_"+tDivBase+"_" + i );

		var uniqueDivID = tDivBase + "(" + i + ")";
		var tDivObj = document.getElementById(uniqueDivID);

		if (i == tDivIndex) {
			// ----- currently clicked radio button, do actions here ----- \\
			tRadioButton.checked = true;

			if ( ( tDivObj.externalFile && !tDivObj.externalLoaded ) || anchor.unloadedFileList.length > 0 ) {
				// ----- need to load external files ----- \\
				expando_loadExternalFiles( tDivObj );
			}

			// ----- this is the selected DIV (or SPAN); make visible ----- \\
			var tShowMode = (tDivObj.nodeName == "SPAN") ? "inline" : "block";
			tDivObj.style.display = tShowMode;
		} else {
			// ----- clean up other, non-active radio buttons ----- \\
			tRadioButton.checked = false;
			tDivObj.style.display = "none";
		}

		// ----- need to resize parent frames, if any ----- \\
		expando_nestedFramesResize( tDivObj );
	}
}


function expandoMouseOver(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;

	// ----- Find the open/close image in the link, if there is one  ----- \\
	tPicObj = "";
	for ( j=0; j < anchor.childNodes.length; j++ ) {
		var imgObj = anchor.childNodes[j];
		if (imgObj.tagName == "IMG") {
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].Open.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src;
				break;
			}
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].Close.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src;
				break;
			}
		}
	}
}


function expandoMouseOut(e) {
	if (!e) var e = window.event;

	var anchor = expando_getAnchorObject(e);

	if (anchor == null) return;

	var iconColor = anchor.iconColor;

	// ----- Find the open/close image in the link, if there is one  ----- \\
	tPicObj = "";
	for (j=0; j < anchor.childNodes.length; j++ ) {
		var imgObj = anchor.childNodes[j];
		if (imgObj.tagName == "IMG") {
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].OpenOver.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].Open.src;
				break;
			}
			if ( unescape(imgObj.src) == unescape(EXPANDO_GRAPHICS.Color[iconColor].CloseOver.src) ) {
				imgObj.src = EXPANDO_GRAPHICS.Color[iconColor].Close.src;
				break;
			}
		}
	}
}


function expando_getAnchorObject ( e ) {
	var anchor = null;

	if (e.target) {			// Mozilla
		anchor = e.target;
	}
	if (e.srcElement ) {		// IE
		anchor = e.srcElement;
	}
	if (anchor.nodeType == 3) {	// defeat Safari bug
		anchor = anchor.parentNode;
	}

	// ----- the srcElement could be a subtag of <A> (e.g. an image); ----- \\
	// ----- crawl up the DOM until you reach the actual <A> tag.     ----- \\
	while ( (anchor != null) && (anchor.tagName != "A") ) {
		anchor = anchor.parentNode;
	}
	if (anchor.tagName != "A") { anchor = null; }

	return anchor;
}


// ------------------------------------------------------------------- \\
// -----      CREATE AND MANAGE "EXTERNAL" FILES AS EXPANDOS     ----- \\


function expando_createExternalFrame( divObj, tFile ) {
	// ----- There's an external file referenced by the DIV.   ----- \\
	// ----- Create and size an IFRAME for the included file.  ----- \\
	tFile = tFile.replace(/\\/g, "/");

	// ----- fail to create the expando link if it's a         ----- \\
	// ----- cyclical file reference.                          ----- \\
	if ( !expando_checkCyclical( tFile ) ) {
		return false;
	}

	// ---- store info we need later in global "frames" object  ---- \\
	var tFrmObj = new createExpandoFrameObject( divObj, tFile );
	top.GLOBALFRAMES.Expando[tFrmObj.FrameName] = tFrmObj;


	// ----- erase current contents of DIV ----- \\
	while ( divObj.lastChild ) {
		divObj.removeChild(divObj.lastChild);
	}

	// ----- insert the "Loading..." warning ----- \\
	var tt = document.createTextNode( TEXT["expando_loading"] );
	divObj.appendChild(tt);


	// ----- Note: a link to the <iframe> node is not the same ----- \\
	// ----- as a link to the frame window; which is to say    ----- \\
	// ----- divObj.all(0) != document.frames(tIFName).        ----- \\
	// ----- Which is why the iframe needs both name and ID.   ----- \\

	// ----- create IFRAME object ----- \\
	var iframeObj = document.createElement("IFRAME");
	iframeObj.name = tFrmObj.FrameName;
	iframeObj.id = tFrmObj.FrameName;

	iframeObj.scrolling = "auto";
	iframeObj.style.position = "absolute";
	iframeObj.style.width = 64;
	iframeObj.style.height = 64;
	iframeObj.style.top = -1024;
	iframeObj.style.left = -1024;
	iframeObj.style.display = "block";
	iframeObj.style.border = "0px";		// Mozilla
	iframeObj.frameBorder = 0;		// IE

	divObj.appendChild(iframeObj);

	// ----- add some custom attributes to the DIV ----- \\
	divObj.externalFile = tFile;
	divObj.externalLoaded = false;
	divObj.externalFrame = iframeObj;

	top.GLOBALFRAMES.Expando[tFrmObj.FrameName].IFrameObj = iframeObj;

	return true;
}


function expando_loadExternalFiles ( divObj ) {

	if ( !divObj.externalLoaded ) {
		var tIFrameName = divObj.externalFrame.name;

		if (!window.frames[tIFrameName].name) { window.frames[tIFrameName].name = tIFrameName; }

		top.GLOBALFRAMES.Expando[tIFrameName].Loading = true;
		top.GLOBALFRAMES.Expando[tIFrameName].Loaded = false;
		expando_loadExternalFileNow( window.frames[tIFrameName].location, divObj.externalFile );
		divObj.externalLoaded = true;

		trackExpandoUsage( "XPANDO", divObj.externalFile );

		// ----- set up a timer watch to see if it's loaded. Useful for non-Help   ----- \\
		// ----- target files; proper topics will report themselves as done and    ----- \\
		// ----- terminate the watch. NB: Alien external files can only be leafs.  ----- \\
		divObj.externalWatchID = window.setTimeout("expando_watchLoadState('" + tIFrameName + "')", 2000);
	}

	// ----- if any of the external subfiles aren't loaded yet, do it ----- \\
	subList = divObj.linkObj.unloadedFileList;

	if (subList) {
		for ( var i=0; i < subList.length; i++ ) {
			if ( !subList[i].externalLoaded ) {
				var tIFrameName = subList[i].externalFrame.name;

				top.GLOBALFRAMES.Expando[tIFrameName].Loading = true;
				top.GLOBALFRAMES.Expando[tIFrameName].Loaded = false;
				expando_loadExternalFileNow( window.frames[tIFrameName].location, subList[i].externalFile );

				trackExpandoUsage( "XPANDO", subList[i].externalFile );

				// ----- set up a timer watch to see if it's loaded. Useful for non-Help   ----- \\
				// ----- target files; proper topics will report themselves as done and    ----- \\
				// ----- terminate the watch. NB: Alien external files can only be leafs.  ----- \\
				subList[i].externalWatchID = window.setTimeout("expando_watchLoadState('" + tIFrameName + "')", 2000);
			}
		}
		divObj.linkObj.unloadedFileList = new Array();
	}
}

function expando_loadExternalFileNow ( loc, filename ) {
	var tFile = filename;
	if ( tFile.search(/\w+\.chm\:\:\//i) >= 0 && tFile.search(/ms\-its\:/i) >= 0 ) {
		// "ms-its:" and "CHM" reference
		tFile = tFile.substr( tFile.search(/\w+\.chm\:\:\//i), tFile.length );
		tFile = "ms-its:" + TOPIC_EXTPATH + tFile;
	} else if ( tFile.search(/\w+\.chm\:\:\//i) >= 0 ) {
		// CHM file, but not ms-its:
		tFile = "ms-its:" + TOPIC_EXTPATH + tFile;
	}
	loc.replace( tFile );
}


// ------------------------------------------------------------------- \\
// -----       RESIZING NESTED IFRAMES (EXTERNAL EXPANDOS)       ----- \\


function expando_watchLoadState ( frameName ) {
	var framething = top.GLOBALFRAMES.Expando[frameName];
	var divObj = framething.DivObj;
	// ----- frameName = actual frame name plus GLOBALFRAMES idx key. ----- \\
	var iframeWin = window.frames[frameName];

	var failure = false;
	try {
		if ( iframeWin && iframeWin.document && iframeWin.document.body ) {
			failure = false;
			// ----- non-regulation file has loaded; finish it now.   ----- \\
			expando_childLoaded( frameName );
		} else {
			failure = true;
		}
	}
	catch(e) {
		// ----- If error is "Access is denied"... ----- \\

		if ( e.number == -2147024891 ) {		// IE only
			// this usually means "Page not found" error
			failure = false;
			// access the "Loading..." message and change to "Cannot load"
			if ( divObj && divObj.firstChild && divObj.firstChild.nodeType == 3 ) {
				divObj.firstChild.nodeValue = TEXT["expando_badload"];
			}
		} else {
			failure = true;
		}
	}

	if (failure) {
		// ----- not loaded yet; wait a little bit and try again  ----- \\
		divObj.externalWatchID = window.setTimeout("expando_watchLoadState('" + frameName + "')", 3000);
	}
}


function expando_onresizeBrowser(e) {
	// ----- wait briefly, to eliminate multiple calls from piling on ----- \\
	top.clearTimeout(top.GLOBALFRAMES.WaitingToResize);
	top.GLOBALFRAMES.WaitingToResize = top.setTimeout("expando_onresizeBrowserAction()", 100);
}

function expando_onresizeBrowserAction() {
	// ----- check global counters for external frames that are still ----- \\
	// ----- loading -- no resizing while external files are not yet  ----- \\
	// ----- loaded; otherwise you get onresize looping and a crash.  ----- \\
	if ( !expando_isAllLoaded() ) {
		expando_onresizeBrowser();
	}

	// ----- no frames are still loading; go ahead and resize all    ------ \\
	for (var i=0; i < window.frames.length; i++) {
		var fobj = window.frames[i];
		if ( fobj.location && fobj.location.href != "about:blank" ) {
			expando_doFrameResize( fobj );
			if ( fobj.expando_onresizeBrowser ) {
				// ----- not called automatically by resize event;
				// ----- only attached to top window. Stops event looping.
				fobj.expando_onresizeBrowserAction();
			}
			// ----- first crawl down, resizing; then crawl back up
			expando_doFrameResize( fobj );
		}
	}
}


function expando_onresizeFrame(e) {
}


function expando_resizeExternalChildFrame ( frameName ) {
	// ----- frameName = actual frame name, also GLOBALFRAMES idx key. ----- \\

	var iframeWin = window.frames[frameName];

	expando_doFrameResize( iframeWin );

	// ----- need to resize parent frames, if any ----- \\
	var parentDivObj = top.GLOBALFRAMES.Expando[frameName].DivObj;
	expando_nestedFramesResize( parentDivObj );
}


function expando_nestedFramesResize ( divObj ) {

	// ----- if this is inside an included frame,     ----- \\
	// ----- keep expanding the parent frames to fit. ----- \\
	var tMe = self;
	while ( tMe.name.indexOf("_expando_") >= 0 ) {
		expando_doFrameResize( tMe );
		tMe = tMe.parent;
	}

	if ( !divObj.startOpen ) {
		// ----- this doesn't apply to auto-open links.   ----- \\
		// ----- if we're expanding, and the bottom will  ----- \\
		// ----- go past the bottom of the window, then   ----- \\
		// ----- scroll it up so it's visible.            ----- \\
		if (divObj.style.display == "block") {
			if (divObj.offsetHeight < document.body.clientHeight) {
				// ----- if the expando section is bigger than the window, don't bother ----- \\
				var tZoneBottom = divObj.offsetTop + divObj.offsetHeight;
				var tZoneY = tZoneBottom - document.body.scrollTop;
				if (tZoneY > document.body.clientHeight) {
					window.scrollTo( 0,document.body.scrollTop + (tZoneY - document.body.clientHeight) );
				}
			}
		}
	}
}


function expando_doFrameResize ( frameWindow ) {

	// ----- frameName = actual frame name, also GLOBALFRAMES idx key. ----- \\
	var frameName = frameWindow.name;

	var iframeObj = top.GLOBALFRAMES.Expando[frameName].IFrameObj;

	var parentDivObj = top.GLOBALFRAMES.Expando[frameName].DivObj;

	// ----- turn off IE scrollbars to match FireFox           ----- \\
	frameWindow.document.body.scroll = 'no';

//alert("Resizing "+frameName+", with IFRAME="+iframeObj+" and parentDiv="+parentDivObj+".");

	// ----- find width of parent DIV - it needs to be visible ----- \\
	// ----- in order to report the width correctly            ----- \\
	parentDivObj.style.height = parentDivObj.scrollHeight + "px";
//	iframeObj.style.display = "none";					// take out FRAME for DIV sizing
	var parentDisplay = parentDivObj.style.display;
	if (!parentDisplay) { parentDisplay = "block"; }
	parentDivObj.style.display = "block";
	var maxWidth = parentDivObj.scrollWidth;
	parentDivObj.style.display = parentDisplay;
	iframeObj.style.display = "block";
	parentDivObj.style.height = "";

	maxWidth -= 2;								// account for the DIV border

	var curWidth = frameWindow.document.body.scrollWidth;

	// ----- set width
	iframeObj.style.width = maxWidth;					// all browsers

	if ( curWidth == frameWindow.document.body.scrollWidth ) {
		// ----- In Mozilla/Firefox, in IFRAMES within IFRAMES, width won't change.
		// ----- (IFRAME is lost in space somewhere; can't resize, like it's invisible)
		// ----- need to bring it back here. Means visible flash, unfortunately.
		iframeObj.style.position = "static";
	}

	// ----- set height
	iframeObj.style.height = frameWindow.document.body.scrollHeight;

	// ----- this is the final size; now bring DIV back inline ----- \\
	iframeObj.style.position = "static";

	var xx = top.document.getElementById("x"+frameName);
	if (xx) {
		xx.appendChild( top.document.createTextNode( "["+iframeObj.style.width+","+iframeObj.style.height+"]" ) );
		xx.appendChild( top.document.createElement( "BR" ) );
	}

	if (parentDivObj.scrollWidth && frameWindow.innerWidth && frameWindow.innerWidth > parentDivObj.scrollWidth ) {
		// ----- Mozilla/FireFox has changed the width (added scrollbar); needs fixing
		// ----- call onresizeBrowser to get the timeout and "still loading" checks
// crashes FF.
//		expando_onresizeBrowser();
	}
}


// ------------------------------------------------------------------- \\

function expando_attachToDisplayParent( divObj, originalDivObj ) {
	// ----- search up the document tree to see if a "forced open" section ----- \\
	// ----- has an expando parent that it can be "attached" to, in order  ----- \\
	// ----- to delay loading until user clicks on a link.                 ----- \\
	// ----- Also, don't load if it's conditionally hidden.                ----- \\
	// ----- (This only applies to external expandos under regular ones)   ----- \\

	var foundparent = false;

	if ( !originalDivObj ) {
		// ----- first call to function; divObj = originalDivObj ----- \\
		foundparent = expando_attachToDisplayParent( divObj.parentNode, divObj );
	} else {
		if ( divObj.nodeName != "BODY" ) {
			// ----- is conditional text available? ----- \\
			if (window.validateSKUs) {
				// ----- check for a false conditional, and set "foundparent" to true          ----- \\
				// ----- this link isn't added to any file list, and so it can never display   ----- \\
				var tSKUs = divObj.getAttribute("skus");
				if (tSKUs) {
					foundparent = !validateSKUs(tSKUs);
				}
			}

			// ----- check for an unopened expando, then attach this div to its list ----- \\
			if (  ( divObj.className.toLowerCase() == "expando" ||
				divObj.className.toLowerCase().substring(0,8) == "expando_")
			   ) {
				if ( !divObj.startOpen ) {
					var tFiles = divObj.linkObj.unloadedFileList;
					tFiles[tFiles.length] = originalDivObj;
					foundparent = true;
				}
			}
		}
	}

	return foundparent;
}


function expando_checkCyclical ( filepath ) {
	// ----- Make sure it's not a cyclical reference.          ----- \\
	// ----- walk up the "_expando_" tree and check all src.   ----- \\

	var cyclical = false;
	var tWin = null;
	var tMaster = makeExplicitURL( filepath );

	// ----- want to check every "_expando_" frame, plus one more - the ultimate parent.
	do {
		if (tWin) {
			tWin = tWin.parent;
		} else {
			tWin = self;
		}
		tCurrent = makeExplicitURL( unescape(tWin.location.href) );

		cyclical = cyclical || (tMaster.toLowerCase() == tCurrent.toLowerCase());
	}
	while ( tWin.name.indexOf("_expando_") >= 0 );

	return (!cyclical);
}


function trackExpandoUsage ( pCode, pURL ) {
	var submitted = false;
	if ( top.Persistent ) {
		if ( top.Persistent.saveDataLine ) {
			top.Persistent.saveDataLine ( pCode, pURL, "" );
			submitted = true;
		}
	}
	return submitted;
}


// ------------------------------------------------------------------- \\
// -----                     COMMON ROUTINES                     ----- \\

function nothing() {
}


function expando_getFrameName ( n ) {
	return "_expando_" + n;
}


function getBookmark() {
	// ----- In IE7 beta 2 in a CHM, location.hash doesn't return anything.
	return document.location.href.replace(/^[^#]*\#(\w+)/,"#$1");
}


function makeExplicitURL ( old ) {

	var url = old.replace( /\\/g, "/" );

	if ( old.indexOf(".chm::/") < 0 && old.indexOf("://") < 0 ) {
		// ----- only build a full URL if it's not already explicit

		var cur = unescape(document.location.href).replace( /\\/g, "/" );	// ----- where am I now?
		cur = cur.replace( /\/[^\/]*$/, "/" );

		url = cur + old;
	}

	// ----- remove relative "../" notations
	url = url.replace( /\/[^\/]*\/\.\./gi, "" );

	// ----- remove prefix from CHM paths
	url = url.replace( /^.*\/([^\/]*\.chm\:\:\/)/i, "$1" );

	return url;
}



// ============================================================ \\
// =====       END OF CONDITIONAL/EXPANDO CODE            ===== \\
// ============================================================ \\
