function hideAll( depth )
{
	var divs = document.getElementsByTagName( "DIV" );
	var currDiv;

	for ( var i = 0; i < divs.length; i++ )
	{
		currDiv = divs[ i ];
		if ( typeof( currDiv.attributes[ "depth" ] ) != "undefined" &&
             parseInt( currDiv.attributes[ "depth" ].nodeValue ) >= depth )
		{
			currDiv.style.display = "none";
		}
	}
}

function showHide( catId, url )
{
	var divs = document.getElementsByTagName( "DIV" );
	var currDiv, node1, node2;

	for ( var i = 0; i < divs.length; i++ )
	{
		currDiv = divs[ i ];
		if ( currDiv.id.substr( 0, 3 ) == "cat" )
		{
			if ( currDiv.id == ( "cat" + catId ) )
			{
                node1 = currDiv.childNodes[ 0 ];
                if ( node1.nodeName == "#text" )
                {
                    node1 = currDiv.childNodes[ 1 ];
                    node2 = node1.childNodes[ 0 ];
                    if ( node2.nodeName == "#text" )
                    {
                        node2 = node1.childNodes[ 1 ];
                    }
                }
                else
                {
                    node2 = node1.childNodes[ 0 ];
                }

				if ( node1.childNodes.length == 0 ||
				     typeof( node2 ) == "undefined" ||
					 node2.childNodes.length == 0 )
				{
					document.location.href = url;
					return;
				}
				else
				{
				    var open = true;
				    if ( currDiv.style.display == "block" )
				    {
				        open = false;
				    }

                    if ( typeof( currDiv.attributes[ "depth" ] ) != "undefined" )
                    {
					   hideAll( parseInt( currDiv.attributes[ "depth" ].nodeValue ) );
					}

                    if ( open )
                    {			        
					   currDiv.style.display = "block";
					}
				}
			}
		}
	}
}

