

window.collapsibleListRef = []; window.imageCache = []; window.autoCloseRef = [];
var is_Icab = window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1;

function collapsibleList() {
	this.treeImg = arguments[0];
	this.expdImg = arguments[1];
	this.isAutoClose = arguments[2];
	this.subClass = arguments[3];
	this.sub = [];
}

function sub() {
	this.text = arguments[0];
	this.expanded = arguments[1];
	this.sub = [];
}

function ColLexPdOb(plI,miI,oSv,oAc) { this.plI = plI; this.miI = miI; this.subs = []; this.saveName = oSv; this.autoCol = oAc; }
function ColLexPdIT(name,expanded) { this.name = name; this.expanded = expanded; }

function createList(listObject,currentExt,imgExt,oLev,oBase) {
	if( !currentExt || !currentExt.match(/^treeList_\d+(_\d+)+$/) ) {
		window.collapsibleListRef[window.collapsibleListRef.length] = new ColLexPdOb( listObject.expdImg[4], listObject.expdImg[5], currentExt, listObject.isAutoClose );
		currentExt = 'treeList_'+( window.collapsibleListRef.length - 1 ); imgExt = ''; oLev = 0; oBase = listObject;
		document.write( '' );
		oBase.menuUniqueNum = window.collapsibleListRef.length - 1; window.autoCloseRef[oBase.menuUniqueNum] = [];
	}
	document.write( '<span style="display:;" id="'+currentExt+'">' );
	for( var x = 0; x < listObject.sub.length; x++ ) {
		document.write(
			( ( oLev || x ) ? '\n<br>' : '' ) +
			( ( oBase.subClass && oBase.subClass[oLev] && oBase.subClass[oLev][listObject.sub[x].sub.length?1:0] && !( document.layers && navigator.mimeTypes['*'] ) ) ? ( '<span class="'+oBase.subClass[oLev][listObject.sub[x].sub.length?1:0]+'">' ) : '' ) + imgExt +
			( oLev ? '<img src="' + ( ( x < listObject.sub.length - 1 ) ? oBase.treeImg[2] : oBase.treeImg[3] ) + '" align="absmiddle" width="' + oBase.treeImg[0] + '" height="' + oBase.treeImg[1] + '" alt="' + ( ( x < listObject.sub.length - 1 ) ? '|-' : '`-' ) + '" border="0">' : '' ) +
			( listObject.sub[x].sub.length ? '<a href="#" onclick="expandList(\'' + currentExt + '_' + x + '\',\'' + currentExt + '_' + x + '_img\',\'' + oBase.expdImg[4] + '\',\'' + oBase.expdImg[5] + '\',\'' + oBase.menuUniqueNum + '\','+oLev+',' + ( oBase.isAutoClose ? 'true' : 'false' ) + ');if(this.blur){this.blur();}return false;"><img src="' + oBase.expdImg[2] + '" align="absmiddle" name="' + currentExt + '_' + x + '_img" width="' + oBase.expdImg[0] + '" height="' + oBase.expdImg[1] + '" alt="[+/-]" border="0"></a> ' : '<img src="' + oBase.expdImg[3] + '" align="absmiddle" width="' + oBase.expdImg[0] + '" height="' + oBase.expdImg[1] + '" alt="" border="0"> ' ) +
			listObject.sub[x].text + ( ( oBase.subClass && oBase.subClass[oLev] && oBase.subClass[oLev][listObject.sub[x].sub.length?1:0] && !( document.layers && navigator.mimeTypes['*'] ) ) ? '</span>' : '' )
		);
		if( listObject.sub[x].sub.length ) {
			window.collapsibleListRef[window.collapsibleListRef.length - 1].subs[window.collapsibleListRef[window.collapsibleListRef.length - 1].subs.length] = new ColLexPdIT( currentExt + '_' + x, listObject.sub[x].expanded && !oBase.isAutoClose );
			createList( listObject.sub[x], currentExt + '_' + x, oLev ? ( imgExt + ( ( x < listObject.sub.length - 1 ) ? '<img src="' + oBase.treeImg[4] + '" align="absmiddle" width="' + oBase.treeImg[0] + '" height="' + oBase.treeImg[1] + '" alt="|&nbsp;">' : '<img src="' + oBase.treeImg[5] + '" align="absmiddle" width="' + oBase.treeImg[0] + '" height="' + oBase.treeImg[1] + '" alt="&nbsp;&nbsp;">' ) ) : '', oLev + 1, oBase );
		}
	}
	document.write( '</span>' );
	if( !oLev ) {
		document.write( '\n' );
		if( document.all || document.getElementById ) { window.setTimeout('prepareForUse('+(window.collapsibleListRef.length-1)+')',100); }
	}
}

function expandList(spanName,imgName,plsImg,minImg,oMenu,oLevel,oAutoClose) {
	var theSpan = document.getElementById ? document.getElementById(spanName) : document.all ? document.all[spanName] : (new Object());
	if( !theSpan ) { return; } if( theSpan.style ) { theSpan = theSpan.style; }
	if( typeof( theSpan.display ) == 'undefined' && !is_Icab ) {
		window.alert( 'Sorry, your browser cannot collapse or expand these lists\nso the lists will remain constantly expanded.' );
	} else {
		for( var y = window.autoCloseRef[oMenu].length - 1; y >= oLevel; y-- ) {
			if( window.autoCloseRef[oMenu][y] && oAutoClose && window.autoCloseRef[oMenu][y][0] != spanName ) {
				var theSpan2 = document.getElementById ? document.getElementById(window.autoCloseRef[oMenu][y][0]) : document.all ? document.all[window.autoCloseRef[oMenu][y][0]] : (new Object());
				if( theSpan2.style ) { theSpan2 = theSpan2.style; } theSpan2.display = 'none';
				document.images[window.autoCloseRef[oMenu][y][1]].src = window.autoCloseRef[oMenu][y][2];
				window.autoCloseRef[oMenu][y] = null;
			}
		}
		if( theSpan.display == 'none' ) { window.autoCloseRef[oMenu][oLevel] = [spanName,imgName,plsImg]; }
		theSpan.display = ( theSpan.display == 'none' ) ? ( is_Icab ? 'inline' : '' ) : 'none';
		document.images[imgName].src = theSpan.display ? plsImg : minImg;
	}
}

function prepareForUse(listNum) {
	if( !window.collapsibleListRef[listNum].subs.length ) { return; } 
	var lastPart = window.collapsibleListRef[listNum].subs[window.collapsibleListRef[listNum].subs.length - 1].name;
	lastPart = document.getElementById ? document.getElementById(lastPart) : document.all[lastPart];
	if( !lastPart ) { window.setTimeout('prepareForUse('+listNum+')',100); } else {
		if( lastPart.style ) { lastPart = lastPart.style; }
		if( typeof( lastPart.display ) == 'undefined' && !is_Icab ) { return; }
		window.imageCache[listNum] = [(new Image()),(new Image())];
		window.imageCache[listNum][0].src = window.collapsibleListRef[listNum].plI;
		window.imageCache[listNum][1].src = window.collapsibleListRef[listNum].miI;
		var svNm; if( svNm = window.collapsibleListRef[listNum].saveName ) { svNm = retrieveCookie(svNm); }
		if( typeof( svNm ) == 'string' ) { svNm = svNm.split(','); }
		for( var x = 0; x < window.collapsibleListRef[listNum].subs.length; x++ ) {
			var lastPart = window.collapsibleListRef[listNum].subs[x];
			if( svNm ) { var thisArray = mwjInArray(lastPart.name,svNm); }
			if( ( svNm && thisArray ) || ( !svNm && lastPart.expanded ) ) {
				document.images[lastPart.name + '_img'].src = window.imageCache[listNum][1].src;
			} else {
				document.images[lastPart.name + '_img'].src = window.imageCache[listNum][0].src;
				lastPart = document.getElementById ? document.getElementById(lastPart.name) : document.all[lastPart.name];
				if( lastPart.style ) { lastPart = lastPart.style; }
				lastPart.display = 'none';
			}
		}
	}
}

function mwjInArray(oNeed,oHay) { for( var i = 0; i < oHay.length; i++ ) { if( oNeed == oHay[i] ) { return true; } } return false; }

function saveCollapseState(oLife) {
	var allSpans = document.getElementsByTagName ? document.getElementsByTagName('span') : ( document.all ? document.all.tags('SPAN') : [] );
	if( !allSpans.length ) { return; } 
	for( var x = 0, saveNums = ''; window.collapsibleListRef[x]; x++ ) {
		if( !window.collapsibleListRef[x].autoCol && window.collapsibleListRef[x].saveName ) { saveNums += ( saveNums ? '|' : '' ) + x; } }
	if( !saveNums ) { return; } 
	for( var x = 0, brnch = [], frNm, rgxp = new RegExp('^treeList_('+saveNums+')_.*$',''); x < allSpans.length; x++ ) {
		if( allSpans[x].id && allSpans[x].id.match(rgxp) && allSpans[x].style.display != 'none' ) {
			frNm = allSpans[x].id.replace(rgxp,'$1');
			brnch[frNm] = ( brnch[frNm] ? ( brnch[frNm] + ',' ) : '' ) + allSpans[x].id;
		}
	}
	for( var x = 0, saveNums = ''; window.collapsibleListRef[x]; x++ ) {
		if( window.collapsibleListRef[x].saveName ) { setCookie(window.collapsibleListRef[x].saveName,brnch[x],oLife,'/'); } }
}