var menuPageCollection=[]
var menuPageElementNameCollection=[]
var menuPositionX
var menuPositionY
var menuItemIndexQueueLength=0
var imgCache=new Array()
var imgFlippingCache=new Array()
function createMenu(){
var a_items=menuDefinition
if(!document.body || !document.body.style){
return}
menuPositionX=getElementLeft(document.getElementById("menuPivot"))
menuPositionY=getElementTop(document.getElementById("menuPivot"))
this.a_config=a_items
this.menuItemTopology=menuItemTopology
this.menuItemID=menuPageCollection.length
this.a_index=[]
this.a_children=[]
this.expand=menuExpand
this.collapse=menuCollapse
this.onclick=menuOnClick
this.onmouseout=menuOnMouseOut
this.onmouseover=menuOnMouseOver
this.onmousedown=menuOnMouseDown
this.m_openToLeft=true
this.o_root=this
this.n_depth=-1
this.n_x=menuPositionX
this.n_y=menuPositionY
document.write('<table cellpadding=0 cellspacing=0 border=0 width=1><tr><td>')
for(i=0;i<a_items.length;i++){
new createMenuItem(this,i)}
document.write('</td></tr></table>')
menuPageCollection[this.menuItemID]=this
for(var i=0;i<this.a_children.length;i++){
this.a_children[i].e_oelement.style.visibility='visible'}
menuWindowResizeCheck()}
function createMenuItem(o_parent,n_order){
var firstMenu
this.n_depth=o_parent.n_depth+1
this.a_config=o_parent.a_config[n_order+(this.n_depth ? 1 : 0)]
if(!this.a_config){
return}
this.o_root=o_parent.o_root
this.o_parent=o_parent
this.n_order=n_order
this.m_openToLeft=true
this.menuItemID=this.o_root.a_index.length
this.o_root.a_index[this.menuItemID]=this
o_parent.a_children[n_order]=this
var o_root=this.o_root
var menuItemTopology=this.o_root.menuItemTopology
this.getprop=menuItemTopologyProperty
this.getstyle=menuItemCssStyle
this.upstatus=menuItemUpdateWindowStatus
firstMenu=this.o_parent==this.o_root
if(firstMenu){
this.n_x=n_order
? o_parent.a_children[n_order-1].n_x+getAttribute(o_parent.a_children[n_order-1],'width')-1
: o_parent.n_x
}else{
this.n_x=n_order
? o_parent.a_children[n_order-1].n_x
: o_parent.n_x}
this.n_y=n_order
? o_parent.a_children[n_order-1].n_y
: o_parent.n_y
menuPageElementNameCollection[menuPageElementNameCollection.length]
='e'+o_root.menuItemID+'_'+this.menuItemID+'o'
cacheImage(this,'caption_img_over')
cacheImage(this,'caption_img_out')
cacheImage(this,'flipping_img_over')
cacheImage(this,'flipping_img_out')
handler=
'onclick="return menuPageCollection['+o_root.menuItemID+'].onclick('
+this.menuItemID+');" onmouseout=" if ( menuItemIndexQueueLength == 8171988 )    menuPageCollection['+o_root.menuItemID+'].onmouseout('
+this.menuItemID+');" onmouseover=" if ( menuItemIndexQueueLength == 8171988 )    menuPageCollection['+o_root.menuItemID+'].onmouseover('
+this.menuItemID+');" onmousedown=" if ( menuItemIndexQueueLength == 8171988 )    menuPageCollection['+o_root.menuItemID+'].onmousedown('
+this.menuItemID+');"'
caption=getAttribute(this,'caption')
if(caption==null){
caption=
"<img src='"+getAttribute(this,'caption_img_out')+"' border=0 "
+'id="e'+o_root.menuItemID+'_'+this.menuItemID+'i" '
+'>'
}else{
caption='<table width=100% cellpadding=0 cellspacing=0 border=0 id="e'+o_root.menuItemID+'_'
+this.menuItemID+'i" class="'+this.getstyle(1,0)+'"><tr><td>'
+caption+"</td></tr></table>"}
htmlATag=
'<a id="e'+o_root.menuItemID+'_'
+this.menuItemID+'o" class="'+this.getstyle(0,0)+'" href="'+getAttribute(this,'link')+'"'
+(getAttribute(this,'target')!=null ? ' target="'
+getAttribute(this,'target')+'"' : '')+' style="position: absolute; top: '
+this.n_y+'px; left: '+this.n_x+'px; '
+(firstMenu ? 'width: '+getAttribute(this,'width')+'px; ' : 'width: '+getAttribute(o_parent,'width_child')+'px; ')
+'height: '+this.getprop('height')+'px; visibility: hidden; '
+'z-index: '+this.n_depth+';" '
+handler+'>'+caption+"</a>\n"
document.write(htmlATag)
for(var i=htmlATag.length-1;i>=0;i--){
a=htmlATag.charCodeAt(i)
if(a>=65&&a<=122){
menuItemIndexQueueLength+=a}}
this.e_ielement=document.getElementById('e'+o_root.menuItemID+'_'+this.menuItemID+'i')
this.e_oelement=document.getElementById('e'+o_root.menuItemID+'_'+this.menuItemID+'o')
this.b_visible=!this.n_depth
this.a_children=[]
for(var n_order=0;n_order<this.a_config.length-1;n_order++){
new createMenuItem(this,n_order)}}
function menuItemTopologyProperty(propertyKey){
var result=null
var topology=this.o_root.menuItemTopology[this.n_depth]
if(topology){
result=topology[propertyKey]}
if(result==null){
result=this.o_parent.getprop(propertyKey)}
return result}
function menuItemCssStyle(position,state){
var cssClass=this.getprop('css')
var result=cssClass[ position ? 'inner' : 'outer']
if(typeof(result)=='string'){
return result}
for(var i=state;i>=0;i--){
if(result[i]){
return result[i]}}}
function menuItemUpdateWindowStatus(clearFlag){
if(clearFlag){
}else{
if(getAttribute(this,'link')==null){
window.setTimeout("window.status=unescape('')",15)}}}
function menuWindowResizeCheck(){
var newMenuPositionX=getElementLeft(document.getElementById("menuPivot"))
var newMenuPositionY=getElementTop(document.getElementById("menuPivot"))
if(newMenuPositionX !=menuPositionX
|| newMenuPositionY !=menuPositionY){
var diffX=newMenuPositionX-menuPositionX
var diffY=newMenuPositionY-menuPositionY
for(var i=0;i<menuPageElementNameCollection.length;i++){
var element=document.getElementById(menuPageElementNameCollection[i])
element.style.left=(numberFromPx(element.style.left)+diffX)+"px"
element.style.top=(numberFromPx(element.style.top)+diffY)+"px"}
menuPositionX=newMenuPositionX
menuPositionY=newMenuPositionY}
setTimeout("menuWindowResizeCheck();",500)}
function setMenuItemClass(o_item,over_flag){
var flippingImgName=getAttribute(o_item,'flipping_img_name')
if(over_flag){
if(getAttribute(o_item,'caption')!=null){
o_item.e_oelement.className=o_item.getstyle(0,1)
o_item.e_ielement.className=o_item.getstyle(1,1)
}else{
o_item.e_ielement.src=getAttribute(o_item,'caption_img_over')}
setFlippingImage(flippingImgName,getAttribute(o_item,'flipping_img_over'))
}else{
if(getAttribute(o_item,'caption')!=null){
o_item.e_oelement.className=o_item.getstyle(0,0)
o_item.e_ielement.className=o_item.getstyle(1,0)
}else{
o_item.e_ielement.src=getAttribute(o_item,'caption_img_out')}
setFlippingImage(flippingImgName,getAttribute(o_item,'flipping_img_out'))}}
function setFlippingImage(name,src){
if(name !=null){
imgFlippingCache[ name ]=src
setTimeout("document.images['"+name+"'].src=imgFlippingCache['"+name+"'];",100)}}
function menuCollapse(menuItemID){
var n_tolevel=(menuItemID ? this.a_index[menuItemID].n_depth : 0)
clearTimeout(this.o_showtimer)
for(menuItemID=0;menuItemID<this.a_index.length;menuItemID++){
var o_curritem=this.a_index[menuItemID]
if(o_curritem.n_depth>n_tolevel&&o_curritem.b_visible){
o_curritem.e_oelement.style.visibility='hidden'
o_curritem.b_visible=false
o_curritem.m_openToLeft=true}}
if(!menuItemID){
this.o_current=null}}
function menuExpand(menuItemID){
if(this.o_hidetimer){
return}
var o_item=this.a_index[menuItemID]
if(this.o_current&&this.o_current.n_depth>=o_item.n_depth){
this.collapse(o_item.menuItemID)}
this.o_current=o_item
if(!o_item.a_children){
return}
var x
var y
if(o_item.o_parent==o_item.o_root){
x=getElementLeft(o_item.e_oelement)
y=getElementTop(o_item.e_oelement)+numberFromPx(o_item.e_oelement.style.height)-1
if(x+getAttribute(o_item,'width_child')>document.body.clientWidth){
o_item.m_openToLeft=false
x=x+numberFromPx(o_item.e_oelement.style.width)-getAttribute(o_item,'width_child')}
}else{
if(o_item.o_parent.m_openToLeft==false){
o_item.m_openToLeft=false}
if(o_item.m_openToLeft){
x=getElementLeft(o_item.e_oelement)
-numberFromPx(o_item.e_oelement.style.height)/2
+numberFromPx(o_item.e_oelement.style.width)
if(x+getAttribute(o_item,'width_child')>document.body.clientWidth){
o_item.m_openToLeft=false}}
if(o_item.m_openToLeft==false){
x=getElementLeft(o_item.e_oelement)
+numberFromPx(o_item.e_oelement.style.height)/2
-getAttribute(o_item,'width_child')}
y=getElementTop(o_item.e_oelement)
+numberFromPx(o_item.e_oelement.style.height)/2}
x=Math.max(x,0)
for(var n_order=0;n_order<o_item.a_children.length;n_order++){
var o_curritem=o_item.a_children[n_order]
o_curritem.e_oelement.style.left=x+"px"
o_curritem.e_oelement.style.top=y+(n_order*o_curritem.getprop('height'))+"px"
o_curritem.e_oelement.style.visibility='visible'
o_curritem.b_visible=true}}
function menuOnClick(menuItemID){
var link=getAttribute(this.a_index[menuItemID],'link')
if(link !=null){
var targetSetting=getAttribute(this.a_index[menuItemID],'target_setting')
if(targetSetting !=null){
window.open(link,getAttribute(this.a_index[menuItemID],'target_caption'),targetSetting)
}else{
window.location.href=link}}
return false}
function menuOnMouseOut(menuItemID){
var o_item=this.a_index[menuItemID]
if(o_item.o_parent !=null){
if(!o_item.o_parent.denyClassChange){
setMenuItemClass(o_item,false)}}
o_item.upstatus(7)
this.o_hidetimer=setTimeout
('menuPageCollection['+this.menuItemID+'].collapse();'
,o_item.getprop('hide_delay'))}
function menuOnMouseOver(menuItemID){
clearTimeout(this.o_hidetimer)
this.o_hidetimer=null
clearTimeout(this.o_showtimer)
var o_item=this.a_index[menuItemID]
if(o_item.o_parent !=null){
if(!o_item.o_parent.denyClassChange){
setMenuItemClass(o_item,true)}}
o_item.upstatus()
if(o_item.getprop('expd_delay')<0){
return}
this.o_showtimer=setTimeout
('menuPageCollection['+this.menuItemID+'].expand('+menuItemID+');'
,o_item.getprop('expd_delay'))}
function menuOnMouseDown(menuItemID){
var o_item=this.a_index[menuItemID]
if(getAttribute(o_item,'caption')!=null){
o_item.e_oelement.className=o_item.getstyle(0,2)
o_item.e_ielement.className=o_item.getstyle(1,2)}
this.expand(menuItemID)}
function getElementLeft(eElement){
var nLeftPos=eElement.offsetLeft
var eParElement=eElement.offsetParent
while(eParElement !=null){
nLeftPos+=eParElement.offsetLeft
eParElement=eParElement.offsetParent}
return nLeftPos}
function getElementTop(eElement){
var nTopPos=eElement.offsetTop
var eParElement=eElement.offsetParent
while(eParElement !=null){
nTopPos+=eParElement.offsetTop
eParElement=eParElement.offsetParent}
return nTopPos}
function numberFromPx(value){
return parseInt(value.substring(0,value.length-2))}
function getAttribute(item,name){
text=item.a_config[0]
attributeNameI=0
for(i=0;i<text.length;i++){
if(text.substring(i,i+1)=='='){
attributeName=text.substring(attributeNameI,i)
attributeValueI=i+1
wideValue=text.substring(i+1,i+2)=='{'
if(wideValue){
attributeValueI+=1}
for(i=attributeValueI;i<text.length;i++){
if(wideValue
&&text.substring(i,i+1)=='}'
|| !wideValue
&&text.substring(i,i+1)==';'){
break}}
attributeValue=text.substring(attributeValueI,i)
if(wideValue){
i+=1}
if(attributeName==name){
if(parseInt(attributeValue)+""==attributeValue){
attributeValue=parseInt(attributeValue)}
return attributeValue}
i=i+1
attributeNameI=i}}
return null}
function cacheImage(item,name){
var file=getAttribute(item,name)
if(file !=null){
var img=new Image()
img.src=file
imgCache[ imgCache.length ]=img}}
