var what=null;
var newbrowser=true;
var check=false;
var layerRef;

var topTD=null;
var bottomTD=null;
var wc="leftNavBottom";

var menuStatus=-1;  // -1 = Open    0 = Closed    # = Expanded Section

var openCat=-1;

function toggle(which)
{
	var menuTable=document.getElementById('LeftMenuTable');
	index=getIndex(which);
	
	if (menuStatus==-1)
	{
		menuStatus=index;
		hideAll();
		showOne(index);
	}
	else if (menuStatus==-2)
	{
		menuStatus=index;
		showOne(index);
	}
	else if (menuStatus==index)
	{
		menuStatus=-2;
		hideAll();
	}
	else
	{
		menuStatus=index;
		hideAll();
		showOne(index);
	}
}

function toggle2( targetId ){
   if (document.getElementById){
         target = document.getElementById( targetId );
            if (target.style.display == "none"){
               target.style.display = "";
            } else {
               target.style.display = "none";
            }
      }
      return false;
}

function hideAll()
{
	var menuTable=document.getElementById('LeftMenuTable');
	var lastMain=null;
	for (var x=0; x<menuTable.rows.length; x++)
	{
		var theCell=menuTable.rows[x].cells[0];
		if (theCell.id.indexOf('.')>0)
		{
			menuTable.rows[x].style.display='none';
		}		
		else
		{
			if (x==0)
				theCell.className='leftNavTopClosed';
			else
				theCell.className='leftNavClosed';
			
			lastMain=theCell;
		}
		var img=document.getElementById('i'+theCell.id);
		if (img!=null)
			img.src=imgDown;
	}

	lastMain.className='leftNavBottomClosed';
}

function showAll()
{
	var menuTable=document.getElementById('LeftMenuTable');
	var lastMain=null;
	for (var x=0; x<menuTable.rows.length; x++)
	{
		var theCell=menuTable.rows[x].cells[0];
		if (theCell.id.indexOf('.')>0)
		{
			menuTable.rows[x].style.display='';
		}		
		else
		{
			lastMain=theCell;
			theCell.className='leftNavClosed';
		}
	}
	lastMain.className='leftNav';
}
function showOne(index)
{
	var menuTable=document.getElementById('LeftMenuTable');
	var lastMain=null;

	var off=false;
	var drawn=false;
	var lastShown;
	for (var x=index; x<menuTable.rows.length; x++)
	{
		var theCell=menuTable.rows[x].cells[0];
		
		if (theCell.id.indexOf('.')>0 & !off)
		{
			menuTable.rows[x].style.display='';			
			
			theCell.style.width=menuTable.width;
			lastShown=theCell;
		}
		else if (x<index)
		{
			if (x==0)
				theCell.className='leftNavTop';
			else
				theCell.className='leftNavClosed';
		}
		else if (x==index & x>0 & !off)
		{
			theCell.className='leftNavOpen';
			var img=document.getElementById('i'+theCell.id);
			if (img!=null)
				img.src=imgUp;
			drawn=true;
		}
		else if (x>0 & !off)
		{
			if (drawn)
			{
				if (theCell.className!='leftNavBottomClosed')
					theCell.className='leftNavClosed';
			}
			off=true;
		}
		else if (x==0)
		{
			theCell.className='leftNavTop';
			var img=document.getElementById('i'+theCell.id);
			if (img!=null)
				img.src=imgUp;
		}
	}	
	if (lastShown!=null)
	{
		if (lastShown.className!='leftNavMainBottom')
		   lastShown.className='leftNavLast';
	}
}
function getIndex(which)
{
	var menuTable=document.getElementById('LeftMenuTable');

	for (var x=0; x<menuTable.rows.length; x++)
	{
		var theCell=menuTable.rows[x].cells[0];
		if (theCell.id==which)
			return x;
	}
	return -1;
}
function show_props(obj,name)
{
    for(var i in obj)
    {
        var msg = name + "." + i + " (" + typeof(obj[i]) + ") = '" + obj[i] + "'";

        document.writeln(msg+"<BR>");
    }
}
