/*
CrossBrowser Menu Advanced ver0.25 [200211232345]
Copyright 2001-2002 Mugi
mail : mugi@email.ee
site : http://mugi.ca.tc/
*/

var menu=new Array()
var opened=new Array()
var next=new Array()
var hover=new Array()
var menuid=new Array()
var paritm=new Array()
var border=new Array()
var shift=new Array()
var mouse=0
var tlen=0
var idcheck="@"
var wait=150
var dir=1
var vert=false
var hidetimer=null
var sec=600000
var popup=""
var oflag=0
var pflag=0
var rflag=1
var op=!!window.opera&&!!document.createTextNode
var ie=!op&&!!document.all&&navigator.platform=="Win32"
var nn=!op&&navigator.appName=="Netscape"&&navigator.appVersion.charAt(0)=="4"
var gk=(navigator.userAgent.match(/Gecko/i)!=null)
var mac=navigator.platform.indexOf("Mac")!=-1
var me=!op&&mac&&document.all&&document.getElementById
if(me){gk=true;ie=false}
var mark="&gt;&gt;"
if(gk&&!document.all){document.all=document.getElementById}

function changevis(id,visible){
if(ie||gk||op){
document.all(id).style.visibility=(visible?"inherit":"hidden")
document.all(id).style.display=(visible?"":"none")
}else
if(nn){
popup.document.layers[id].visibility=(visible?"inherit":"hide")
}
}

top.onresize=window.onresize=new Function("if(!rflag&&(!nn||nn&&document.layers.length==0)){location.reload()}")

function add(id,txt,loc,msg,par){
if(arguments.length<5){par=msg;msg=null}
var a=paritm[par]||menu
a[id]=new Array()
a[id][0]=txt
a[id][1]=loc
a[id][2]=msg
paritm[id]=a[id]
}

function createlayer(id,z,win){
if(ie){
var r=document.body.createTextRange()
r.collapse(false)
r.pasteHTML("<span id="+id+" style=z-index:"+z+";text-align:left;position:absolute;left:0;top:0;height:"+h+";visibility:hidden>&nbsp;</span>")
return document.all(id)
}else
if(gk||op){
var e=document.createElement("div")
e.id=id
if(me){
e.style.position="absolute"
e.style.zIndex=z
e.style.left=0
e.style.top=0
e.style.height=h
e.style.visibility="hidden"
}else{
e.setAttribute("style","z-index:"+z+";position:absolute;left:0;top:0;height:"+h+";visibility:hidden")
}
document.body.appendChild(e)
return document.getElementById(id)
}else
if(nn){
var lay=new Layer(w,win)
lay.moveTo(0,0)
lay.resizeTo(window.innerWidth,h)
lay.clip.height=window.innerHeight
lay.document.open()
lay.document.write("")
lay.document.close()
lay.zIndex=z
lay.visibility="hide"
return lay
}
}

function _setTimeout(s,n){if(type==1||n<=0){eval(s)}else{setTimeout(s,n)}}

function nnscrfix(){
if(type==0&&document.layers){
var realheight=0
for(var i=0;i<document.layers.length;i++){
if(document.layers[i].visibility!="hide"&&document.layers[i].pageY+document.layers[i].clip.height>realheight){
realheight=document.layers[i].pageY+document.layers[i].clip.height
}
}
document.height=realheight
setTimeout("nnscrfix()",1000)
}
}

window.onload=init
function init(){
if(mouse==1||mouse==0&&ie&&!window.print||me||op){mouse=-1}
if(mouse==2&&!(ie&&!window.print)){mouse=0}
if(type!=2){popup=""}
if(type!=0){if(type<0)vert=true;type=1;wait=0}
if(type==1){document.onmousedown=function(){hoveract(0,null);hidemenu(0,1);if(mouse==1){mouse=-1}}}
if(popup==""){
if(ie||gk||op){popup=document.body}else
if(nn){popup=window}
}else{
pflag=1
if(ie||me){
if(popup=="window"){
document.oncontextmenu=function(){window.event.returnValue=false}
document.onmousedown=showpopup
}else{
document.all(popup).oncontextmenu=function(){window.event.returnValue=false}
document.all(popup).onmousedown=showpopup
}
}else
if(gk||op){
if(popup=="window"){
document.onmousedown=showpopup
}else{
document.getElementById(popup).onmousedown=showpopup
}
}else
if(nn){
if(popup=="window"){
document.captureEvents(Event.MOUSEDOWN)
document.onmousedown=showpopup
}else{
document.layers[popup].captureEvents(Event.MOUSEDOWN)
document.layers[popup].onmousedown=showpopup
}
}
popup=createlayer("popup",100,window)
}
comment=createlayer("comment",101,popup)
var s=createmenu("$root",menu,0,0,0)
showmenu("$root",0)
if(ie||gk||op){
document.all(border[0]).style.width=w*s+2+(gk&&!me||op?2:0)
document.all(border[0]).style.height=h*Math.ceil((menuid["$root__"].split("@").length-1)/s)+2
}else
if(nn){
popup.document.layers[border[0]].resizeTo(w*s+2,h*Math.ceil((menuid["$root__"].split("@").length-1)/s)+2)
}
setTimeout("rflag=0;nnscrfix()",0)
}

function createmenu(a,menu,n,o,p){
var b=false,s,arrow,m=0,hide,show,comm,link,none,over,down
a+="__"
for(var i in menu){
if(idcheck.indexOf("@"+i+"@")!=-1){continue}
idcheck+=i+"@"
if(i+""!="0"&&i+""!="1"&&i+""!="2"){
b=true
if(!menuid[a]){menuid[a]=""}
if(type==1&&p==0&&(pflag&&n>0||x+w*n+w>(window.innerWidth||document.body.clientWidth))){m=n;n=0;y+=h}
if(type==1&&p>0&&!pflag&&(dir<0||x+w*(n+1+1)>(window.innerWidth||document.body.clientWidth))){dir=-1}
if(type==0||vert&&p==0){n=0}
if(dir==-1&&x+w*(n-1)<0){dir=1}
s=createmenu(a+i,menu[i],n+1*dir*type-dir*(!vert&&!pflag&&type==1&&p==0?1:0),o+(type==0?1:0)+(!vert&&!pflag&&type==1&&p==0?1:0),p+1)
arrow=((p>0||type==0)&&s?ie?"</td><td align=right style=font-size:7px>"+mark+"&nbsp;&nbsp;":"<div style=position:relative;text-align:right;font-size:7px;top:-"+font+">"+mark+"&nbsp;&nbsp;</div>":"")
hide="hidemenu("+p+");hoveract("+p+",this,"+(menu[i][0]=="---")+");"
show="showmenu('"+a+i+"',"+(p+1)+");"
comm=";changevis(comment.id,false)"+(!menu[i][2]?"":";showcomm(menu['"+(a+i).replace((ie||me||op?"":"\\")+"$root__","").replace(/__/g,"']['")+"'],"+(ie||me||op?"window.event.clientX":"event.pageX")+","+(ie||me||op?"window.event.clientY":"event.pageY")+")")
link="setTimeout('tlen=0',0);go('"+menu[i][1]+"')"
none=(me?"":";void(0)")+(ie||gk||op?";if(me){event=window.event};event.cancelBubble=true":"")
over=((type==1?hide+(s?show:none):none)+comm+";clearTimeout(hidetimer)")
down="if(tlen==0){"+(menu[i][0]=="---"?none:hide+(s?(type==1?none:show):link+none))+"}"
_font=font
if(menu[i][0].match(/(<img)([^>]+>)/)!=null){menu[i][0]=menu[i][0].replace(/<img/g,"<img align=absmiddle");_font=h}
if(ie){
if(!border[p]){
var r=document.body.createTextRange()
r.moveToElementText(popup)
r.collapse(pflag)
r.pasteHTML("<div id=border"+p+" style=z-index:"+(10+2*p-1)+";font-size:1px;position:absolute;display:none;width:"+(w+2)+";background:"+bc+"></div>")
border[p]="border"+p
}
var r=document.body.createTextRange()
r.moveToElementText(popup)
r.collapse(pflag)
r.pasteHTML("<table cellspacing=0 cellpadding=0 id="+a+i+" onmouseover=\""+over+"\" onmousedown=\"if(window.event.button==1){"+down+"}\" onmouseout="+(type==0?"changevis(comment.id,false)":"hidetimer=setTimeout('document.onmousedown()',sec)")+" style=z-index:"+(10+2*p)+";text-align:left;cursor:default;display:none;overflow:hidden;position:absolute;color:"+fg+";background-color:"+bg+";font-size:"+font+"px;left:"+(x+w*n)+";top:"+(y+h*o)+";width:"+w+";height:"+h+";clip:rect(0,"+w+","+h+",0)><tr valign=middle><td nowrap style=padding-left:"+(2+!type*10*p)+">"+(menu[i][0]=="---"?"<hr width="+(w-4-!type*10*p-4)+">":menu[i][0]+arrow)+"</td></tr></table>")
menuid[a]+="@"+a+i
}else
if(nn){
if(!border[p]){
var lay=new Layer(w,popup)
lay.zIndex=(10+2*p-1)
lay.clip.width=w+2
lay.bgColor=bc
border[p]=lay.id
}
var lay=new Layer(w,popup)
lay.document.open()
lay.document.write(menu[i][0]=="---"?"<hr style=padding-left:"+(2+!type*10*p)+" width="+(w-4-!type*10*p-4)+">":"<table cellspacing=0 cellpadding=0 border=0 height="+(h*2)+"><tr><td width="+w+" valign=middle><a href=# style=font-size:"+font+"px;color:"+fg+";text-decoration:none;padding-left:"+(2+!type*10*p)+">"+menu[i][0]+"</a></td>"+((p>0||type==0)&&s?"<td align=right style=font-size:7px;color:"+fg+">"+mark+"</td>":"")+"</tr>"
+"<tr><td nowrap valign=middle><a href=# style=font-size:"+font+"px;color:"+hf+";text-decoration:none;padding-left:"+(2+!type*10*p)+">"+menu[i][0]+"</a></td>"+((p>0||type==0)&&s?"<td align=right style=font-size:7px;color:"+hf+">"+mark+"</td>":"")+"</tr></table>")
lay.document.close()
lay.bgColor=bg
lay.moveTo(x+w*n,y+h*o)
lay.resizeTo(w,h)
lay.clip.width=w
lay.clip.height=h
lay.zIndex=(10+2*p)
lay.visibility="hidden"
lay.captureEvents(Event.CLICK)
lay.onclick=new Function("event",down+";return false")
lay.onmouseover=new Function("event",over)
lay.onmouseout=new Function(type==0?"changevis(comment.id,false)":"hidetimer=setTimeout('document.onmousedown()',sec)")
menuid[a]+="@"+lay.id
}else
if(gk||op){
if(!border[p]){
var e=document.createElement("div")
e.id="border"+p
if(me){
e.style.position="absolute"
e.style.zIndex=(10+2*p-1)
e.style.display="none"
e.style.width=(w+2)
e.style.backgroundColor=bc
}else{
e.setAttribute("style","z-index:"+(10+2*p-1)+";position:absolute;display:none;width:"+(w+2*2)+";background:"+bc)
}
popup.appendChild(e)
border[p]="border"+p
}
var e=document.createElement("div")
e.innerHTML="<nobr>"+(menu[i][0]=="---"?"<hr size=1 width="+(w-4-!type*10*p)+">":menu[i][0]+arrow)+"</nobr>"
e.id=a+i
if(me){
e.style.position="absolute"
e.style.zIndex=(10+2*p)
e.style.cursor="default"
e.style.display="none"
e.style.overflow="hidden"
e.style.paddingLeft=(2+!type*10*p)
e.style.paddingTop=((h-_font)/2)
e.style.color=fg
e.style.backgroundColor=bg
e.style.fontSize=font+"px"
e.style.left=(x+w*n)
e.style.top=(y+h*o)
e.style.width=(w-(me?0:!type*10*p))
e.style.height=(h-(me?0:(h-_font)/2))
}else{
e.setAttribute("style","z-index:"+(10+2*p)+";cursor:default;display:none;overflow:hidden;padding-left:"+(2+!type*10*p)+";padding-top:"+((h-_font)/2)+";position:absolute;color:"+fg+";background-color:"+bg+";font-size:"+font+"px;left:"+(x+w*n)+";top:"+(y+h*o)+";width:"+(w-!type*10*p)+";height:"+(h+(op?1:0)-(h-_font)/2))
}
e.onmouseover=new Function("event",over)
e.onmousedown=new Function("event","if("+(me?"window.event.button":"event.which")+"==1){"+down+"}")
e.onmouseout=new Function(type==0?"changevis(comment.id,false)":"hidetimer=setTimeout('document.onmousedown()',sec)")
popup.appendChild(e)
menuid[a]+="@"+a+i
}
if(p==0){
if(type==0||vert&&p==0){o++}
changevis(nn?lay.id:a+i,true)
n++
}else{
o++
}
}
}
return p==0?m>0?m:n:b
}

function hoveract(n,item,hr){
if(n>0&&!pflag){
if(ie||gk||op){
hover[0].style.color=fg
hover[0].style.backgroundColor=bg
}else
if(nn){
hover[0].bgColor=bg
if(hover[0].clip.top>0){
hover[0].clip.top=0
hover[0].clip.bottom=h
hover[0].top+=h
}
}
}
if(type==0){
for(var i=0;i<hover.length;i++){
if(hover[i]==item){oflag=1;setTimeout("hover.length="+i,0);break}
}
}
for(var i=(type==0?0:n);i<hover.length;i++){
if(ie||gk||op){
hover[i].style.color=fg
hover[i].style.backgroundColor=bg
}else
if(nn){
hover[i].bgColor=bg
if(hover[i].clip.top>0){
hover[i].clip.top=0
hover[i].clip.bottom=h
hover[i].top+=h
}
}
}
if(item&&!hr&&!oflag){
hover[n]=item
if(ie||gk||op){
hover[n].style.color=hf
hover[n].style.backgroundColor=hb
}else
if(nn){
hover[n].bgColor=hb
hover[n].clip.top=h
hover[n].clip.bottom=h*2
hover[n].top-=h
}
}
}

function showmenu(id,d){if(tlen!=-1){if(tlen==0||type==1){_showmenu(id,d)}else{setTimeout('setTimeout(\'_showmenu("'+id+'",'+d+')\',0)',wait*tlen);tlen=-1};if(id=="$root"){tlen=0}}}
function _showmenu(id,d){
if(id!=""){id+="__"}
if(oflag){oflag=0;tlen=0}else{
var a=menuid[id].split("@")
var top=(ie||me?"pixelTop":"top")
if(type==0){
shift[d]=new Array()
shift[d][0]=h*(a.length-1)
shift[d][1]=d-1
for(var x=0;x<opened.length;x++){
for(var i=1;i<opened[x].length;i++){
if(ie||gk||op){
if(parseInt(eval("document.all(opened["+x+"]["+i+"]).style."+top))>=parseInt(eval("document.all(a[1]).style."+top))){
for(var t=1;t<a.length;t++){
_setTimeout('document.all(opened['+x+']['+i+']).style.top=parseInt(document.all(opened['+x+']['+i+']).style.top)+h',t*wait)
}
shift[d][shift[d].length]=opened[x][i]
}
}else
if(nn){
if(document.layers[opened[x][i]].top>=document.layers[a[1]].top){
for(var t=1;t<a.length;t++){
_setTimeout('document.layers[opened['+x+']['+i+']].moveBy(0,h)',t*wait)
}
shift[d][shift[d].length]=opened[x][i]
}
}
}
}
}
for(var i=1;i<a.length;i++){
_setTimeout('changevis("'+a[i]+'",true)',i*wait)
if(i==a.length-1){_setTimeout("tlen=0",i*wait)}
}
opened[opened.length]=a
if(type==1){
if(ie){
document.all(border[d]).style.pixelLeft=document.all(a[1]).style.pixelLeft-1
document.all(border[d]).style.pixelTop=document.all(a[1]).style.pixelTop-1
document.all(border[d]).style.pixelHeight=h*(a.length-1)+2
}else
if(nn){
popup.document.layers[border[d]].moveTo(popup.document.layers[a[1]].left-1,popup.document.layers[a[1]].top-1)
popup.document.layers[border[d]].clip.height=h*(a.length-1)+2
}else
if(gk||op){
document.getElementById(border[d]).style.left=parseInt(document.getElementById(a[1]).style.left)-1
document.getElementById(border[d]).style.top=parseInt(document.getElementById(a[1]).style.top)-1
document.getElementById(border[d]).style.height=h*(a.length-1)+2
}
changevis(border[d],true)
}
}
}

function hidemenu(depth,m){
depth++
for(var i=opened.length-1;i>=depth;i--){
for(var a=opened[i].length-1;a>=1;a--,tlen++){
_setTimeout('changevis("'+opened[i][a]+'",false)',(1+opened.length-1-i+opened[i].length-1-a)*wait)
}
changevis(border[i],false)
if(type!=0)tlen=0
}
opened.length=depth
for(var x=shift.length-1,c=0;x>=depth;x--,c++){
for(var i=shift[x].length-1;i>=2;i--){
for(var t=1;t<shift[x][0]/h+1;t++){
if(ie||gk||op){
_setTimeout('document.all("'+shift[x][i]+'").style.top=parseInt(document.all("'+shift[x][i]+'").style.top)-h',(t+c)*wait)
}else
if(nn){
_setTimeout('document.layers["'+shift[x][i]+'"].moveBy(0,-h)',(t+c)*wait)
}
}
}
shift.length=x
}
if(m&&pflag){
if(nn){
popup.visibility="hide"
popup.moveTo(0,0)
}else{
if(ie||gk||op){
changevis(popup.id,false)
popup.style.left=0;popup.style.top=0
if(gk||op){document.onmouseup=null}
}
}
}
changevis(comment.id,false)
}

function showpopup(e){
if(type==1&&!(nn&&e.target.constructor==self.Url)){
hoveract(0,null)
hidemenu(0,1)
}
if((mouse*=(Math.abs(mouse)==1?-1:1))!=-1){
if(ie||me){
if(mouse!=1&&window.event.button==2||mouse==1&&window.event.button==1){
popup.style.left=window.event.clientX+document.body.scrollLeft
popup.style.top=window.event.clientY+document.body.scrollTop
changevis(popup.id,true)
if(mouse==2){rflag=1;window.event.srcElement.blur();window.blur();setTimeout("setTimeout('self.resizeBy("+document.body.clientWidth+","+document.body.clientHeight+");window.focus();popup.focus();rflag=0',100)",100);self.resizeBy(-document.body.clientWidth,-document.body.clientHeight)}
window.event.cancelBubble=true
window.event.returnValue=false
}
}else
if(nn){
if(mouse!=1&&e.which==3||mouse==1&&e.which==1||mac&&e.modifiers==2){
popup.moveTo(e.pageX,e.pageY)
popup.visibility="show"
return false
}
}else
if(gk||op){
if(mouse!=1&&e.which==3||mouse==1&&e.which==1||mac&&e.ctrlKey){
document.oncontextmenu=function(){document.oncontextmenu=null;return false}
popup.style.left=e.pageX
popup.style.top=e.pageY
changevis(popup.id,true)
e.cancelBubble=true
return false
}
}
}
}

function showcomm(ar,x,y){
var html=ar[2]
if(!me){
html="<table cellpadding=0 cellspacing=0 bgcolor="+cb+"><tr><td style=color:"+cf+";font-size:"+font+"px nowrap>"+html+"</td></tr></table>"
}
if(ie||gk||op){
if(me){
while(comment.childNodes.length>0){
comment.removeChild(comment.childNodes[0])
}
var s=document.createElement("span")
s.style.color=cf
s.style.backgroundColor=cb
s.style.fontSize=font+"px"
s.innerHTML="<nobr>"+html+"</nobr>"
comment.appendChild(s)
}else{
comment.innerHTML=html
}
comment.style.left=x+(ie||me?document.body.scrollLeft:0)+10
comment.style.top=y+(ie||me?document.body.scrollTop:0)+10
if(ie&&!window.print){
var r=document.body.createTextRange()
r.moveToElementText(comment)
comment.style.width=r.boundingWidth
}
}else
if(nn){
with(comment.document){open();write(html);close()}
comment.pageX=x+10
comment.pageY=y+10
comment.clip.width=comment.document.width
comment.clip.height=comment.document.height
}
changevis(comment.id,true)
}

function go(url){
if(type==1){
hoveract(0,null)
hidemenu(0,1)
if(mouse==1){mouse=-1}
}
url=url.split(";")
if(url.length==1){
location.href=url[0]
}else
if(url[1].charAt(0)=="@"){
top.frames[url[1].substring(1)].location.href=url[0]
}else
if(url[1].charAt(0)=="*"){
window.open(url[0],url[1].substring(1))
}else
top.location.href=url[0]
}
