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

EXPANDO_GRAPHICS = new createExpandoGraphicsObject( "blue", "white" );
if (!top.GLOBALFRAMES)	{ top.GLOBALFRAMES = new createGlobalFramesObject(); }
var EXPANDO_MULTILINKS = new Array();

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

function createExpandoGraphicsObject() {
	if (arguments.length == 0) return;

	this.Colorlist = new Array();
	this.Color = new Array();
	this.Icon = new Array();

	for (var i=0; i<arguments.length; i++) {
		var couleur = arguments[i];
		this.Colorlist[i] = couleur;
		this.Icon[i] = new createExpandoButtonObject(couleur);
		this.Color[couleur.toLowerCase()] = this.Icon[i];
	}

	// Make first colour the default
	this.Default = arguments[0];
}

function createExpandoButtonObject ( couleur ) {
	var pathprefix = "";
	if (window.HELPFILE && HELPFILE.Paths && HELPFILE.Paths["images"]) {
		pathprefix = HELPFILE.Paths["images"];
	}

	this.Name = couleur;

	this.Open = new Image();	this.Open.src = 	pathprefix + "button_expand_" + couleur + "_open_lo.gif";
	this.Close = new Image();	this.Close.src =	pathprefix + "button_expand_" + couleur + "_close_lo.gif";
	this.OpenOver = new Image();	this.OpenOver.src =	pathprefix + "button_expand_" + couleur + "_open_hi.gif";
	this.CloseOver = new Image();	this.CloseOver.src =	pathprefix + "button_expand_" + couleur + "_close_hi.gif";
}

function createGlobalFramesObject() {
	this.Expandos = 0;
	this.Expando = new Array();
	this.ExpandoPadding = "0px";
	this.ExpandoMargin = "2px";
	this.Popups = 0;
	this.Popup = new Array();
	this.PopupDepthLimit = 1;		// -1 = infinite nesting
}

// ------------------------------------------------------------------- \\
// -----              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.className = "expandochicklet";
			linkObj.insertBefore( imgObj, linkObj.firstChild );
			linkObj.className = "expandotitle";

			// ----- 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) {
		externalexpando_divPrep();
	}
		
	if ( divObj.startOpen ) {
		expando_setBlockOpen( divObj );
	} else {
		expando_setBlockClosed( divObj );
	}

	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;
}

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

function expando_setBlockOpen ( div ) {
	var cls = div.className.toLowerCase();
	ar = cls.match(/expando(_open|_closed|)(.*)/);
	if (ar) {
		div.className = "expando_open" + ar[2];
	}
}

function expando_setBlockClosed ( div ) {
	var cls = div.className.toLowerCase();
	ar = cls.match(/expando(_open|_closed|)(.*)/);
	if (ar) {
		div.className = "expando_closed" + ar[2];
	}
}

function expando_isBlockOpen ( div ) {
	var cls = div.className.toLowerCase();
	ar = cls.match(/expando(_open|_closed|)(.*)/);

	var query = false;
	if ( ar && ar[1] && ar[1] == "_open" ) {
		query = true;
	}
	return query;
}

function expando_isBlockClosed ( div ) {
	var cls = div.className.toLowerCase();
	ar = cls.match(/expando(_open|_closed|)(.*)/);

	var query = true;
	if ( ar && ar[1] && ar[1] == "_open" ) {
		query = false;
	}
	return query;
}

// ------------------------------------------------------------------- \\
// -----       "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;
				}
			}
		}
		if ( expando_isBlockClosed(divObj) ) {
			expando_setBlockOpen(divObj);
			if (tPicObj) {
				tPicObj.src = EXPANDO_GRAPHICS.Color[iconColor].Close.src;
			}
		} else if ( expando_isBlockOpen(divObj) ) {
			expando_setBlockClosed(divObj);
			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 ----- \\
			expando_setBlockOpen( tDivObj );
		} else {
			// ----- clean up other, non-active radio buttons ----- \\
			tRadioButton.checked = false;
			expando_setBlockClosed( tDivObj );
		}

		// ----- 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;
}


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

function nothing() {}