var undef='undefined', tt=[], tcm={tnd:0,_tmv:null,t1i:-1,tv:null,tba:null};

presColor	= '#AA0000';
DisabledColor = '#AAAAAA';
levelX = 10;
ItemClick = 1;

function Setting() { 
	with(tcm){
		t1i=0;tv=null;tba=null;
	} 
	if(!tmenuWidth) 
		tmenuWidth = '200'; 
}
function check(V,def){ return(typeof(V)!=undef&&V)?V:def; }
function checkItem(tv){ 
	if(!tv) 
		return null; 
	if(tv.thc) 
		return tv.tii[0]; 
	var tba=tv._tpii; 
	if(!tba) 
		return null; 
	if(tv.tnd<tba.tii.length-1) 
		return tba.tii[tv.tnd+1]; 
	if(tv.tnd==tba.tii.length-1){ 
		while(tba._tpii){
			with(tba) 
				if(_tpii.tii[tnd+1]) 
					return _tpii.tii[tnd+1]; 
			tba=tba._tpii;
		} 
		return null;
	}
}

function isIcon(d) { 
	if(d.indexOf('.gif')>0||d.indexOf('.GIF')>0) 
		return 1; 
	return 0;
}
function addPath(d, path) { 
	for(var i=0;i<d.length;i++) 
		if(d[i]&&isIcon(d[i])) 
			d[i]=path+d[i]; 
	return d;
}
function leftX(){
	return {twb:bExpandBtn[0],tIx:TitleBackCol[0],twl:titleLeft,twp:4,twm:sTitleImg[0]}; 
}
function titleSet() { 
	return {tbc:itemBackCol[0],tbi:itemBackImg,tfn:tfontColor[1],tf1:tfontStyle[0],tdf:tfontDecor[0]}; 
}
function gSt(tis){ 
	if(typeof(tis)==undef) 
		return leftX(); 
	return {twb:bExpandBtn[1], tIx:TitleBackCol[1],twl:titleLeft,twp:4,twm:sTitleImg[1]}; 
}
function iSt(tis){ 
	if(typeof(tis)==undef) 
		return titleSet(); 
	return {tbc:itemBackCol[1],tbi:itemBackImg,tfn:tfontColor[tis],tf1:tfontStyle[1],tdf:tfontDecor[1]}; 
}
function initMenu(tci){ 
	tt[tci]={tii:[],tnd:tci,id:'jf_t'+tci,_tpii:null,txl:0,tnc:0,tap:tabsolute,left:tleft,top:ttop, width:tmenuWidth, height:0, tbc:menuBackCol,tbi:menuBackImg, tbs:expBtn, tai:iconAlign, tib:0, tpdi:'', tsi1:titleSet(),tis1:leftX(), tsp:'',tsl:0,tse:[]};tcm._tmv=tt[tci];
}

function subTxt(tss) { return tss.substring(1,tss.length);}
function icon(ic){
	var tc0=check(ic[2],''), tc1=check(ic[3],tc0), tc2=check(ic[4],tc1); 
	return[tc0,tc1,tc2];
}
function createItem(tmp,tir,tipr,tllv,t1i){
	var txt=tipr[0],ti1=tmp.id+'i'+tmp.tnc,thi=0; 
	if(txt.charAt(0)=='#'){
		thi =1; 
		txt = subTxt(txt);
	} 
	var texp = 0; 
	if(txt.charAt(0)=='+'){
		txt = subTxt(txt); 
		texp=1;
	} 
	texp=(texp&&!thi); 
	if(txt.charAt(0)=='>') {
		txt = subTxt(txt); 
		tmp.tpdi=ti1;
	} 
	var tli = check(tipr[1],''), tar="_blank";
	if(!tir)
		tir=tmp; 
	else 
		tir.thc=1; 
	var tnx=(t1i>-1)?t1i:tir.tii.length; 
	tir.tii[tnx]={tii:[],tmi:tmp.tnd,tnd:tnx,id:ti1,_tpii:tir,tvl:tllv, tptm:'',thc:0,exp:texp?1:0,text:txt,link:tli,target:tar,tip:check(tipr[5],''), cursor:itreeCursor,tst:iSt(tipr[7]),tws:gSt(tipr[8]),tic:addPath(icon(tipr),P), tiv:1,tih:thi, til:0,_ttm:null};
	with(tmp){
		if(tllv>txl)
			txl=tllv;
		tnc++;
	}
	with(tcm){
		_tmv=tmp;t1i=tnx;tv=tir.tii[tnx];tba=tir;
	}
}
function itemLevel(name){ 
	var level=0; 
	while(name.charAt(level)=='#') 
		level++; 
	return level;
}
function openItem(tv){
	with(tv){ 
		if(tvl > 1) 
			tiv = (_tpii.exp&&!_tpii.tih); 
		else tiv=1; 
		exp=(thc&&exp&&tiv&&!tih)?1:0;
	}
}
function createMenu() { 
	var tpl=-1,tcl=0,ttl; 

	for(var j=0; (j<tItems.length&&typeof(tItems[j])!=undef); j++) { 
		tcl=itemLevel(tItems[j][0]); 
		tItems[j][0]=tItems[j][0].substring(tcl,tItems[j][0].length); 
		with(tcm){
			if(tpl<tcl) 
				tba=tv; 
			if(tpl>tcl) 
				for(var i=0;i<tpl-tcl;i++) 
					tba=tba._tpii; 
			createItem(_tmv,tba,tItems[j],tcl,-1);
		} 
		tpl=tcl;
	} 
	var tv=tcm._tmv.tii[0]; 
	do{openItem(tv);} while((tv=checkItem(tv)))
}
function objectId(id,style){
	return'<DIV id="'+id+'" style="'+style+'">';
}
function sTable(id, style,title,event,tr){ 
	return'<table id="'+id+'" '+title+' cellspacing=0 cellpadding=0 '+event+' style="'+style+'" border=0>'+(tr?'<tr>':'');
}
function setText(id,style,title,tml){
	return'<td id="'+id+'" '+title+' style="'+style+'">'+tml+'</td>';
}
function SetImg(id,url,w,h,event){ 
	return'<img id="'+id+'" src="'+url+'" width='+w+' height='+h+' '+event+' border=0>';
}
function setHead(tv){ 
	var q=''; 
	with(tv){ 
		for(var i=tvl;i>=0;i--) 
			q += setText('','','',SetImg('',tblankImage,levelX,1,''));
	} 
	return q;
}
function itemAction(tm,tv){ 
	with(tv){
		var event='onMouseDown="OnDownItem(\''+id+'\')"'; 
		return setText('','','', SetImg(id+'btn',(thc?(exp?tm.tbs[1]:tm.tbs[0]):tblankImage),expBtnW,expBtnH,event));
	} 
}
function iIcon(tv){ 
	with(tv){ 
		if(tic[0]) 
			return setText('','','',SetImg(id+'icon',tic[0],iconW,iconH,''));
		else
			return ''; 
	} 
}

function hideFont(tv){
	with(tt[tv.tmi])
		with(tv)
			with(tst)
				return '<span id="'+id+'font" style = "color:'+DisabledColor+'; font:'+tf1+'; font-decoration:'+tdf[0]+'">'+text+'</span>';
}
function setItemText(tv) { 
	with(tv){ 
		if(!text) 
			return; 
		else 
			return setText(id+'textTD','width:100%;','nowrap align='+treeAlign,hideFont(tv)); 
	} 
}
function createTitle(tm,tv,td) { 
	with(tv) { 
		var q = sTable(id,'width:100%; cursor:pointer','','title = "'+tip+'" onMouseOver = "titleOver(\''+id+'\',1)" onMouseOut = "titleOver(\''+id+'\',0)" onClick = "titleClick(\''+id+'\')"',0)+'<tr style="display:'+td+'">'; 
		var ttd = setText(id+'textTD','width:100%; background:'+tws.tIx+' url('+tws.twm+') repeat-y','',hideFont(tv)); 
		var tbm=exp?tws.twb[2]:tws.twb[0]; 
		if(tic[0]) 
			q += setText('','','rowspan=2',SetImg('',tic[0],IconW,IconH,'')) + setText('','height:'+(IconH-BtnH)+'px','colspan=2','')+'</tr><tr>' + ttd + setText('','','',SetImg(id+'btn',tbm,BtnW,BtnH,'')); 
		else 
			q += setText('','height:'+BtnH+'px','',SetImg('',tws.twl,tws.twp,BtnH,'')) + ttd + setText('','','',SetImg(id+'btn',tbm,BtnW,BtnH,'')); 
		q += '</tr></table>' + objectId(id+'divXP','width:100%; position:relative; overflow:visible; height:auto;'+(exp?'':'display:none;')) + objectId(id+'divXP2','width:100%; height:auto; position:relative; top:0px; left:0px; filter:blendTrans(duration=0.2);') + sTable(id+'tbl','border:solid 0px; width:100%;background:'+tm.tbc+' url('+tm.tbi+') repeat','','',0);
	} 
	return q;
}
function eTable(){
	return '</table>'+'</DIV></DIV>'+objectId('','height:10px;font-size:1px;')+'</DIV>';
}
function Title(tm,tv,td){
	with(tv)
		return '<tr id="'+id+'tr" style="display:'+td+'"><td>'+sTable(id,'cursor:'+cursor+';background:'+tst.tbc[0]+' url('+tst.tbi[0]+') repeat;width:100%','title="'+tip+'"','onMouseOver="OnMove(\''+id+'\',1)" onMouseOut="OnMove(\''+id+'\',0)" onClick="Click(\''+id+'\')" ',1)+((tm.expBtnAlign!='right')?setHead(tv)+itemAction(tm,tv):'')+((tm.tai!='right')?iIcon(tv):'')+setItemText(tv)+((tm.tai=='right')?iIcon(tv):'')+((tm.expBtnAlign=='right')?itemAction(tm,tv)+setHead(tv):'')+'</tr></table></td></tr>';
}
function treeMenuInit(){ 
	Setting(); 
	with(tcm){ 
		initMenu(tnd); 
		createMenu(); 
		var tm=_tmv;
	}
	var q='',tv=tm.tii[0],tpr1,td;
	with(tm){
		q+=objectId(id+'div','background:'+tbc+' url('+tbi+') repeat;border:solid 0px;'+'width:'+width+'; position:'+(tap?'absolute':'static')+';height:'+(height?height:'auto')+';left:'+left+'px;top:'+top+'px;z-index:1000;'+(height?'overflow:auto':''),''); 
		do{
			with(tv){
				td=(!tih&&(tiv||tvl<=1))?'':'none'; 
				if(!tvl) 
					q += createTitle(tm,tv,td);
				else 
					q += Title(tm,tv,td);
			}
			if(!checkItem(tv)||checkItem(tv).tvl==0)
				q += eTable();
		}while((tv=checkItem(tv)))
	}
	document.write(q); 
	tcm.tnd++;
}
function ObjectOnId(id) { 
	var tv; 
	for( var i = 0; i < tt.length; i++) { 
		tv=tt[i].tii[0]; 
		do { 
			if(tv.id==id) 
				return tv;
		} while((tv=checkItem(tv)))
	} 
	return null;
}
function checkValue(V) { return(V<1)?1:V; }
function Measure(tdi,tmi,t1i,tin){ 
	var tm=tt[tmi],tv=tm.tii[t1i],tsd=GetId(tdi),tsd1=GetId(tdi+'2'),toh=tsd1.offsetHeight,tcd=0; 
	with(tsd)
		var th = style.height?parseInt(style.height):offsetHeight; 
	if(tin==-1){
		tcd=(th>1); 
		th -= th;
	}
	else{
		tcd=(th<toh);
		if(tcd) 
			th += checkValue(toh-th);
			if(th>toh){
				th=toh;tcd=0;
			}
	} 
	if(tcd){
		tsd.style.height=th+'px';
		tsd1.style.top=th-toh+'px';
	}
	else{
		window.clearInterval(tv._ttm);
		tv._ttm=null; 
		if(tin==-1) 
			tsd.style.display='none'; 
		else 
			with(tsd.style){
				overflow='visible'; 
				height='auto';
			} 
		tm.tib--;
	}
}
function setStyle(tob,tvi) { 
	with(tob.filters[0]) { 
		apply(); 
		tob.style.visibility = tvi; 
		play(); 
	} 
}
function titleClick( ti1, tsc ) { 
	var tv = ObjectOnId(ti1),tm = tt[tv.tmi]; 
	with(tv) { 
		if(_ttm) 
			return; 
		tm.tib++; 
		var tbo = GetId(id+'btn'), tsd = GetId(id+'divXP'), tdd = tsd.style, tsd1 = GetId(id+'divXP2'); 
		if(exp) { 
			exp=0;
			if(tbo&&tws.twb[1])
				tbo.src=tws.twb[1];
			with(tdd){
				height=tsd.offsetHeight+'px'; 
				overflow = 'hidden';
			} 
			_ttm = setInterval('Measure("' + tsd.id+'",'+tmi+','+tnd+',-1)',5); 
		} 
		else {
			exp = 1; 
			if(tbo&&tws.twb[3]) 
				tbo.src = tws.twb[3]; 
			tdd.display=''; 
			with(tdd) { 
				height='1px'; 
				overflow='hidden';
			} 
			_ttm = setInterval('Measure("'+tsd.id+'",'+tmi+','+tnd+',+1)',5); 
		}
	} 
	with(tm){ 
		if(tv.exp&&tsc != 1) 
			for(var i=0;i<tii.length; i++) 
				if(tii[i].id != ti1&&tii[i].exp) 
					titleClick(tii[i].id,1); 
	}
}
function titleOver( ti1, tvo ) {
	var tv = ObjectOnId(ti1);
	with(tv) {
		changeColor(tv, GetId(id+'font').style, tvo);
		with(tws)with(GetId(id+'btn')){ if(exp) tvo += 2; if(twb[tvo]) src = twb[tvo]; }
	}
}
function changeColor(tv,tsf,tvo,tpr){ 
	with(tv)with(tsf){
		if(tpr)
			color=tt[tmi].presColor; 
		else 
		with(tst){
			color=tfn[tvo]; 
			textDecoration=tdf[tvo];
		}
	}
}
function OnMove(ti1,tvo){ 
	var tv = ObjectOnId(ti1);
	if(!tv)
		return;
	with(tv){
		var tpr=(tt[tmi].tpdi==id); 
		changeColor(tv,GetId(id+'font').style,tvo,tpr); 
		if(tpr||exp)
			tvo=2;
		var tco=GetId(id+'icon');
		if(tco)
			tco.src=tic[tvo];
	}
}

function Click( ti1 ) {
	if( typeof(userClick)=='function' && !userClick(ti1) )
		return false;

	var tv = ObjectOnId(ti1), tm = tt[tv.tmi], id = 0;
	with(tv) {
		if(tm.ItemClick && thc)
			Execute(tv, !exp);
	
		if( link ) { 
			if( link == "Job" || link == "Message" ) {
				ShowMailForm( link );
				return;
			} 

			if(link=="menu") {
				ShowInfos(text);
				return;
			}

			var ext = link.substring( link.length-4, link.length ).toLowerCase();
			if( ext != "html" && ext != ".htm" && link.substring(0,4) != "http" && link.substring(0,6) != "mailto") {
				SetData( link );
				return;
			}

			if( link.toLowerCase().indexOf('javascript:') == 0)
				eval( link.substring(11, link.length) );
			else 
			if( !target || target == '_self' )
				location.href = link;
			else 
				open( link, target );
		}
	}
}

function OpenCloseItem(tv,tvi) { 
	with(tv){
		tiv=tvi; 
		if(tih) 
			return; 
		GetId(id+'tr').style.display=tvi?'':'none'; 
		if(!tvi) 
			exp=0;
	}
}

function Execute(tv,texp){
	var tm=tt[tv.tmi];
	if(!tv.thc||tv.tih||tv.til)
		return;
	var tbo=GetId(tv.id+'btn');
	if(texp){
		with(tv){
			for(var i=0;i<tii.length;i++) 
				OpenCloseItem(tii[i],1);
			exp=1;
			tbo.src=tm.tbs[1]; 
			OnMove(id,1);
		}
	}
	else{
		with(tv){
			for(var i=0;i<tii.length;i++){
				if(tii[i].thc&&tii[i].exp){ 
					Execute(tii[i],0);
					GetId(tii[i].id+'btn').src=tm.tbs[0];
				} 
				OpenCloseItem(tii[i],0);
			}
			exp=0;
			tbo.src=tm.tbs[0]; 
			OnMove(id,0);
		}
	} 
}
function OnDownItem(ti1) { 
	var tv = ObjectOnId(ti1), tm=tt[tv.tmi]; 
	with(tv){
		with(tm){
			var tit = tm.tii[0]; 
		if(!exp) 
			do { 
				if(tit.tvl==tv.tvl&&tit.exp&&tit.id!=tv.id) 
					Execute(tit,0);
			} while((tit=checkItem(tit))); 
			Execute(tv,!exp); 
		}
	}
}
function GetId(id) { 
	if(!id) 
		return null; 
	else
		return document.getElementById(id); 
}

function SetData( name ) {
	LoadData(name);
	ShowData(); 
}

