currentId="";
activeTree=new Array();
openElements=new Array();
hlElements=new Array();
topElement="";
tempMainCat="";
function navTreeSearch(thisCat){
	//alert(thisCat);
	var result=new Array();
	if(thisCat=="")
		return result;
	result[result.length]=thisCat;
	ref=document.getElementById(thisCat);
	if(ref.className=="subnavwrapper")
		topElement=thisCat;
	thisParentRef=ref.parentNode;
	if(thisParentRef.className!="subnav")
	{
		result=result.concat(navTreeSearch(thisParentRef.id));		
	}
	return result;
}
function closeOpenElements(){
	for(o=0;o<openElements.length;o++)
		document.getElementById(openElements[o]).style.display="none";
	openElements=new Array();
	for(h=0;h<hlElements.length;h++)
	{
		document.getElementById("a"+hlElements[h]).style.color="#A1896A";
		document.getElementById("a"+hlElements[h]).style.background="none";
	}
	hlElements=new Array();
}
function openNode(refid){
	document.getElementById(refid).style.display="block";
	tRef= document.getElementById(refid).parentNode;
	if(tRef.className!="subnavwrapper")
		openElements[openElements.length]=refid;	
}
function resetNav(cat){
	if(parent.ready)
	{
		if(!parent.onMenue)
			offMain();
		if(allCats[cat]!=null)
		{
			currentId=cat;
			closeOpenElements();
			activeTree=navTreeSearch(cat);
			if(topElement!="")
				parent.head.setActive(topElement);
			if(activeTree.length>0)
			{
				for(a=0;a<activeTree.length;a++)
				{
					//alert(activeTree[a]);
					if(!parent.onMenue)
						openNode(activeTree[a]);
					childs=document.getElementById(activeTree[a]).childNodes;
					if(document.getElementById(activeTree[a]).className != "subnavwrapper")
					{
						document.getElementById('a' + activeTree[a]).style.color="#660000";
						if(document.getElementById(activeTree[a]).className == "subnavnode")
						{
							document.getElementById('a' + activeTree[a]).style.background="url(../img/ornament.gif) no-repeat";
							document.getElementById('a' + activeTree[a]).style.backgroundPosition="1px 2px";
						}
						hlElements[hlElements.length]=activeTree[a];	
					}
					
					for(c=0;c<childs.length;c++)
					{
						if(childs[c].id!=null && childs[c].id!="" && childs[c].id.indexOf("a")<0)
								openNode(childs[c].id);
					}
				}			
			}	
			else
			{
					parent.head.fallBack();
					topElement="";
			}
		}
		else
		{
			//alert(cat);
			offMain();
			activeTree=new Array;
			parent.head.fallBack();
			topElement="";
		}
	}
	else
	{
		setTimeout('resetNav(\''+cat+'\')',700);
	}
}
function onMain(onCat){
	//closeOpenElements();
	if(tempMainCat!="")
		document.getElementById(tempMainCat).style.display="none";
	tempMainCat=onCat;
	if(topElement!="")
		document.getElementById(topElement).style.display="none";
	document.getElementById(onCat).style.display="block";
}
function offMain(){
	if(tempMainCat!="")
		document.getElementById(tempMainCat).style.display="none";
	if(topElement!="")
		document.getElementById(topElement).style.display="block";
	tempMainCat="";
}
function init(){
	parent.ready=true;
}
