arrMenu=new Array()
function MenuObj(num, nest, imgopn, imgcls, ident, level)
{
	this.ident=ident
	this.level=level
	this.obj=document.layers['div' + num]
	this.nest=nest
	this.subs=new Array()
	this.css=this.obj
	this.x=this.css.left
	this.y=this.css.top
	this.height=this.obj.document.height
	this.isFolded=false
	this.isVisible=false
	this.Show=ShowIt; this.Hide=HideIt;
	this.Move=MoveIt;
	
	this.image=imgopn ? this.obj.document.images['img/neutral/' + num] : null
	this.imageOpn=imgopn ? CreateImage(imgopn) : null
	this.imageCls=imgcls ? CreateImage(imgcls) : CreateImage(imgopn)
	
	return this
}
function ShowIt(){this.css.visibility="show"; this.isVisible=true}
function HideIt(){this.css.visibility="hide"; this.isVisible=false}
function MoveIt(y){this.css.top=y; this.y=y}

counter=0
function Create(ident,parent,text,href,imgopn,imgcls,sclass)
{
	nest= (parent==null) ? null : GetNumericParent(parent)
	level= (nest==null) ? 0 : arrMenu[nest].level + 1
	var str;
	str='<layer z-index=10 visibility=hide left=' + (gLeft + gXOffset*level) + ' name=div' + counter + '>'
	if (imgopn)	str+='<a href="javascript:///" onclick="Fold('+ counter +');return false"><img src="'+ imgopn +'" width=24 height=17 border=0 name="img' + counter +'"></a>&nbsp;'
	if (href) str+='<a href="' + href + '" class="' + sclass  +'">'
	str+=text
	if (href) str+='</a>'
	str+='</layer>'
	document.write (str)
	if (nest!=null) arrMenu[nest].subs[arrMenu[nest].subs.length]=counter
	arrMenu[counter]=new MenuObj(counter,nest,imgopn,imgcls,ident, level)
	counter++
}

function GetNumericParent(parent)
{
	var i
	for (i=0; i<arrMenu.length; i++)
		if (arrMenu[i].ident==parent)
			return i
	return null
}

function ShowLine(num)
{
	if (arrMenu[num].isVisible)
	{
		arrMenu[num].Show()
		arrMenu[num].Move(intPos)
		intPos+=arrMenu[num].height+gItemSpace
	}
	else
		arrMenu[num].Hide()
	var j
	for(j=0; j<arrMenu[num].subs.length; j++)
		ShowLine(arrMenu[num].subs[j])

}

function Update()
{
	intPos=gTop
	for(i=0; i<arrMenu.length; i++)
		if (arrMenu[i].level==0)
			ShowLine(i)
}

function FoldOpen(num)
{
	window.resizeTo(self.innerWidth-10,self.innerHeight-10)
	window.resizeTo(self.innerWidth+10,self.innerHeight+10)
	var i;
	for(i=0; i<arrMenu[num].subs.length; i++)
	{
		arrMenu[arrMenu[num].subs[i]].isVisible=true
	}
	if(arrMenu[num].nest!=null) FoldOpen(arrMenu[num].nest)
	arrMenu[num].isFolded=true
	arrMenu[num].image.src=arrMenu[num].imageCls.src
}

function FoldClose(num)
{
	var i;
	for(i=0; i<arrMenu[num].subs.length; i++)
	{
		arrMenu[arrMenu[num].subs[i]].isVisible=false
		FoldClose(arrMenu[num].subs[i])
	}
	arrMenu[num].isFolded=false
	arrMenu[num].image.src=arrMenu[num].imageOpn.src
}

function Fold(num)
{
	if (arrMenu[num].isFolded) FoldClose(num)
	else FoldOpen(num)
	Update()
}

function Init(num)
{
	for(i=0; i<arrMenu.length; i++)
		if (arrMenu[i].nest==null) arrMenu[i].isVisible=true
	if (!isNaN(num)) Fold(num)
	Update()
}

function CreateImage(img) {var objImg=new Image(); objImg.src=img; return objImg;}
bMLoad=true
