NN4=document.layers?true:false;
NN6=(navigator.appName == "Netscape")&&!NN4;
function getElementById(anId){
	return anId?window.document.getElementById(anId):null;
}
function getHeight(anObj){
	return anObj.offsetHeight;
}
function getCoordsById(anId){
	var obj=getElementById(anId);
	return getCoords(obj)
}
function getCoords(anObj){
	var objRes=new Object();
	objRes.left=objRes.top=objRes.width=objRes.height=0;
	with(objRes){
		width+=anObj.offsetWidth;
		height+=anObj.offsetHeight;
		for(var i=anObj;i!=null;i=i.offsetParent){
			left+=i.offsetLeft;
			top+=i.offsetTop;
		}
	}
	return objRes;
}
var mainMenu=null;
var alldone=false;
//MenuItem Class Begin
function MenuItem(anId){
	this.Id=anId;
	var aRef=getElementById(anId);
	this.ref=aRef;
	aRef.ref=this;
	this.parent=null;
	this.subpad=null;
	this.AddSubpad=AddSubpad;
	this.visible=true;
	this.height=0;
	this.maxHeight=getHeight(this.ref);
	this.deltaHeight=true;
	this.ChangeH=ItemChangeH;
	this.Show=ItemShow;
	this.Hide=ItemHide;
	this.Hide();
	return this;
}
function AddSubpad(){
	var anSubpad=new MenuPad();
	anSubpad.Id=this.Id;
	anSubpad.parent=this;
	return this.subpad=anSubpad;
}
function ItemChangeH(aHeight){
	var newHeight;
	aHeight-=newHeight=(aHeight>this.maxHeight)?this.maxHeight:(aHeight<0?0:aHeight);
	if (this.height!=newHeight){
		if (newHeight==0){
			this.deltaHeight=(this.height!=0);
			this.height=0;
			this.Hide();
		}else{
			this.deltaHeight=(this.height!=newHeight);
			this.height=newHeight;
			this.Show();
		}
	}
	return aHeight;
}
function ItemShow(){
	if (this.deltaHeight)
		this.ref.style.height=this.height;
	if (!this.visible){
		this.ref.style.visibility="visible";
		this.ref.style.display="block";
	}
	this.deltaHeight=false;
	this.visible=true;
}
function ItemHide(){
	if (this.deltaHeight)
		this.ref.style.height=this.height;
	if (this.visible)
		this.ref.style.display="none";
	this.deltaHeight=false;
	this.visible=false;
}

function ItemClick(anId, force){
	var aPad, anItem;
	if ((anItem=getElementById(anId)) && (anItem=anItem.ref))
		aPad=anItem.subpad;
	else
		if (anId=="")
			aPad=mainMenu;
		else
			return;
	if (aPad && aPad.dir==-1)
		aPad.Expand(force);
	else
		if (anItem && (aPad=anItem.parent)) aPad.Expand(force);
	
}
//MenuItem Class End

// mainMenuClass begin
// mainMenuClass end

//MenuPad Class Begin
function MenuPad(){
	this.Id="";
	this.parent=null;
	this.items=new Array();
	this.AddItem=AddItem;
	this.visible=false;
	this.height=0;
	this.maxHeight=0;
	this.ChangeHby=PadChangeHby;
	this.Expand=PadExpand;
	this.Collapse=PadCollapse;
	this.trackNum=0;
	this.wasMoved=false;
	this.dir=-1;
	return this;
}
function AddItem(anId){
	var anItem=new MenuItem(anId);
	var anIndex=this.items.length;
	anItem.parent=this;
	this.maxHeight+=anItem.maxHeight;
	return this.items[anIndex]=anItem;
}
function PadChangeHby(byPx){
	var aHeight=this.height+byPx;

	var tmpHeight=aHeight;
	for(var i=0;i<this.items.length;i++){
		tmpHeight=this.items[i].ChangeH(tmpHeight);
	}
	var newHeight=aHeight-tmpHeight;
	byPx=newHeight-this.height;
	if (byPx>0)
		this.dir=1
	else
		this.dir=-1;
	if (byPx!=0){
		this.height=newHeight;
		if (newHeight==0)
			this.visible=false;
		else
			this.visible=true;
	}
	return tmpHeight;
}
function PadExpand(force){
	if (mainMenu.curr) mainMenu.curr.Collapse(force);
	else
		if (mainMenu.dest) mainMenu.dest.Collapse(force);
	mainMenu.dest=this;
	mainMenu.curr=mainMenu;
	PadSingleExpand(force);
}
function PadCollapse(force){
	window.clearTimeout(mainMenu.timerId);
	PadStepCollapse(this,force);
}
function PadSingleExpand(force){
	mainMenu.curr.trackNum+=1;
	PadStepExpand(force);
}
function PadStepExpand(force){
	if (mainMenu.curr.height==mainMenu.curr.maxHeight)
		if (mainMenu.curr.wasMoved && force==null)
			mainMenu.timerId=window.setTimeout("PadPauseExpand()",mainMenu.pause)
		else{
			var aPad=PadGetBelow();
			if (aPad==null) return;
			mainMenu.curr=aPad;
			PadSingleExpand(force);
		}
	else{
		if (force==null){
			mainMenu.curr.ChangeHby(mainMenu.step);
			mainMenu.timerId=window.setTimeout("PadTimerExpand()",mainMenu.delay);
		}else{
			mainMenu.curr.ChangeHby(mainMenu.curr.maxHeight-mainMenu.curr.height);
			PadStepExpand(force);
		}
	}
}
function PadStepCollapse(curr,force){
	if (curr.trackNum==1){
		if (curr.height==0)
			if (curr.wasMoved && force==null)
				window.setTimeout("PadPauseCollapse('"+curr.Id+"')",mainMenu.pause);
			else{
				curr.trackNum-=1;
				if (curr.parent && curr.parent.parent)
					curr=curr.parent.parent;
				else
					curr=null;
				if (curr!=null) PadStepCollapse(curr,force);
			}
		else{
			if (force==null){
				curr.ChangeHby(-mainMenu.step);
				window.setTimeout("PadTimerCollapse('"+curr.Id+"')",mainMenu.delay);
			}else{
				curr.ChangeHby(-curr.height);
				PadStepCollapse(curr,force);
			}
		}
	}else{
		curr.trackNum-=1;
		if (curr.parent && curr.parent.parent)
			curr=curr.parent.parent;
		else
			curr=null;
		if (curr!=null) PadStepCollapse(curr,force);
	}
}
function PadTimerExpand(){
	mainMenu.curr.wasMoved=true;
	PadStepExpand();
}
function PadTimerCollapse(currId){
	var curr=(currId=="root"?mainMenu:getElementById(currId).ref.subpad);
	curr.wasMoved=true;
	PadStepCollapse(curr);
}
function PadPauseExpand(){
	mainMenu.curr.wasMoved=false;
	PadStepExpand();
}
function PadPauseCollapse(currId){
	var curr=(currId=="root"?mainMenu:getElementById(currId).ref.subpad);
	curr.wasMoved=false;
	PadStepCollapse(curr);
}
function PadGetBelow(){
	if (mainMenu.curr==mainMenu.dest) return null;
	var itr=mainMenu.dest;
	if (itr==null) return null;
	var itrPrev=itr;

	while(true){
		itr=itr.parent
		if (itr==null) return null;
		itr=itr.parent
		if (itr==null) return null;

		if (itr==mainMenu.curr) return itrPrev;
		itrPrev=itr;
	}
}
//MenuPad Class End
function MySetPosition(id){
	var obj=getElementById(id);
	if(obj){
		var c=getCoords(obj.parentElement);
		obj.style.top=c.top+obj.parentElement.offsetHeight;
		obj.style.left=c.left;
		alert("top="+c.top+"\nleft="+c.left);
	}else
		setTimeout("MySetPosition('"+id+"')",1000);
}
function myon(id){
	var obj=getElementById("mtd"+id);
	var c=getCoords(obj.parentElement);
	obj.style.top=c.top+obj.parentElement.offsetHeight-5;
	obj.style.left=c.left;
	obj.style.visibility="visible";
	obj.style.display="block";
}
function myoff(id){
	var obj=getElementById("mtd"+id);
	obj.style.visibility="hidden";
	obj.style.display="none";
}
function alterTable(id,r1,r2){
/*
	var obj=document.all[id].childNodes;
	for(var i in obj)
		if(obj[i].tagName=='TABLE'){
			var o=obj[i].childNodes;
			for(var j in o)
				if(o[j].tagName=="TBODY"){
					var k=o[j].childNodes;
					var c=0;
					for(var t in k){
						if(c++ % 2 == 0)
							k[t].className=r1;
						else
							k[t].className=r2;
					}
				}
		}
*/
}
