var openLists = [], oIcount = 0;
//*******************************************************************************
// Nisad Sivcevic - 20050107
var oPl = '<img src="/Sherlewagner/navig/plus.gif" align="baseline" border="0" hspace="1">'
var oPlImg = '/Sherlewagner/navig/plus.gif';
var oMnImg = '/Sherlewagner/navig/minus.gif';
// you can also try this images
//var oPl = '<img src="catalog_imgs/navig/arrow_down.gif" align="baseline" border="0" hspace="1" height="12" width="12">'
//var oPlImg = 'catalog_imgs/navig/arrow_down.gif';
//var oMnImg = 'catalog_imgs/navig/arrow_up.gif';
//*******************************************************************************

function compactMenu(oID,oAutoCol,oPlMn,oMinimalLink) {
	 
	if( !document.getElementsByTagName || !document.childNodes || !document.createElement ) { 
		return; 
	}
	var baseElement = document.getElementById( oID ); 
	if( !baseElement ) { 
		return; 
	}
	compactChildren( baseElement, 0, oID, oAutoCol, oPlMn, baseElement.tagName.toUpperCase(), oMinimalLink && oPlMn );
}

function compactChildren( oOb, oLev, oBsID, oCol, oPM, oT, oML ) {
	 
	if( !oLev ) { 
		oBsID = escape(oBsID); 
		if( oCol ) { 
			openLists[oBsID] = []; 
		} 
	}
	for( var x = 0, y = oOb.childNodes; x < y.length; x++ ) { 
		
		if( y[x].tagName ) {
		//for each immediate LI child
		var theNextUL = y[x].getElementsByTagName( oT )[0];
		if( theNextUL ) {
			//collapse the first UL/OL child
			theNextUL.style.display = 'none';
			//create a link for expanding/collapsing
			var newLink = document.createElement('A');
			newLink.setAttribute( 'href', '#' );
			newLink.onclick = new Function( 'clickSmack(this,' + oLev + ',\'' + oBsID + '\',' + oCol + ',\'' + escape(oT) + '\');return false;' );
			//wrap everything upto the child U/OL in the link
			if( oML ) { 
				var theHTML = ''; 
			} else {
				var theT = y[x].innerHTML.toUpperCase().indexOf('<'+oT);
				var theA = y[x].innerHTML.toUpperCase().indexOf('<A');
				var theHTML = y[x].innerHTML.substr(0, ( theA + 1 && theA < theT ) ? theA : theT );
				while( !y[x].childNodes[0].tagName || ( y[x].childNodes[0].tagName.toUpperCase() != oT && y[x].childNodes[0].tagName.toUpperCase() != 'A' ) ) {
					y[x].removeChild( y[x].childNodes[0] ); }
				}
				y[x].insertBefore(newLink,y[x].childNodes[0]);
				y[x].childNodes[0].innerHTML = oPM + theHTML.replace(/^\s*|\s*$/g,'');
				theNextUL.MWJuniqueID = oIcount++;
				compactChildren( theNextUL, oLev + 1, oBsID, oCol, oPM, oT, oML );
			} 
		} 
	} 
}

function clickSmack( oThisOb, oLevel, oBsID, oCol, oT ) {
	 alert(oThisOb );
	 alert( oLevel);
	 alert(oBsID );
	 alert( oCol);
	 alert(oT );
	if( oThisOb.blur ) { 
		oThisOb.blur(); 
	}
	oThisOb = oThisOb.parentNode.getElementsByTagName( unescape(oT) )[0];
	if( oCol ) {
		
		for( var x = openLists[oBsID].length - 1; x >= oLevel; x-=1 ) { 
		 
			if( openLists[oBsID][x] ) {
				openLists[oBsID][x].style.display = 'none'; 
				//*******************************************************************************
				// Nisad Sivcevic - 20050107
				openLists[oBsID][x].previousSibling.innerHTML = openLists[oBsID][x].previousSibling.innerHTML.replace(oMnImg,oPlImg); 
				//*******************************************************************************
				if( oLevel != x ) { 
					openLists[oBsID][x] = null; 
				}
			} 
		}
		if( oThisOb == openLists[oBsID][oLevel] ) { 
			openLists[oBsID][oLevel] = null; 
		} else {	
			oThisOb.style.display = 'block'; 
			//*******************************************************************************
			// Nisad Sivcevic - 20050107
			oThisOb.previousSibling.innerHTML = oThisOb.previousSibling.innerHTML.replace(oPlImg,oMnImg); 
			//*******************************************************************************
			openLists[oBsID][oLevel] = oThisOb; }
	} else {  
		oThisOb.style.display = ( oThisOb.style.display == 'block' ) ? 'none' : 'block'; 
	}
}

