cMT=null;
cM=null;
mHT=null;
mST=null;
mOM=false;
tM=[];
isHC=false;
hiddenElmnts=false;

function createLeftNav(menuId){
	cM=null;
	var mArray=eval("menu_"+menuId);
	cMT={width:mArray[0][0],x:mArray[0][1],y:mArray[0][2]};
	tM[tM.length]=cMn(menuId,false);
};

function cMn(menuId,isHdr){
	var lyr=document.createElement("DIV");
	lyr.id="menu"+menuId;
	lyr.a=eval("menu_"+menuId);
	lyr.maxItems=lyr.a.length-1;
	//lyr.isHdrMenu=isHdr;
	lyr.itemCount=0;
	lyr.tree=cMT;
	lyr.showL=showL;
	lyr.hideL=hideL;
	lyr.onmouseover=menuOn;
	lyr.onmouseout=menuOut;
	lyr.hideT=hideT;
	lyr.hideChildren=hideCM;
	lyr.hasCVisible=false;
	lyr.isOn=false;
	lyr.currentItem=null;
	var l_s=lyr.style;
	l_s.width=cMT.width+"px";
	l_s.zIndex=1000;
	l_s.position="absolute";
	l_s.visibility="hidden";
	if(cM){
	if(menuId.charAt(0)==1){l_s.left=l_s.top="-200px";	}
	else {l_s.left=l_s.top="0px";}
	lyr.parentMenu=cM;
	lyr.level=cM.level+1;
	lyr.parentRow=cM.row;
	lyr.parentRow.child=lyr;
	lyr.hasParent=true;
	}
	else{
		l_s.left=cMT.x+"px";
		l_s.top=cMT.y+"px";
		lyr.hasParent=false;
		cMT.treeParent=lyr;
		l_s.visibility="visible";
		lyr.level=1;
		lyr.isOn=true;	
	}
	cM=lyr;
	var itr=cM.maxItems;
	while(itr--){
		cM.itemCount++;
		var row=createRow(menuId);
		if(row){
			cM.row=row;
			if(row.hasMore){
				var childMenu=cMn(menuId+"_"+cM.itemCount,isHdr);
				if(childMenu)cM=cM.parentMenu;
			}
			if(row.index){
				var sb_s=row.siblingBelow.style;
				row.style.top=(parseInt(sb_s.top)+parseInt(sb_s.height.substring(0,sb_s.height.indexOf("px"))))+"px";
			}
			else row.style.top="0px";
		}
	}
	cM.style.height=(cM.itemCount*20)+"px";
	if (menuId.charAt(0)==1) document.getElementById("left").appendChild(lyr);
	else document.getElementById("languag").appendChild(lyr);
	return cM;
};
			
function createRow(menuId){
	var row=document.createElement("DIV");
	row.id="row"+menuId+"_"+cM.itemCount;
	row.menu=cM;
	row.tree=cMT;
	row.index=cM.itemCount-1;
	row.child=null;
	row.onmouseover=rowOn;
	row.onmouseout=rowOut;
	row.showCM=showCM;
	row.a=cM.a[cM.itemCount];
	row.hasMore=row.a[9];
	row.fc=(typeof row.a[2]!='undefined')?row.a[2]:fc[cM.level-1];
	row.bg=(typeof row.a[4]!='undefined')?row.a[4]:bg[cM.level-1];
	row.txt=row.a[0];
	row.linktxt=(typeof row.a[1]=='undefined')?"":row.a[1];
	row.fc_o=(typeof row.a[3]!='undefined')?row.a[3]:fc_o[cM.level-1];
	row.bg_o=(typeof row.a[5]!='undefined')?row.a[5]:bg_o[cM.level-1];
	var r_s=row.style;
	r_s.position="absolute";
	r_s.visibility="inherit";
	
	if(menuId.charAt(0)==1){
		if(row.hasMore){
			row.imageSrc="../picture/arrowsmall.gif";
			r_s.background=row.bg+" url("+row.imageSrc+") no-repeat "+(row.tree.width-16)+"px 3px";
		}
		else r_s.backgroundColor=row.bg;
	}
	else r_s.backgroundColor=row.bg;
	r_s.color=row.fc;
	
	if (menuId.charAt(0)==1) r_s.font="11px verdana,arial,helvetica,sans-serif";
	else r_s.font="9px verdana";
	
	r_s.height="20px";
	r_s.lineHeight="20px";
	r_s.left="0px";
	if(menuId.charAt(0)==1) {	
		if(menuId.charAt(1)=='_') r_s.width="123px";
		else r_s.width=cMT.width+"px";
	}
	else{
		  r_s.width="95px";
	}
	if(row.linktxt.length>0){row.onclick=goTo;
	r_s.cursor=(isIE)?"hand":"pointer";
	var r_cont='<a href="'+row.linktxt+'" style="text-decoration:none;color:'+r_s.color+';">'+row.txt+'</a>';
	}
	else{r_s.cursor="default";
	var r_cont=row.txt;
	}
	if(cM.level==1)row.innerHTML='<div style="padding:0 5px;">'+r_cont+'</div>';
	else row.innerHTML='<div style="padding:0 10px;">'+r_cont+'</div>';
	cM.appendChild(row);
	row.siblingBelow=row.previousSibling;
	return row;
};

function menuOn(){
	var t_tp=this.tree.treeParent;
	if(!t_tp)t_tp=this;
	if(t_tp==this)hidetM(this);
	mOM=true;
	cM=this;
	if(mHT)clearTimeout(mHT);
	};

function menuOut(){
	mOM=false;
	mHT=setTimeout("cM.hideT()",800);
	};
	
function hidetM(callingmenu){
	for(var i=tM.length-1;i>=0;i--){
		var topMenu=tM[i].tree.treeParent;
		if(topMenu==callingmenu)continue;
		if(topMenu.hasCVisible)topMenu.hideChildren();
		topMenu.hideL();
				//h_s.paddingTop="5px";
				//h_s.marginTop="0px";
				}
				};
				
function rowOn(){
	this.style.backgroundColor=this.bg_o;
	if(this.getElementsByTagName('a').length==1)this.getElementsByTagName('a')[0].style.color=this.fc_o;
	else this.style.color=this.fc_o;
	if(this.menu.hasCVisible){
		var v_c=this.menu.visibleChild;
		if(v_c==this.child&&v_c.hasCVisible)v_c.hideChildren(this);
		else this.menu.hideChildren(this);
	}
	if(this.menu.currentItem&&this.menu.currentItem!=this){
		var current=this.menu.currentItem;
		current.style.backgroundColor=current.bg;
		if(current.getElementsByTagName('a').length==1)current.getElementsByTagName('a')[0].style.color=current.fc;
		else current.style.color=current.fc;
		if(current.hasMore)current.style.backgroundImage="url("+current.imageSrc+")";
	}
	this.menu.currentItem=this;
	if(this.hasMore){
		this.style.backgroundImage="";
		this.showCM();
	}
	status=this.linktxt;
	};
	
function rowOut(){
	if(!this.menu.hasCVisible){
		this.style.backgroundColor=this.bg;
		if(this.getElementsByTagName('a').length==1)this.getElementsByTagName('a')[0].style.color=this.fc;
		else this.style.color=this.fc;
		if(this.hasMore)this.style.backgroundImage="url("+this.imageSrc+")";
	}
	};
	
function showL(){
	if(this.tree.treeParent!=this){
		this.style.visibility="visible";
		this.isOn=true;
	}
	};
	
function hideL(){
	if(this.tree.treeParent!=this){
		this.style.visibility="hidden";
		this.isOn=false;
	}
	if(this.currentItem){
		var current=this.currentItem;
		current.style.backgroundColor=current.bg;
		if(current.getElementsByTagName('a').length==1)current.getElementsByTagName('a')[0].style.color=current.fc;
		else current.style.color=current.fc;if(current.hasMore)current.style.backgroundImage="url("+current.imageSrc+")";
	}
	this.currentItem=null;


};
	
function hideT(){
	clearTimeout(mHT);
	if(mOM)return;
	if(this.hasCVisible)this.hideChildren(this);
	var menu=this;menu.hideL();
	while(menu.hasParent){
		menu=menu.parentMenu;menu.hideL();
	}
	if(hiddenElmnts)showF();
	};
	
function showCM(){
	var menu=this.menu;
	var c_s=this.child.style;
	if(menu.id.charAt(4)==1){
		c_s.top=(parseInt((menu.style.top)?menu.style.top:menu.offsetTop)+this.offsetTop)+"px";
		c_s.left=(parseInt((menu.style.left)?menu.style.left:menu.offsetLeft)+parseInt(this.style.width))+"px";
	}
	else {
	c_s.top="-"+parseInt(c_s.height)+"px";
	c_s.left="0px";
	}
	menu.hasCVisible=true;
	menu.visibleChild=this.child;
	this.child.showL();
};

function hideCM(caller){
	var menu=this.visibleChild;
	while(menu.hasCVisible){menu.visibleChild.hideL();
	menu.hasCVisible=false;menu=menu.visibleChild;
	}
	if((caller&&(!caller.hasMore||this.visibleChild!=caller.child))||(!caller&&this.isOn)){
		this.visibleChild.hideL();
		this.hasCVisible=false;
	}
	};
	
function goTo(){if(this.linktxt.indexOf("javascript:")!=-1)eval(this.linktxt);else window.location.href=this.linktxt;};