var overall_menuShowed_text="";  
function menu(obj,win,menu_name,_x,_y,dir) 
{
var child_menu=_gId(menu_name,win);
if(obj.tagName=="A"&&obj.parentNode.tagName=="DIV")
{
ytd_menu_hidSub(obj.parentNode.id,obj_doc,child_menu.parentNode.id);  
var p=obj.parentNode;
while(p.tagName!="DIV"){p=p.parentNode;}
child_menu.style.zIndex=p.style.zIndex+1;
}
else
{
ytd_menu_hiddenAll(win)	 
}
if(overall_menuShowed_text.indexOf(child_menu.id)==-1)
{
child_menu.style.display="block";
control_menu_position(child_menu,win);
var position=get_objPosition(win,obj,child_menu,dir,_x,_y);  
child_menu.style.top=parseInt(position.split(",")[1]);
child_menu.style.left=parseInt(position.split(",")[0]);
overall_menuShowed_text=overall_menuShowed_text+child_menu.id+",";
}
}
function control_menu_position(child_menu,win)
{
var jiantou1=child_menu.rows[0].cells[0].getElementsByTagName("A")[0];
var jiantou2=child_menu.rows[2].cells[0].getElementsByTagName("A")[0];
var centerObj=child_menu.rows[1].cells[0].childNodes[0];
var menu_h=child_menu.offsetHeight;
var body_h=win.document.body.offsetHeight;
if(menu_h>body_h||body_h-menu_h<get_top(child_menu))
{
var menu_martop=body_h-get_top(child_menu);
var menu_marbot=menu_h-menu_martop;
child_menu.style.top=get_top(child_menu)-menu_marbot-35;
if(get_top(child_menu)<0) 
{
child_menu.style.top=0;
var jiantou_h=jiantou1.offsetHeight;
centerObj.style.height=body_h-jiantou_h*2-35;
}
}
if(centerObj.scrollHeight>centerObj.offsetHeight)
{
jiantou1.style.display="block";
jiantou2.style.display="block";	
}
else
{
jiantou1.style.display="none";
jiantou2.style.display="none";		
}	
}
function set_menu_content(menu_name,str,win,pid,window_parent,styleName,_x,_y,dir,itemTag,tag,isDel)
{
var btStr="";
var max_str="";
if(menu_name=="main_tr0_menu") 
{
str=get_column_selected_btStr(str);
}
btStr=bulid_menu_item_html(str,menu_name,styleName,pid,window_parent,dir,_x,_y,itemTag,tag,isDel);
var div=win.document.getElementById("div_"+menu_name);
if(div)
{
div.removeNode(true);
}
win.document.body.insertAdjacentHTML("beforeEnd","<div id=div_"+menu_name+">"+btStr+"</div>")
win.document.getElementById(menu_name+"_"+pid).style.zIndex=1;
var mn=menu_name+"_"+pid;
var div_node=win.document.getElementById(mn);
if(!div_node)
{
div.insertAdjacentHTML("afterBegin",btStr);	
}
return mn;  
}
function ytd_menu_hiddenAll(win,teshu)
{
var o=overall_menuShowed_text
var old=gid('index_menu_old',tops.window);
if(old)o+=old.value;
var m=gid("main_work_menu_right",tops.window);
if(m)
{
if(m.style.display!="none"&&teshu!="yes")
{
if((win.event&&!win.event.srcElement.wanneng_menu)||(win.document.workFrame))
{
o+=","+m.id+",";
}
}
}
o=o.replace(/,,/g,',');
if(o==''||o==',')return;
var arr=o.split(",");
ytd_menu_hiddenAll_sub(o)
overall_menuShowed_text="";
}
function ytd_menu_hiddenAll_sub(s)
{
var arr=(","+s+",").split(",");
for(var i=0;i<arr.length;i++)
{
var win=tops.window;
if(arr[i] && arr[i].length>0)
{
ytd_menu_hiddenAll_sub_sub(win,arr[i]);
}
}
}
function ytd_menu_hiddenAll_sub_sub(win,n)
{
o=gid(n,win)
if(o)
{
var oo=win.document.getElementById(n+"_shadow");
if(o.hid_type&&o.hid_type=="del") 
{
o.removeNode(true);
if(oo)oo.removeNode(true);
}
else
{
o.style.display="none";
if(oo)oo.style.display="none";
}
}
var f=win.frames;
for(var j=0;j<f.length;j++)
{
var url='';
try
{
url=f[j].document.location.href
}catch(e){}
if(url.length>0)
ytd_menu_hiddenAll_sub_sub(f[j],n);
}
}
function ytd_menu_findParent(id,win,menu_name) 
{
var showed=overall_menuShowed_text;
var idSplit=id.split("_");
var pid=idSplit[idSplit.length-1];
var preMenu=win.document.getElementById("menuItem_"+menu_name+pid);
if(preMenu)
{
pid=preMenu.parentNode.id;
}
if(showed.indexOf(pid)>-1)
{
return pid;	
}
return "";
}
function ytd_menu_hidSub(curMenuObj_id,win,menu_name)
{
var showed=overall_menuShowed_text;
var arr=showed.split(",");
for(var i=0;i<arr.length-1;i++)
{
if(ytd_menu_findParent(arr[i],win,menu_name)==curMenuObj_id) 
{
win.document.getElementById(arr[i]).style.display="none";
ytd_menu_hidSub(arr[i],win,menu_name); 
overall_menuShowed_text=showed.replace(arr[i]+",","");
}
}
}
function get_column_selected_btStr(str)
{
if(parent.user_purview-0!=3)
{
str=",1,2,";
}
var data=get_column_select_menu_str();
var dataArr=data.split("<&>");
var id,btStr="";
for(var i=0;i<dataArr.length;i++)
{
id=dataArr[i].split("|")[0];  
if(str.indexOf(","+id+",")>-1)
{
btStr+=dataArr[i]+"<&>";
}
}
return btStr;
}
function bulid_menu_item_html(str,menu_name,styleName,pid,window_parent,node_dir,_x,_y,itemTag,tag,isDel)
{
str=str.replace(/&#39;/g,"'");
str=str.replace(/@@/g,"'");
var htm="<div wanneng_menu=0 style='overflow-y:hidden;width:100%'>";
var tag1="<&>",tag2="|";
if(itemTag&&typeof(itemTag)!="undefined"){tag1=itemTag;}
if(tag&&typeof(tag)!="undefined"){tag2=tag;}
if(str.indexOf(tag1)>-1)
{
var arr=str.split(tag1),arr1;
for(var i=0;i<arr.length-1;i++)
{
if(arr[i]!="")
{
arr1=arr[i].split(tag2);
var pic="";
var pic_pos="";
if(arr1[3].indexOf("?")>-1&&arr1[3].indexOf(",")>-1)
{
pic=arr1[3].split("?")[0];
pic_pos=arr1[3].split("?")[1].replace(","," ");
}
if(isNaN(arr1[4])){arr1[4]=0;}
if(arr1[4]==pid)
{	
var o="onmouseover=tf.menu(this,window,";
o+=window_parent+"set_menu_content('"+menu_name+"',get_selected_menu_id(),window,"+arr1[0]+",'"+window_parent+"'),"+_x+","+_y+",'"+node_dir+"')";
var zdy_shuxing="wanneng_menu=0";
var jiantou="<span id='jiantou' "+zdy_shuxing+">&nbsp;&nbsp;&nbsp;>></span>";
var a_id="id='menuItem_div_"+menu_name+arr1[0]+"'";
var omover="";
var u_1="<u wanneng_menu=0>";
var u_2="<u>";
if(have_module(arr1[0],str)==false)
{
u_1="";
u_2="";
var c=arr1[2].replace("~","'");
while(c.indexOf("~")>-1)c=c.replace("~","'");
if(c!="")
{
o="onclick="+c;
}
else
{
o="";	
}
jiantou="";
zdy_shuxing="";
omover="onmouseover=tops.menu_over(this);"+window_parent+"ytd_menu_hidSub('"+menu_name+"_"+pid+"',window,'div_"+menu_name+"')";
}
htm+="<p><q><a "+a_id+"  "+omover+" onMouseOut=tops.menu_out(this) "+zdy_shuxing+" href='#ytd;' "+o+" ><b style='background:url("+pic+") "+pic_pos+";background-repeat:no-repeat'>"+u_1+arr1[1]+" "+jiantou+"</b>"+u_2+"</a></q></p>";
}
}
}
}
htm+="</div>";
var hid_type="";
if(isDel==1){hid_type="hid_type='del'";}
var menuObj="<table cellpadding=0 cellspacing=0 "+hid_type+"  id='"+menu_name+"_"+pid+"' class='"+styleName+"'  style='width:150px;display:none;overflow:hidden;'  wanneng_menu=0>";
menuObj+="<tr>";
menuObj+="<td><a wanneng_menu=0 id='menu_jt_up' onMouseDown=\"tops.menu_scroll('"+menu_name+"_"+pid+"',-1,window)\">ΙΟ</a></td>";
menuObj+="</tr>";
menuObj+="<tr>";
menuObj+="<td class=but_paq>"+htm+"</td>";
menuObj+="</tr>"
menuObj+="<tr>";
menuObj+="<td><a wanneng_menu=0 id='menu_jt_down' onMouseDown=\"tops.menu_scroll('"+menu_name+"_"+pid+"',1,window)\">ΟΒ</a></td>";
menuObj+="</tr>";
menuObj+="</table>";
return menuObj;
}
function have_module(cid,str)
{
if(str.indexOf("<&>")>-1)
{
var arr=str.split("<&>"),arr1;
for(var i=0;i<arr.length-1;i++)
{
if(arr[i]!="")
{
arr1=arr[i].split("|");
if(arr1[4]==cid)
{
return true;
}
}
}
}
return false;
}
function get_menu_content_html(str)
{
if(str=="")return str;
var htm="";
if(str.indexOf("!!")>-1)
{
var arr=str.split("!!"),arr1,ev="";
for(var i=0;i<arr.length;i++)
{
if(arr[i]!="")
{
arr1=arr[i].split("|");	
if(arr1[2]!=""){ev="onclick="+arr1[2];}else{ev="";}
htm+="<p><q><a href='#ytd;' "+ev+" onMouseOver=tops.menu_over(this) onMouseOut=tops.menu_out(this)><b style='background-image:url("+arr1[0]+")'><u>"+arr1[1]+"</u></b></a></q></p>";
}
}
}
else
{
if(str.indexOf("|")>-1)
{
var arr1=str.split("|"),ev="";
if(arr1[2]!=""){ev="onclick="+arr1[2];}else{ev="";}
htm="<p><q><a href='#ytd;' "+ev+" onMouseOver=tops.menu_over(this) onMouseOut=tops.menu_out(this)><b style='background-image:url("+arr1[0]+")'><u>"+arr1[1]+"</u></b></a></q></p>";
}
else
{
return str;	
}
}
return htm;
}
function show_a_menu(win,menu_name,content,obj,dir)
{
var m=_gId(menu_name,win);
if(m){win.document.body.removeChild(m);return};
var html="<div id='"+menu_name+"' onmouseover=set_cur_select(window,this,'P','on_mouse_over') style='position:absolute;'>"+get_menu_content_html(content)+"</div>";
win.document.body.insertAdjacentHTML("afterBegin",html);
m=_gId(menu_name,win);
var position=get_objPosition(win,obj,m,dir,0,0);
m.style.top=parseInt(position.split(",")[1]);
m.style.left=parseInt(position.split(",")[0]);
}
function menu_over(obj)
{
obj.style.backgroundPosition="0px -50px";
obj.parentElement.style.backgroundPosition="0px 0px";
obj.parentElement.parentElement.style.backgroundPosition="right 0px";
}
function menu_out(obj)
{
obj.style.backgroundPosition="0px -150px";
obj.parentElement.style.backgroundPosition="left -100px";
obj.parentElement.parentElement.style.backgroundPosition="right -100px";
}