var menuimgopen="siteImg/button_on.gif";
var menuimgclose="siteImg/button_off.gif";
var shopmenuimgopen="siteImg/button_on.gif";
var shopmenuimgclose="siteImg/button_off.gif";
var mc_catalogimgopen="siteImg/button_on.gif";
var mc_catalogimgclose="siteImg/button_off.gif";

var tobjs = new Array;
var objs = new Array;
var tobjs2 = new Array;
var tobjs3 = new Array;
function hidetree(tree, id)
{
	for(var i=0; i<tree.length; i++)
		if (tree[i].getAttribute("parent")==id)
		{
			tree[i].style.display="none";
			hidetree(tree, i);
		}
}

function showtree(tree, id)
{
	for(var i=0; i<tree.length; i++)
		if (tree[i].getAttribute("parent")==id)
		{
			tree[i].style.display="";
			if (!tree[i].getAttribute("shrinked"))
				showtree(tree, i);
		}
}

function menu(ptr)
{
	eval("var io = "+ptr.getAttribute("table")+"imgopen;");
	eval("var ic = "+ptr.getAttribute("table")+"imgclose;");
	eval("var curimg = document.all."+ptr.getAttribute("table")+ptr.id+";");
	var iidx = 0;
	if (ptr.getAttribute('table')=='menu')
	objs = tobjs;
	if (ptr.getAttribute('table')=='shopmenu')
	objs = tobjs2;
	if (ptr.getAttribute('table')=='mc_catalog')
	objs = tobjs3;
	if (!objs.length)
	{
		objs = new Array;
		for (var i=0; i<document.all.length; i++)
			if (document.all[i].getAttribute("table")==ptr.getAttribute("table"))
			{
				objs[iidx] = document.all[i];
				iidx++;
			}
	}
	if (ptr.getAttribute("shrinked"))
	{
		showtree(objs, ptr.id);
		if (ptr.getAttribute("parent")==-1)
			for (var j=0; j<objs.length; j++)
				if ((objs[j].id!=ptr.id) && (objs[j].getAttribute("parent")==-1) && (!objs[j].getAttribute("shrinked")))
				{
					hidetree(objs, j);
					objs[j].setAttribute("shrinked", "true");
					eval("if (document.all."+ptr.getAttribute("table")+j+" && ic) document.all."+ptr.getAttribute("table")+j+".src=ic;");
				}
		ptr.setAttribute("shrinked", "");
		if (curimg && io)
			curimg.src = io;
	}
	else
	{
		hidetree(objs, ptr.id);
		ptr.setAttribute("shrinked", true);
		if (curimg && ic)
			curimg.src = ic;
	}
	if (ptr.getAttribute('table')=='menu')
	tobjs = objs;
	if (ptr.getAttribute('table')=='shopmenu')
	tobjs2 = objs;
	if (ptr.getAttribute('table')=='mc_catalog')
	tobjs3 = objs;
}