﻿//2007/7/27 更新
//IE5.0 Select元件遮擋問題
//英文選單<BR>傳值過濾
//loose.dtd問題
var tdColor="#000";
var tdBgColor="#f5f5f5";//"#E0E2F5";
var hlColor="#000";
var hlBgColor="#d4d4d4";//"#777777";
var md=1000;
var ti=-1;
var oTd=new Object;
oTd=null;
var haddraw=',,';
var oldHTML='';
var p=0;
var j=0;var t0;
var mydroptitle=',,';
var lloop=0;
var currtd='';

var curid='';
var curvl='';
var InKeybordUsed=false;
var mymenus_array=new Array();
var mymenus_text=new Array();
var mymenus_id=new Array();
var mymenus_hidden=new Array();
var itemMouseOut=false;
var downcanuse=false;
var for104temp=false;
var isIE = navigator.appVersion.match(/MSIE/) == "MSIE";

function isUndefined(a) {
    return typeof a == 'undefined';
}
function _fun_104_menu_script(){
	return true;
}
function getkeycode(event)
{
  var e2 = event;  
  k2 = e2.which ? e2.which : ( e2.keyCode ? e2.keyCode : ( e2.charCode ? e2.charCode : 0 ) );
 return k2;
}

function MyDropDownMenuClass()
{
    this.obj =null;
    this.menu_id =null;
    this.menu_title=null;
    this.include_up_node=null;
    this.up_node_textbe=null;
    this.up_node_textaf=null;
    this.show_node=null;
    this.hide_node=null;
    this.can_choice_level=null;
    this.AppendRootNode=null;
}

/*var myClassObj1 = new MyDropDownMenuClass();
var myClassObj2 = new MyDropDownMenuClass();
myClassObj1.myData = 10;
myClassObj1.myString = "Obj1:  Hello World";
myClassObj2.myData = 20;
myClassObj2.myString = "Obj2:  Hello World";*/
//alert(myClassObj1.myString);

function CreateDropDownMenu(obj,menu_id,menu_title,include_up_node,up_node_textbe,up_node_textaf,show_node,hide_node,can_choice_level,AppendRootNode)
{

  var drop_Max=checkdeep(obj.n,0);
  if(can_choice_level==null || can_choice_level==0 || can_choice_level=='')
  {
  can_choice_level=drop_Max;
  }
  
  if(include_up_node==null  || include_up_node=='')
  {
  include_up_node=0;
  }
  var menu_no=menu_id.split('_')[1];
  mymenus_array[menu_no]=new MyDropDownMenuClass();
  mymenus_array[menu_no].obj=obj;
  mymenus_array[menu_no].menu_id=menu_id;
  mymenus_array[menu_no].menu_title=menu_title;
  mymenus_array[menu_no].include_up_node=include_up_node;
  mymenus_array[menu_no].up_node_textbe=up_node_textbe;
  mymenus_array[menu_no].up_node_textaf=up_node_textaf;
  mymenus_array[menu_no].show_node=show_node;
  mymenus_array[menu_no].hide_node=hide_node;
  
  mymenus_array[menu_no].can_choice_level=can_choice_level;
  mymenus_array[menu_no].AppendRootNode=AppendRootNode;
}
function setlastvalue(td,inputvalue)
{
  var dtd='';
  var _curtddd='';
  if(navigator.userAgent.indexOf('MSIE 5')>0)
    return;
  if(inputvalue.length<=0)return td;
  if(inputvalue.substr(inputvalue.length-6,6)=='000000')
  {
  _curtddd=td+"_"+inputvalue;
  }    
  else if(inputvalue.substr(inputvalue.length-3,3)=='000')
  {
  _curtddd=td+"_"+inputvalue.substr(0,inputvalue.length-6)+"000000_"+inputvalue;
  }
  else
  {
  _curtddd=td+"_"+inputvalue.substr(0,inputvalue.length-6)+"000000_"+inputvalue.substr(0,inputvalue.length-3)+"000_"+inputvalue;
  }
  //_curtddd+='_'+inputvalue+'X';
  
  if(isUndefined(inputvalue.length)==false)  
    dtd=inputvalue;  
  else
    return;
    
/*    if (eval("typeof(td"+dtd+")!=\"undefined\""))
      _curtddd=eval("td"+dtd);
    else 
      return "";*/
    
  
  var sp=_curtddd.toString();
      sp=sp.split('_');
  var sd="td";
  if(navigator.userAgent.indexOf('Netscape6')>0)
  if(sp.length>0)
  _curtddd=sd+"_"+sp[1];
  for(var i=1;i<sp.length;i++)
  {
      sd+="_"+sp[i];  
      drawmenu(sd);
      //setTimeout("doMenu('"+sd+"');",100*i);
      if(document.getElementById(sd))
      if(document.getElementById(sd).onmouseover)
      {
      //
      if(navigator.userAgent.indexOf('Netscape6')>0)
      {
        setTimeout("document.getElementById('"+sd+"').onmouseover();",100*i);
        setTimeout('itemMouseOut=true;',150*i);
      }
      else  
        document.getElementById(sd).onmouseover();
      }
      //setTimeout("document.getElementById('"+sd+"').onmouseover();",500*i);
      //alert(sd+document.getElementById(sd));
  }
  
  return _curtddd;
}


function getmenu(menutype,inputid,inputvalue,width,display,displayvalue,idvalue)
{
mymenus_text[menutype]=inputid;
mymenus_id[menutype]=inputvalue;
var _displayvalue;
var  _idvalue;
if(typeof(displayvalue)=='undefined')_displayvalue='請選擇'+eval('td_'+menutype);else _displayvalue=displayvalue;
if(typeof(idvalue)=='undefined')_idvalue='0';else _idvalue=idvalue;
var str="";
if(menutype==1)
CreateDropDownMenu(JobCatHRoot,'td_1','職務類別',2,'','全部','','','','不拘,0');
else if(menutype==2)
CreateDropDownMenu(JobCatRoot,'td_2','職務類別',2,'','全部','','','','不拘,0');
else if(menutype==3)
CreateDropDownMenu(IndustRoot,'td_3','產業類別',1,'','全部','','',2,'不拘,0');
else if(menutype==4)
CreateDropDownMenu(AreaRoot,'td_4','地區類別',2,'','全區','','','','不拘,0');
else if(menutype==5)
CreateDropDownMenu(JobCatPRoot,'td_5','職務類別',2,'','全部','','','','不拘,0');
if(menutype==1)
str="<td id=\"td_1\" style=\"display:"+display+"\" > <input name=\""+inputid+"\" class=\"_inputform\" id=\""+inputid+"\" onclick=\"javascript:clearMenu();doMenu('td_1','"+inputid+"','"+inputvalue+"','td_1'); \" style=\"width:"+width+";\" readonly value=\""+_displayvalue+"\"> <img style=\"margin-left:-4px\" src=\"/public/function01/img/arrow_menu.gif\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:clearMenu();doMenu('td_1','"+inputid+"','"+inputvalue+"','td_1'); \"> <input name=\""+inputvalue+"\" id=\""+inputvalue+"\" type=\"hidden\" value=\""+_idvalue+"\"><span style=\"display:none\" id=\""+inputid+"sp\">/<span></td>";
else if(menutype==2)
str="<td id=\"td_2\" style=\"display:"+display+"\" ><input name=\""+inputid+"\" class=\"_inputform\" id=\""+inputid+"\" onclick=\"javascript:clearMenu();doMenu('td_2','"+inputid+"','"+inputvalue+"','td_2');\" style=\"width:"+width+"\"  readonly value=\""+_displayvalue+"\">  <img style=\"margin-left:-4px\" src=\"/public/function01/img/arrow_menu.gif\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:clearMenu();doMenu('td_2','"+inputid+"','"+inputvalue+"','td_2'); \"><input name=\""+inputvalue+"\" id=\""+inputvalue+"\" type=\"hidden\" value=\""+_idvalue+"\"><span style=\"display:none\" id=\""+inputid+"sp\">/<span></td>";
else if(menutype==3)
str="<td id=\"td_3\" style=\"display:"+display+"\" ><input name=\""+inputid+"\" class=\"_inputform\" id=\""+inputid+"\" onclick=\"javascript:clearMenu();doMenu('td_3','"+inputid+"','"+inputvalue+"','td_3');\" style=\"width:"+width+"\"  readonly value=\""+_displayvalue+"\"> <img style=\"margin-left:-4px\" src=\"/public/function01/img/arrow_menu.gif\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:clearMenu();doMenu('td_3','"+inputid+"','"+inputvalue+"','td_3'); \"> <input name=\""+inputvalue+"\" id=\""+inputvalue+"\" type=\"hidden\" value=\""+_idvalue+"\"><span style=\"display:none\" id=\""+inputid+"sp\">/<span></td>";
else if(menutype==4)
str="<td id=\"td_4\" style=\"display:"+display+"\" ><input  name=\""+inputid+"\" class=\"_inputform\" id=\""+inputid+"\" onclick=\"javascript:clearMenu();doMenu('td_4','"+inputid+"','"+inputvalue+"','td_4');\" style=\"width:"+width+"\"  readonly value=\""+_displayvalue+"\"> <img style=\"margin-left:-4px\" src=\"/public/function01/img/arrow_menu.gif\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:clearMenu();doMenu('td_4','"+inputid+"','"+inputvalue+"','td_4'); \"> <input name=\""+inputvalue+"\" id=\""+inputvalue+"\" type=\"hidden\" value=\""+_idvalue+"\"><span style=\"display:none\" id=\""+inputid+"sp\">/<span></td>";
else if(menutype==5)
str="<td id=\"td_5\" style=\"display:"+display+"\" ><input name=\""+inputid+"\" class=\"_inputform\" id=\""+inputid+"\" onclick=\"javascript:clearMenu();doMenu('td_5','"+inputid+"','"+inputvalue+"','td_5');\" style=\"width:"+width+"\"  readonly value=\""+_displayvalue+"\"> <img style=\"margin-left:-4px\" src=\"/public/function01/img/arrow_menu.gif\" border=\"0\" align=\"absmiddle\" onclick=\"javascript:clearMenu();doMenu('td_5','"+inputid+"','"+inputvalue+"','td_5'); \"> <input name=\""+inputvalue+"\"  id=\""+inputvalue+"\" type=\"hidden\" value=\""+_idvalue+"\"><span style=\"display:none\" id=\""+inputid+"sp\">/<span></td>";

document.write(str);
}
function getScrollXY(which) {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) 
  {
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } 
  else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) 
  {
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } 
  else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) 
  {
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  if(which==1)  
    return scrOfX;  
  else
    return scrOfY;
}

function alertSize(which) {
  var myWidth = 0, myHeight = 0;
  if( typeof( document.documentElement.offsetWidth ) == 'number' ) 
  {
    if(isIE)
    {
    myWidth = document.documentElement.offsetWidth;
    myHeight = document.documentElement.offsetHeight;
    }
    else
    {
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
    }

  } 
  else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
  {
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } 
  else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
  {
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  if(which==1)  
  return myWidth;  
  else
  return myHeight;
}

function rebuild(td)
{

}

function Time_to_doMenu(td)
{
  if(navigator.userAgent.indexOf('Netscape6/6.0')>0)
  doMenu(td);
  else
  {
  clearTimeout(t0);
  if(InKeybordUsed==true)
    doMenu(td);
  else
    t0=setTimeout("doMenu('"+td+"');",100);
  }
}
/************************************************
 * FUNCTION: doMenu                              
 *                                               
 * DESCRIPTION: 產生下拉式選單                          
 *                                               
 * PARAMETERS: td(要產生的選單種類),id(指定text要顯示在哪個ID之下),v_id(指定value要顯示在哪個ID之下),rt(選單對應的Table/TD的ID) 
 *                                               
 * RETURNED: No                                  
 *                                               
 * CREATED: 2007/1/3                             
 *                                               
 * BY: Paul.Yu                                   
 *                                               
 * COMMENTS:                                     
 *                                               
 ************************************************/

function doMenu(td,id,v_id,rt){
	
  if(td==null)
    return;
  var i;var sT="";var tda=new Array();
  clearTimeout(ti);
  
  if(typeof(td)=='string')
    currtd=td;
  else
    {currtd=td.id;}  
  tda=currtd.split("_");     
  

  if(id && id!=null && typeof(id)!='undefined' && id.length>0)
  {
  mymenus_id[tda[1]]=id;
  mymenus_text[tda[1]]=v_id; 
  _temptd=setlastvalue(td,document.getElementById(v_id).value);
  if(_temptd!=null && typeof(_temptd.length)!='undefined' && _temptd.length>0) {currtd=_temptd;td=_temptd;tda=currtd.split("_");}     
  document.getElementById(id).onkeydown = dropdownmenu_keyDown;
  setTimeout('itemMouseOut=true;',100);
  }


  if(isUndefined(td)==false)
    drawmenu(td);
  lloop=tda[tda.length-1];
	  if(typeof(oTd)=='string' && document.getElementById(td))	    
      oTd=document.getElementById(td);   
       
  if(oTd!=null)
  {        
		var tdo=new Array();
		if(typeof(oTd)=='string')
		tdo=oTd;
		else
		tdo=oTd.id.split("_");
		for(i=1;i<tdo.length;i++)
    {
			sT+="_"+tdo[i];
			if(tdo[i]!=tda[i])
      {	
           if(sT!='dtd_1'&&sT!='_1' && sT!='dtd_2'&&sT!='_2' && sT!='dtd_3'&& sT!='_3' && sT!='dtd_4'&& sT!='_4' && sT!='dtd_5'&& sT!='_5')
              {						      
                if(document.getElementById("td"+sT))
                {
                if(document.getElementById("td"+sT).style.backgroundColor!=tdBgColor)
        		    document.getElementById("td"+sT).style.backgroundColor=tdBgColor;
        		    if(document.getElementById("td"+sT).style.color!=tdColor)
        				document.getElementById("td"+sT).style.color=tdColor; 
        				if(document.getElementById("td"+sT).style.textDecoration!='none')
                document.getElementById("td"+sT).style.textDecoration='none';
                }
              }

           //if(for104temp==true && tda[1]==2 && tda.length>2){}
           //else	
        	 if(document.getElementById("tbl"+sT)!=null)
        	 if(document.getElementById("tbl"+sT).style.visibility!="hidden")
        	 {        	 
        	    document.getElementById("tbl"+sT).style.visibility="hidden";
        		  DivSetVisible('',"tbl"+sT,false);
           } 
			}
		}
	}
	
	  if(typeof(td)=='string')
      oTd=document.getElementById(td);
    else
      oTd=td;
      

	sT="tbl";
	osT="td";
	


    if(id!=null && rt!=null)
    {
      sT+="_"+tda[1];  
      document.getElementById(sT).style.visibility="visible";   
      document.getElementById(sT).style.height="auto";
      
      //判斷第一層選單要向上還是向下    
      if(navigator.userAgent.indexOf('Firefox/1')>0)
      {
        document.getElementById(sT).style.top=getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]+'px';
      }
      else
      {
        if((getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]-getScrollXY(2))<((alertSize(2))/2))
        {
          document.getElementById(sT).style.top=getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]+'px';
        }
        else
        {
         document.getElementById(sT).style.top=getRootCoord(id,rt,sT,2).replace('px;left','').replace('px">','').split(':')[0]+'px';
        }
      }  
      
      document.getElementById(sT).style.left=getRootCoord(id,rt).replace('px;left','').replace('px">','').split(':')[1]+'px';
     
            		if((navigator.userAgent.indexOf('Firefox/1')<=0) && (GetAbsoluteLocationEx(document.getElementById(sT),1)+GetAbsoluteLocationEx(document.getElementById(sT),4))>(alertSize(2)+getScrollXY(2)))
            		{
            	   x=GetAbsoluteLocationEx(document.getElementById(sT),1)+GetAbsoluteLocationEx(document.getElementById(sT),4);
                 y=alertSize(2)+getScrollXY(2);//螢幕高度+滑動軸高度

                  document.getElementById(sT).style.height=(GetAbsoluteLocationEx(document.getElementById(sT),4)-(x-y)-20)+"px";
                
            	  }
            	  else if((navigator.userAgent.indexOf('Firefox/1')<=0) && (GetAbsoluteLocationEx(document.getElementById(sT),1))<(getScrollXY(2)))//選單高度重設
            	  {
            	  //x=getScrollXY(2);
            	  x=getScrollXY(2);
            	 // alertSize
                y=GetAbsoluteLocationEx(document.getElementById(sT),1);//螢幕高度+滑動軸高度

            	  document.getElementById(sT).style.height=(GetAbsoluteLocationEx(document.getElementById(sT),4)-(x-y))+"px";
            	  //選單高度重設後要調整位置
                  if((getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]-getScrollXY(2))<((alertSize(2))/2))
                    document.getElementById(sT).style.top=getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]+'px';
                  else
                    document.getElementById(sT).style.top=getRootCoord(id,rt,sT,2).replace('px;left','').replace('px">','').split(':')[0]+'px';

                }
              //  if(document.getElementById(sT)!=null)
                
              //  DivSetVisible('',sT,true,0); 
     } 

 
  sT="tbl";
  HidIframe="DivShim";
	for(i=1;i<tda.length;i++)
	{
		sT+="_"+tda[i];
    osT+="_"+tda[i];
    HidIframe+="_"+tda[i];
  
		if(document.getElementById(sT)!=null)
		if(document.getElementById(sT).style.visibility!="visible")
		{		
		oxT="tbl";
		oxTScrollHeight=0;
		oxTScrollWidth=0;
		for(j=1;j<i;j++)
		 oxT+="_"+tda[j];
		 if(navigator.userAgent.indexOf('MSIE 5')>0)
		 {
		  document.getElementById(sT).style.top=getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[0]+'px';
		  document.getElementById(sT).style.left=getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[1]+'px';
//		  document.getElementById(sT).style.visibility="visible";
//      continue;
		 }

		  
		// document.getElementById('td_21').value=getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[1];
		 //當前一個選單scroll bar有滑動時		 
		 
    
		if(document.getElementById(oxT) && document.getElementById(oxT).scrollTop>0)
		{
		 oxTScrollHeight=document.getElementById(oxT).scrollTop;
		}
		if(document.getElementById(oxT))
		document.getElementById(oxT).style.paddingRight="0";
	//	DivSetVisible('',oxT,true,0); 
  		if(document.getElementById(oxT) && document.getElementById(oxT).scrollHeight>document.getElementById(oxT).clientHeight)
  		{
      	
        	if(isIE)
          {
            oxTScrollWidth=15;
            document.getElementById(oxT).style.paddingRight="15";
            DivSetVisible('',oxT,true,0);  
          }
          else
          {
          
          }
  		}
  		if(document.getElementById(sT)!=null)
		    document.getElementById(sT).style.height="auto";
      
      	   if(tda.length>=2)
      	   {
              if((navigator.userAgent.indexOf('Firefox/1')<=0) && GetAbsoluteLocationEx(document.getElementById(sT),4)>alertSize(2))
              document.getElementById(sT).style.height=alertSize(2)-30;           
           }      	  
      	  // if(navigator.userAgent.indexOf('MSIE 5')<=0)
     	      if(getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[1]>0)
      	    {      	    
            document.getElementById(sT).style.top=getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[0]-oxTScrollHeight+'px';

          
            if(tda.length>=2 && i>=2)
            {
          		if((GetAbsoluteLocationEx(document.getElementById(sT),1)+GetAbsoluteLocationEx(document.getElementById(sT),4))>(alertSize(2)+getScrollXY(2)))
          		{
          	   x=GetAbsoluteLocationEx(document.getElementById(sT),4);
               y=alertSize(2)+getScrollXY(2);//螢幕高度+滑動軸高度
                //取得第一個選單是向上還是向下
               if((y-x-25)>0)
               {
               document.getElementById(sT).style.top=(y-x-25)+"px";
               }
          	   else
          	   {document.getElementById(sT).style.top="10px";}
          	  }                          
            }
                      
              if(tda.length>=2)
              {            
                First_sT="tbl_"+tda[1];
            		//選單全部靠左
            		
            		if(GetAbsoluteLocationEx(document.getElementById(First_sT),2)>(alertSize(1)/2))
            		{         	
                 before_sT="tbl";                 
                 for(j=1;j<i;j++)
                    before_sT+="_"+tda[j];
                                                                            
               /*  if((GetAbsoluteLocationEx(document.getElementById(before_sT),2)-document.getElementById(sT).scrollWidth)>0)
                   {                   */
                   if(document.getElementById(sT).scrollHeight>document.getElementById(sT).clientHeight)
                   {
                   if(isIE)
                   document.getElementById(sT).style.left=(GetAbsoluteLocationEx(document.getElementById(before_sT),2)-GetAbsoluteLocationEx(document.getElementById(sT),3)-4)+"px";//+"px";
                   else
                   document.getElementById(sT).style.left=(GetAbsoluteLocationEx(document.getElementById(before_sT),2)-GetAbsoluteLocationEx(document.getElementById(sT),3))+"px";//+"px";
                   }
                   else
                   document.getElementById(sT).style.left=(GetAbsoluteLocationEx(document.getElementById(before_sT),2)-GetAbsoluteLocationEx(document.getElementById(sT),3))+"px";//+"px";
                  /* }
            	   else
            	     {
                   //document.getElementById(sT).style.left="10px";
                   }*/
            	     
            	  }
            	  else
                { 
            	    document.getElementById(sT).style.left=getCoord(sT.replace('tbl','')).replace('px;left','').replace('px">','').split(':')[1]+'px';
            //當不是IE瀏覽器時選單要增加15PX確保不會蓋住Scroll Bar
                  if((navigator.userAgent.indexOf('Firefox/1')<=0) && oxTScrollWidth>0)
                  {            
                  document.getElementById(sT).style.left=GetAbsoluteLocationEx(document.getElementById(sT.replace('tbl','td')),2)+GetAbsoluteLocationEx(document.getElementById(sT.replace('tbl','td')),3)+4+oxTScrollWidth+"px";
                  }
                }
            	  //向左折?向右折 選單偶爾靠左
                if((GetAbsoluteLocationEx(document.getElementById(sT),2)+GetAbsoluteLocationEx(document.getElementById(sT),3))>(alertSize(1)+getScrollXY(1)))
            		{  	
            	   x=GetAbsoluteLocationEx(document.getElementById(sT),3);        	   
                 y=alertSize(1)+getScrollXY(1);//螢幕寬度+滑動軸寬度

                 z=alertSize(1)-GetAbsoluteLocationEx(document.getElementById(sT),2);
                 before_sT="tbl";
                 for(j=1;j<i;j++)
                    before_sT+="_"+tda[j];                                    
                 if((y-x)>0)
                   {document.getElementById(sT).style.left=(y-x-z-GetAbsoluteLocationEx(document.getElementById(before_sT),3))+"px";}
            	   else
            	     {document.getElementById(sT).style.left="10px";}
            	  }                          
              }
      	}
      //	DivSetVisible(HidIframe,sT,true,oxTScrollWidth);  
        		    if(for104temp==true && tda[1]==2 && tda.length>2){document.getElementById('tbl_2').style.visibility="visible";}
        else	document.getElementById(sT).style.visibility="visible";    
   
         
      }       
      
                    	  //選單高度重設後要調整位置
            	  if(id!=null && rt!=null && (navigator.userAgent.indexOf('Firefox/1')<=0))
            	  {
                  if((getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]-getScrollXY(2))>((alertSize(2))/2))
              //    {
            //      if(document.getElementById(sT) && i<=2)
              //      document.getElementById(sT).style.top=getRootCoord(id,rt,sT,1).replace('px;left','').replace('px">','').split(':')[0]+'px';
              //    }
              //    else
                  { 
                    //預設路徑問題選單分岔
                    if(document.getElementById(sT) )
                    {
                      if(i>=2)
                      { 
                        rootst="tbl_"+tda[1];//alert(rootst+document.getElementById(rootst).style.height);
                        //alert(sT+document.getElementById(sT).style.height);
                        
                        if((GetAbsoluteLocationEx(document.getElementById(rootst),4))<(GetAbsoluteLocationEx(document.getElementById(sT),4)))
                        {
                        document.getElementById(sT).style.height=GetAbsoluteLocationEx(document.getElementById(rootst),4)+"px";
                        }
                      }
                      document.getElementById(sT).style.top=getRootCoord(id,rt,sT,2).replace('px;left','').replace('px">','').split(':')[0]+'px';
             //         DivSetVisible('',sT.replace('td','tbl'),true,0); 
                    }
                  }
                }    
      	
    if(document.getElementById(td.replace('td','tbl')))
    {
  		document.getElementById(td.replace('td','tbl')).style.paddingRight="0";
  		if( document.getElementById(td.replace('td','tbl')).scrollHeight>document.getElementById(td.replace('td','tbl')).clientHeight)
  		{		
  		    if(isIE)
          {
            document.getElementById(td.replace('td','tbl')).style.paddingRight="15";
        //    DivSetVisible('',td.replace('td','tbl'),true,0);  
          }
          else
          {
          }
      }
      
    }                      	
		  if(osT!='dtd_1'&&osT!='td_1' && osT!='dtd_2'&&osT!='td_2' && osT!='dtd_3'&&osT!='td_3'&& osT!='dtd_4'&& osT!='td_4'&& osT!='dtd_5'&& osT!='td_5')
      {
         if(document.getElementById(osT)!=null)
         {
      			document.getElementById(osT).style.backgroundColor=hlBgColor;
      	    document.getElementById(osT).style.color=hlColor;
          }  
                oxT="tbl";
          	    for(j=1;j<osT.split('_').length-1;j++)
      		        oxT+="_"+tda[j];
          	    if(document.getElementById(oxT)&&document.getElementById(osT))
          	    {
          	    //oxTScrollHeight
            	    if((document.getElementById(oxT).clientHeight+document.getElementById(oxT).scrollTop)<document.getElementById(osT).offsetTop)
            	    {
            	     document.getElementById(oxT).scrollTop=document.getElementById(osT).offsetTop;            	     
            	    }
            	    else if(document.getElementById(oxT).scrollTop>document.getElementById(osT).offsetTop-5)
            	    {
            	     document.getElementById(oxT).scrollTop=document.getElementById(osT).offsetTop-20;
            	    }
            	    else if((document.getElementById(oxT).clientHeight+document.getElementById(oxT).scrollTop)<(document.getElementById(osT).offsetTop+document.getElementById(osT).offsetHeight))
            	    {
            	     document.getElementById(oxT).scrollTop+=document.getElementById(osT).offsetHeight;
            	    }
          	    }
      }
if(document.getElementById(sT))
DivSetVisible('',sT,true,0);
	}
	  if(oTd==null)
     oTd=td;
 
}

  function DivSetVisible(Iframe,DivId,state,oxTScrollWidth)
  {
     if(navigator.userAgent.indexOf('MSIE 5.0')>0)
     {
      if(state)
     HideAllSelect(DivId);
     else
     ShowAllSelect(DivId.split('_').length-1);
     }
     else if (isIE && navigator.userAgent.indexOf('MSIE 5.0')<=0)
      {
         var DivRef = document.getElementById(DivId);
         var IfrRef = document.getElementById('dropdownmenu_DivShim'+(DivId.split('_').length-1));
         if(IfrRef)
         {
        // alert(DivId+','+'dropdownmenu_DivShim'+(DivId.split('_').length-2));
           if(state)
           {

            IfrRef.style.width = DivRef.offsetWidth;
            IfrRef.style.height = DivRef.offsetHeight;
            IfrRef.style.top =DivRef.style.top;
            IfrRef.style.left = DivRef.style.left;
            IfrRef.style.zIndex = DivRef.style.zIndex - 1;      
            IfrRef.style.display = "";
           }
           else
           {
            IfrRef.style.display = "none";
           }
         }
      }
  }
  
  function HideAllSelect(DivId)
  { 
     var id_len = DivId.split('_').length-1;
     if(id_len<=0)return;
     
     if(typeof(mymenus_hidden[id_len])=='undefined' || mymenus_hidden[id_len]==null)
     mymenus_hidden[id_len]=new Array();
     var a=document.getElementsByTagName('select');
     var b="";
     DivId=document.getElementById(DivId);
     if(!DivId)return;
      obj1y=GetAbsoluteLocationEx(DivId,1);
      obj1x=GetAbsoluteLocationEx(DivId,2);
      obj1w=DivId.offsetWidth;
      obj1h=DivId.offsetHeight;
     for(j=0,i=0;i<a.length;i++)
     {
     //判斷是否覆蓋到選單

          if(a[i].style.visibility!="hidden")
          {
            if(a[i].style.display!="none")
            {
                    c=Check_cumulation(DivId,a[i],obj1y,obj1x,obj1w,obj1h);
            if(c)
            {
            
            a[i].style.visibility="hidden";
            mymenus_hidden[id_len][j]=a[i];
            j++;
            }
          }
        }
     }
  }
  
  function ShowAllSelect(i)
  {
     var a=document.getElementsByTagName('select');
     var b="";
   //  for(i=1;i<4;i++)
   //  {
     //將先前隱藏的選單開啟
      //a[i].style.visibility="visible";
      if(mymenus_hidden[i])
      {
      for(j=0;j<mymenus_hidden[i].length;j++)
      {
        if(mymenus_hidden[i][j].style.visibility!="visible")
        mymenus_hidden[i][j].style.visibility="visible";
      }
      mymenus_hidden[i]=null;
      }
   //  }
  }
  function Check_cumulation(obj1,obj2,obj1y,obj1x,obj1w,obj1h)
  {
       /*
     if(which==1)
      return   offsetTop;
     else if(which==2)
      return   offsetLeft;    
     else if(which==3)
      return   offsetWidth;
     else if(which==4)
      return   offsetHeight;*/  
    // GetAbsoluteLocationEx(a[i]);
    
    if(obj1)
    {
 /*   obj1y=GetAbsoluteLocationEx(obj1,1);
    obj1x=GetAbsoluteLocationEx(obj1,2);
    obj1w=GetAbsoluteLocationEx(obj1,3);
    obj1h=GetAbsoluteLocationEx(obj1,4);*/
    obj2y=GetAbsoluteLocationEx(obj2,1);
    obj2x=GetAbsoluteLocationEx(obj2,2);
    obj2w=obj2.offsetWidth;
    obj2h=obj2.offsetHeight;

    //obj2x between obj1x and obj1x+obj1w
    //obj2y between obj1y and obj1y+obj1h
    
    if(((obj2x>obj1x) && obj2x<(obj1x+obj1w)) && ((obj2y>obj1y) && obj2y<(obj1y+obj1h)))
    return true;
    
    else if(((obj2x>obj1x) && obj2x<(obj1x+obj1w)) && (((obj2y+obj2h)>obj1y) && (obj2y+obj2h)<(obj1y+obj1h)))
    return true;

    else if((((obj2x+obj2w)>obj1x) && (obj2x+obj2w)<(obj1x+obj1w)) && ((obj2y>obj1y) && obj2y<(obj1y+obj1h)))
    return true;
            
    else if((((obj2x+obj2w)>obj1x) && (obj2x+obj2w)<(obj1x+obj1w)) && (((obj2y+obj2h)>obj1y) && (obj2y+obj2h)<(obj1y+obj1h)))
    return true;

    else if((((obj2x+obj2w/2)>obj1x) && (obj2x+obj2w/2)<(obj1x+obj1w)) && (((obj2y+obj2h/2)>obj1y) && (obj2y+obj2h)<(obj1y+obj1h)))
    return true;        
    }
    return false;
  }
  

   function setStyle(element, style) 
   {
    element = $(element);
    for (var name in style)
      element.style[name.camelize()] = style[name];
  }
  function setfocus(d)
  {
   if (document.getElementById &&
         document.getElementById(d) &&
            document.getElementById(d).focus)
   {
   setTimeout('document.getElementById(\''+d+'\').focus();',100);
   };
  }  

function clearMenu(){

itemMouseOut=false;
if(document.getElementById('dropdownmenu_DivShim1'))
 document.getElementById('dropdownmenu_DivShim1').style.display = "none";
 if(document.getElementById('dropdownmenu_DivShim2'))
 document.getElementById('dropdownmenu_DivShim2').style.display = "none";
 if(document.getElementById('dropdownmenu_DivShim3'))
 document.getElementById('dropdownmenu_DivShim3').style.display = "none";
  downcanuse=false;
	if(oTd!=null){	
		var tdo=new Array();
		if(typeof(oTd)=='string')
		  tdo=oTd.split("_");
    else		  
      tdo=oTd.id.split("_");
		var sT="";
		for(var i=1;i<tdo.length;i++){
			sT+="_"+tdo[i];
if(sT!='dtd_1'&&sT!='_1' && sT!='dtd_2'&&sT!='_2' && sT!='dtd_3'&& sT!='_3' && sT!='dtd_4'&& sT!='_4' && sT!='dtd_5'&& sT!='_5')
{
          if(document.getElementById)
            if(document.getElementById("td"+sT))
              if(document.getElementById("td"+sT).style)
              {
      			     document.getElementById("td"+sT).style.backgroundColor=tdBgColor;
      			     document.getElementById("td"+sT).style.color=tdColor;
      			     document.getElementById("td"+sT).style.textDecoration='none'; 
              }			
}	  
			if(document.getElementById("tbl"+sT)!=null)
			 if(document.getElementById("tbl"+sT).style.visibility!="hidden")
				document.getElementById("tbl"+sT).style.visibility="hidden";
				ShowAllSelect(i);
		}
		oTd=null;			
	}
	
//document.getElementById('dropdownmenu_menu').innerHTML="";
}

function runMenu(strURL){
	location.href=strURL;
}

var tt="";
var sT="";
var pT=new Array();
var tA=new Array();

function GetAbsoluteLocationEx(element,which)
{
    if ( arguments.length != 2 || element == null )
    {
        return null;
    }
    var elmt = element;
    var offsetTop = elmt.offsetTop;
    var offsetLeft = elmt.offsetLeft;
    var offsetWidth = elmt.offsetWidth;
    var offsetHeight = elmt.offsetHeight;
    while( elmt = elmt.offsetParent )
    {
        if ( elmt.style.position == 'absolute' || elmt.style.position == 'relative'
            || ( elmt.style.overflow != 'visible' && elmt.style.overflow != '' ) )
        {
            break;
        }
        offsetTop += elmt.offsetTop;
        offsetLeft += elmt.offsetLeft;
    }   
   if(which==1)
    return   offsetTop;
   else if(which==2)
    return   offsetLeft;    
   else if(which==3)
    return   offsetWidth;
   else if(which==4)
    return   offsetHeight;      
}


function getCoord(st){
	  var mnew_ind =document.getElementById("dropdownmenu_menu");
    //var new_ind=mnew_ind.getElementsByTagName('table');
    //var new_td=mnew_ind.getElementsByTagName('td');
    var rtntop=0; 
    var rtnleft=0;
	      tA=st.split("_");
	  if(tA.length>2){
  		  tA=tA.slice(0,-1);
  		  tt=tA.join("_");
  		if(navigator.userAgent.indexOf('Netscape6')>0)
  		{
  				return (GetAbsoluteLocationEx(document.getElementById("td"+st),1))+"px;left:"+
  			         (GetAbsoluteLocationEx(document.getElementById("td"+st),2)+
                  GetAbsoluteLocationEx(document.getElementById("td"+st),3))+"px\">";
  		}
  				return (GetAbsoluteLocationEx(document.getElementById("td"+st),1))+"px;left:"+
  			         (GetAbsoluteLocationEx(document.getElementById("td"+st),2)+
                  GetAbsoluteLocationEx(document.getElementById("td"+st),3))+"px\">";
    }
		if(navigator.userAgent.indexOf('Netscape6')>0)
		{
  		return (GetAbsoluteLocationEx(document.getElementById("mainmenu"),1)+
              GetAbsoluteLocationEx(document.getElementById("td"+st),4)+5)+"px;left:"+
  		       (GetAbsoluteLocationEx(document.getElementById("td"+st),2)+5)+"px\">";
    }		
	return (GetAbsoluteLocationEx(document.getElementById("mainmenu"),1)+
          GetAbsoluteLocationEx(document.getElementById("td"+st),4))+"px;left:"+
		     (GetAbsoluteLocationEx(document.getElementById("td"+st),2))+"px\">";	
}
function getRootCoord(st,rt,_St,which){



		if(navigator.userAgent.indexOf('Netscape6')>0)
		{
  		return (GetAbsoluteLocationEx(document.getElementById(rt),1)+
              GetAbsoluteLocationEx(document.getElementById(st),4)+5)+"px;left:"+
  		       (GetAbsoluteLocationEx(document.getElementById(st),2)+5)+"px\">";
    }		
    
    if(which==1)
    {
	 return (GetAbsoluteLocationEx(document.getElementById(rt),1)+	       
          GetAbsoluteLocationEx(document.getElementById(st),4)+4)+"px;left:"+
		     (GetAbsoluteLocationEx(document.getElementById(st),2))+"px\">";
    }
    else
    {
	 return (GetAbsoluteLocationEx(document.getElementById(rt),1)-	       
          GetAbsoluteLocationEx(document.getElementById(_St),4)+4)+"px;left:"+
		     (GetAbsoluteLocationEx(document.getElementById(st),2))+"px\">";    
    }	
}
/** This is high-level function.
 * It must react to delta being more/less than zero.
 */
function handle(delta) {

/*        if (delta < 0)
		…;
        else
		…;*/
}
/** Event handler for mouse wheel event.
 */
function wheel(event){
        var delta = 0;
        if (!event) /* For IE. */
                event = window.event;
        if (event.wheelDelta) { /* IE/Opera. */
                delta = event.wheelDelta/120;
                /** In Opera 9, delta differs in sign as compared to IE.
                 */
                if (window.opera)
                        delta = -delta;
        } else if (event.detail) { /** Mozilla case. */
                /** In Mozilla, sign of delta is different than in IE.
                 * Also, delta is multiple of 3.
                 */
                delta = -event.detail/3;
        }
        /** If delta is nonzero, handle it.
         * Basically, delta is now positive if wheel was scrolled up,
         * and negative, if wheel was scrolled down.
         */
         
        if (delta)
                handle(delta);
        /** Prevent default actions caused by mouse wheel.
         * That might be ugly, but we handle scrolls somehow
         * anyway, so don't bother here..
         */
        if (event.preventDefault)
                event.preventDefault();
	event.returnValue = false;
}
function dropdownmenu_fun_call(){
	if (dropdownmenu_backonload!= null)
		dropdownmenu_backonload();
	clsmenu();
}
function dropdownmenu_fun_call_rexize(){
	if (dropdownmenu_backonload_rexize!= null)
		dropdownmenu_backonload_rexize();
	rexize();
}
var dropdownmenu_backonload = null;
var dropdownmenu_backonload_rexize = null;
function iinniitt()
{
try {
if(isIE)
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

if (document.onclick != null)
	dropdownmenu_backonload = document.onclick;
  document.onclick = dropdownmenu_fun_call;

if (window.onresize != null)
	dropdownmenu_backonload_rexize = window.onresize;
  window.onresize = dropdownmenu_fun_call_rexize;  
  AppendDefaultDIV();
  //window.onmousewheel = document.onmousewheel = wheel; 
}
function E104_iinniitt()
{
/*
td_1="職務類別";//JobCatRoot
td_2="職務類別";//IndustRoot
td_3="產業類別";//AreaRoot
td_4="地區類別";//AreaRoot
td_5="職務類別";//AreaRoot
*/
try {
if(isIE)
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

if (document.onclick != null)
	dropdownmenu_backonload = document.onclick;
  document.onclick = dropdownmenu_fun_call;

if (window.onresize != null)
	dropdownmenu_backonload = window.onresize;
  window.onresize = dropdownmenu_fun_call_rexize;  
  document.write('<iframe id="dropdownmenu_DivShim1" src="/public/function01/img/bottom-middle.gif" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe> <iframe id="dropdownmenu_DivShim2" src="/public/function01/img/bottom-middle.gif" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>  <iframe id="dropdownmenu_DivShim3" src="/public/function01/img/bottom-middle.gif" scrolling="no" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>    <div id="dropdownmenu_menu" name="dropdownmenu_menu"  style="visibility: hidden" ></div>');
  //window.onmousewheel = document.onmousewheel = wheel; 
}
function clsmenu()
{

  if(itemMouseOut==true)
  {
  clearMenu();
  }
}
function rexize()
{
  if(itemMouseOut==true)
  {
  clearMenu();
  }
}
function hideElement(id_attribute_value)
{
   if (document.getElementById &&
         document.getElementById(id_attribute_value) &&
            document.getElementById(id_attribute_value).style)
   {
   document.getElementById(id_attribute_value).style.display="none";
   document.getElementById(id_attribute_value).style.visibility="hidden";   
   };
}
function ShowElement(id_attribute_value)
{
   if (document.getElementById &&
         document.getElementById(id_attribute_value) &&
            document.getElementById(id_attribute_value).style)
   {
   document.getElementById(id_attribute_value).style.display="";
   document.getElementById(id_attribute_value).style.visibility="visible";   
   };
}
 function SearchEvent()
{

	if(document.all)
		return window.event;

	func=SearchEvent.caller;
	while(func!=null)
	{
		var arg0=func.arguments[0];
		if(arg0)
		{
			if(arg0.constructor==Event)
				return arg0;
		}
		func=func.caller;
	}
	return null;
}

function dropdownmenu_keyDown(e) {
//當第一個選單出現在右半部鍵盤左右鍵需對調
if (!e) e = SearchEvent();  
var cur=currtd.split('_');
var tdd='';var tddd='';var end='';
//選單全部靠左
var drop_Left=37;
var drop_Right=39;
First_sT="tbl_"+cur[1];
if(GetAbsoluteLocationEx(document.getElementById(First_sT),2)>(alertSize(1)/2))
{
drop_Left=39;
drop_Right=37;
}
for(var i=1;i<cur.length-1;i++){tdd+='_'+cur[i];}
for(var i=1;i<cur.length;i++){tddd+='_'+cur[i];end=cur[i];}
var ieKey=getkeycode(e);
downcanuse=true;
if(cur.length==2 && ieKey != 9)
{
old=lloop;
lloop=1;
if(document.getElementById('td'+tddd+'_'+(lloop))){InKeybordUsed=true;
if(document.getElementById('td'+tddd+'_'+(lloop)).onmouseover)
document.getElementById('td'+tddd+'_'+(lloop)).onmouseover();
document.getElementById('td'+tddd+'_'+(lloop)).style.backgroundColor=hlBgColor;
document.getElementById('td'+tddd+'_'+(lloop)).style.color=hlColor;}else  lloop=old; 
}
else if (ieKey==40) 
{      
if(downcanuse==true)
++lloop;
if(document.getElementById('td'+tdd+'_'+(lloop))){  InKeybordUsed=true;     
if(document.getElementById('td'+tdd+'_'+(lloop)).onmouseover)
document.getElementById('td'+tdd+'_'+(lloop)).onmouseover();
document.getElementById('td'+tdd+'_'+(lloop)).style.backgroundColor=hlBgColor;
document.getElementById('td'+tdd+'_'+(lloop)).style.color=hlColor;
}else --lloop;
}
else if (ieKey==38)
{
if(downcanuse==true)
--lloop;
if(document.getElementById('td'+tdd+'_'+(lloop))){InKeybordUsed=true;
if(document.getElementById('td'+tdd+'_'+(lloop)).onmouseover)
document.getElementById('td'+tdd+'_'+(lloop)).onmouseover();
document.getElementById('td'+tdd+'_'+(lloop)).style.backgroundColor=hlBgColor;
document.getElementById('td'+tdd+'_'+(lloop)).style.color=hlColor;}else ++lloop;
}
else if (ieKey==drop_Right)
{
old=lloop;
lloop=1;
if(document.getElementById('td'+tddd+'_'+(lloop))){InKeybordUsed=true;
if(document.getElementById('td'+tddd+'_'+(lloop)).onmouseover)
document.getElementById('td'+tddd+'_'+(lloop)).onmouseover();
document.getElementById('td'+tddd+'_'+(lloop)).style.backgroundColor=hlBgColor;
document.getElementById('td'+tddd+'_'+(lloop)).style.color=hlColor;}else  lloop=old; 
}
else if (ieKey==drop_Left)
{
if(document.getElementById('td'+tdd)){InKeybordUsed=true;
lloop=end;
if(document.getElementById('td'+tdd).onmouseover)
document.getElementById('td'+tdd).onmouseover();
document.getElementById('td'+tdd).style.backgroundColor=hlBgColor;
document.getElementById('td'+tdd).style.color=hlColor;}     
}
else if (ieKey==13)
{
var str=currtd.split('_')[1];
if (eval("typeof("+currtd.replace('td','url')+")!=\"undefined\""))
{
setvalue(mymenus_id[str],mymenus_text[str],currtd);

}

}
else if (((ieKey==9) ||ieKey==27) || (ieKey >= 18 && ieKey <= 20)||(ieKey >= 44 && ieKey <= 45))
{
clearMenu();
}

    if(ieKey != 9)
    {stopEvent(e);}
    InKeybordUsed=false;
}
function checkhaddefined(myid)
{
  /* dr=haddraw.split(',');
   for(i=2;i<dr.length;i++)
   {
   if(dr[i]==myid)return true;
   }
   return false;*/

   if(document.getElementById(myid.replace('td','tbl'))){return true;}
   else return false;
}

function AppendDefaultDIV()
{
    var theDoc = document;
    var theBody=document.body;
    
 var test_menu=theDoc.createElement("div"); 
    var dropdownmenu_menu=theDoc.createElement("div");
        dropdownmenu_menu.id="dropdownmenu_menu";
        dropdownmenu_menu.name="dropdownmenu_menu";
        dropdownmenu_menu.style.visibility="hidden";
        theBody.appendChild(dropdownmenu_menu);
    var dropdownmenu_DivShim=null;
    for(i=1;i<=3;i++)
    {
      dropdownmenu_DivShim=theDoc.createElement("iframe");
      dropdownmenu_DivShim.id="dropdownmenu_DivShim"+i;
      dropdownmenu_DivShim.scrolling="no";
      dropdownmenu_DivShim.style.frameborder="0";
      dropdownmenu_DivShim.style.position="absolute";
      dropdownmenu_DivShim.style.display="none";
      dropdownmenu_DivShim.style.top="0px";
      dropdownmenu_DivShim.style.left="0px";
      dropdownmenu_DivShim.src="/public/function01/img/bottom-middle.gif";
      theBody.appendChild(dropdownmenu_DivShim);
    }

}
function __get_value(cls,deep,which,no)
{
	for(i=0;i<cls.length;i++)
	{
		if(cls[i].no==which[deep]){
		
			floor=i;
			if(deep<=1)return(cls[i]);
			break;
		}
		else floor=-1;
	}


	if( cls && cls[floor] && isUndefined(cls[floor].n)==false && deep>0)
	{

		return __get_value(cls[floor].n,--deep,which,floor);
	}
/*	else
	{
	 if(deep<=0){alert(cls[no].des);
	   return cls[no].des;}
	 else
	   return null;
	}*/
}

function __get(cls,deep,which,no)
{

	for(i=0;i<cls.length;i++)
	{
		if(cls[i].no==which[deep]){
		
			floor=i;
			break;
		}
		else floor=-1;
	}


	if( cls && cls[floor] && isUndefined(cls[floor].n)==false && deep>0)
	{

		return __get(cls[floor].n,--deep,which,no);
	}
	else
	{
	 if(deep<=0)
	   return cls;
	 else
	   return null;
	}
}
function checkdeep(Obj,deep)
{

	var i=deep;
	if(isUndefined(Obj[0].n)==false)
	{
		return checkdeep(Obj[0].n,++i);

	}
	else
	return deep+1;

}
  function drawmenu(td)
  {
  //obj,menu_id,menu_title,include_up_node,up_node_textbe,up_node_textaf,show_node,hide_node,can_choice_level,AppendRootNode
    var theDoc = document;
    var theBody =null ;
    if(document.getElementById('dropdownmenu_menu'))
      theBody=document.getElementById('dropdownmenu_menu');
    else
      theBody=document.body;
    var menu=theDoc.createElement("div");
    theBody.insertBefore(menu,null);
    
    var myid='';
    var nod;
    var  text;
    var level=0;


    if(typeof(td)=='string')myid=td;
      else{myid=td.id;}
    if(checkhaddefined(myid))return;
    sT="";
   //document.getElementById('td_16').value=td;
    td=myid.split('_');
       
    var obj=mymenus_array[td[1]].obj;
    var AppendRootNode=mymenus_array[td[1]].AppendRootNode;
    var include_up_node=mymenus_array[td[1]].include_up_node;
    var up_node_textbe=mymenus_array[td[1]].up_node_textbe;
    var up_node_textaf=mymenus_array[td[1]].up_node_textaf;
    var array2d = new Array();
    var hide_node=mymenus_array[td[1]].hide_node;
    var show_node=mymenus_array[td[1]].show_node;
		for(var i=1;i<td.length;i++){sT+="_"+td[i];}
    k=1;
    for(var i=td.length-1;i>=2;i--){array2d[k++]=td[i];}
    level=array2d.length-1;
    
    if(td.length<=2)
    {
      var array3d=obj.n;
      
    }
    else
      var array3d=__get(obj.n,level,array2d,0);    
    var drop_dwon_Max=mymenus_array[td[1]].can_choice_level;
    
//alert(__get(AreaRoot.n,2,array2d,0)[0].des);
    if(array3d && level<(drop_dwon_Max))
		//if (eval("typeof(td"+sT+"_"+ "1" +")!=\"undefined\""))
    {
      sH="";j=0;
      menu.id="tbl"+sT;
      menu.className="menu";
      menu.onmousewheel=wheel;
      menu.onmouseover=function () { itemMouseOut=false;};
      menu.onmouseout=function () { itemMouseOut=true;};
      menu.style.zIndex=100;
      menu.onkeydown=dropdownmenu_keyDown;

     // 跳到obj的那一個的開頭
      //while (eval("typeof(td"+sT+"_"+ ++j +")!=\"undefined\""))
      if( td.length==2)
  		{
  		var menu_title=null;
  		if(navigator.userAgent.indexOf('MSIE 5')>0)
        menu_title=theDoc.createElement("<div nowrap>");
      else  
        menu_title=theDoc.createElement("div");
  		menu.insertBefore(menu_title,null);
      menu_title.innerHTML=mymenus_array[td[1]].menu_title;	
          menu_title.onclick=clearMenu;
          menu_title.className="titleclose";
        //  sH+=mymenus_array[td[1]].menu_title;
        //  text = theDoc.createTextNode(sH);
            
          	  
      }
       
      if(AppendRootNode.length>0 )
      {
       if(navigator.userAgent.indexOf('MSIE 5')>0)
          nod=theDoc.createElement("<div nowrap>");
       else
          nod=theDoc.createElement("div");
       if(td.length==2)
       {
       menu.insertBefore(nod,null);
       nod.innerHTML=AppendRootNode.split(',')[0];
       //text = theDoc.createTextNode(AppendRootNode.split(',')[0]); 
       nod.onclick=setvalue2_fun(td[1],AppendRootNode.split(',')[0],AppendRootNode.split(',')[1]);
       //nod.onclick=function(){setvalue2(mymenus_id[this.id.split('_')[1]],mymenus_text[this.id.split('_')[1]],mymenus_array[this.id.split('_')[1]].AppendRootNode.split(',')[0],mymenus_array[this.id.split('_')[1]].AppendRootNode.split(',')[1]);}
       //nod.insertBefore(text,null);
       nod.id="td"+sT+"_0";
       }
     
       //else
       //{

       //}
          nod.onmouseout=unHilightus;
          nod.onmouseover=nodmouseoverclick;         
       nod.className="abc";
      }
      
        if( td.length!=2)
        {
         var parentvalue=getvalue(myid);
 /*       if(show_node!='')
        {
          if(!ShowOption(show_node,parentvalue.no))break;
        }
        if(hide_node!='')
        {
          if(HideOption(hide_node,parentvalue.no))break;
        }         */
         if(parentvalue.no!='6001000000' && ShowOption(show_node,parentvalue.no)&& !HideOption(hide_node,parentvalue.no) )
         {
           if(navigator.userAgent.indexOf('MSIE 5')>0)
              nod=theDoc.createElement("<div nowrap>");
           else
              nod=theDoc.createElement("div");
         //判斷是否要包含上一層
          if(include_up_node>=1 && (drop_dwon_Max-include_up_node) <=(level))
          {
          menu.insertBefore(nod,null);
         // text = theDoc.createTextNode(up_node_textbe+parentvalue.des+up_node_textaf );
         // nod.insertBefore(text,null);
          nod.innerHTML=up_node_textbe+parentvalue.des+up_node_textaf ;
          nod.id="td"+sT+"_"+parentvalue.no+"X";
          //nod.onclick=function(){setvalue(mymenus_id[this.id.split('_')[1]],mymenus_text[this.id.split('_')[1]],this.id);}
          nod.onclick=setvalue_fun(td[1],"td"+sT+"_"+parentvalue.no+"X");
          nod.onmouseout=unHilightus;
          nod.onmouseover=nodmouseoverclick;          
          nod.className="abc";
          }
         }
        }
     
      for(i=0;i<array3d.length;i++)
      {
        sH="";
           if(navigator.userAgent.indexOf('MSIE 5')>0)
              nod=theDoc.createElement("<div nowrap>");
           else
              nod=theDoc.createElement("div");
        if(show_node!='')
        {
          if(!ShowOption(show_node,array3d[i].no))continue;
        }
        if(hide_node!='')
        {
          if(HideOption(hide_node,array3d[i].no))continue;
        }
        menu.appendChild(nod);
        //text = theDoc.createTextNode(eval("td"+sT+"_"+j));
        sH=array3d[i].des;
        if(sH.length>30)
        {
        sH=sH.replace('--','<br>--');
        sH=sH.replace('-','<br>-');
        sH=sH.replace('(','<br>(');
        }
        if(sH.length>20)
        {

        if(sH.indexOf(' ')<=0)
          {

          sH=sH.substr(0,sH.length/2)+'<br>'+sH.substr(sH.length/2,sH.length);
          }
        }
        //text = theDoc.createTextNode(array3d[i].des);
        nod.innerHTML=sH;
        //nod.insertBefore(text,null);
        nod.name="td"+sT+"_"+(i+1);
        nod.id="td"+sT+"_"+array3d[i].no;
        
        //if(eval("typeof(td"+sT+"_"+ (j) +"_1)!=\"undefined\""))
        if(level<(drop_dwon_Max-1) && drop_dwon_Max!=1 )
  			{
  			nod.onmouseover=Hilightus;
        nod.onmouseout=unHilightus;
        nod.className="def";
        }
        else
        {
          nod.onmouseout=nodmouseout;
          //if(eval("typeof(url"+sT+"_"+j+")!='undefined'"))
          if(level==(drop_dwon_Max-1) || drop_dwon_Max==1)
          {
            //nod.onclick=function(){setvalue(mymenus_id[this.id.split('_')[1]],mymenus_text[this.id.split('_')[1]],this.id);}
            nod.onclick=setvalue_fun(td[1],"td"+sT+"_"+array3d[i].no);
            nod.onmouseover=nodmouseoverclick;        
            nod.className="abc";
          }
          else
          {
            nod.onmouseover=Hilightus;
            nod.className="abc";
          }
        }
      }
    }
    theDoc = null;
    theBody =null ;
    menu=null ;
    myid=null ;
    nod=null ;
    text=null ;
    level=null ; 
    obj=null ;
    AppendRootNode=null ;
    include_up_node=null ;
    up_node_textbe=null ;
    up_node_textaf=null ;
    array2d = null ;
    array3d=null ;
    
 }

function HideOption(hideoption,options)
{
	showoption=hideoption.toString();
	if(showoption.length<=0)return false;
	options=options.toString();
	var myselect=showoption.split(',');
	for(var i=0;i<myselect.length;i++)
	{
	 if(options==myselect[i])
		return true;
	}
	return false;
}

function ShowOption(showoption,options)
{
	//判斷是否有包含在節點內以及是否要顯示
	showoption=showoption.toString();
	if(showoption.length<=0)return true;
	options=options.toString();
	var myselect=showoption.split(',');


					for(var i=0;i<myselect.length;i++)
					{
						if(options.substr(options.length-6,6)=='000000')
						{
    							if(options.substr(0,options.length-6)==myselect[i].substr(0,myselect[i].length-6))
    							return true;							
						}
			      		
						if((options.substr(options.length-3,3)=='000')&&(options.substr(options.length-6,6)!='000000'))
						{
    							if(options.substr(0,options.length-3)==myselect[i].substr(0,myselect[i].length-3))
    							return true;

    						if(myselect[i].substr(myselect[i].length-6,6)=='000000')
    						{
    							if(options.substr(0,options.length-6)==myselect[i].substr(0,myselect[i].length-6))
    							return true;							
    						} 
						}

            if((options.substr(options.length-3,3)!='000')&&(options.substr(options.length-6,6)!='000000'))
            {
              if(options==myselect[i])
							return true;
    						if((myselect[i].substr(options.length-3,3)=='000')&&(myselect[i].substr(options.length-6,6)!='000000'))
    						{						
    							if(options.substr(0,options.length-3)==myselect[i].substr(0,myselect[i].length-3))
    							return true;	
    						}
    						if(myselect[i].substr(myselect[i].length-6,6)=='000000')
    						{
    							if(options.substr(0,options.length-6)==myselect[i].substr(0,myselect[i].length-6))
    							return true;							
    						}    						
            }
					}
				return false;
}

 function Hilightus()
 {
 this.style.color=hlColor;this.style.backgroundColor=hlBgColor;itemMouseOut=false;Time_to_doMenu(this.id);
 }
 function unHilightus()
 {
 this.style.color=tdColor;this.style.backgroundColor=tdBgColor;itemMouseOut=true;this.style.textDecoration='none';
 if(navigator.userAgent.indexOf('Netscape6/6.0')<=0)
      clearTimeout(t0);
 }
 function nodmouseout()
 {
 this.style.color=tdColor;this.style.backgroundColor=tdBgColor;this.style.textDecoration='none';itemMouseOut=true;
 }
 function nodmouseoverclick()
 {
 this.style.color=hlColor;this.style.backgroundColor=hlBgColor;itemMouseOut=false;this.style.textDecoration='underline';Time_to_doMenu(this.id);
 }
  function setvalue2_fun(_id,des,_value) {
    return function() {
      setvalue2(mymenus_id[_id],mymenus_text[_id],des,_value);
    };
  }
  //setvalue(mymenus_id[this.id.split('_')[1]],mymenus_text[this.id.split('_')[1]],this.id)
  function setvalue_fun(_id,_value) {
    return function() {
      setvalue(mymenus_id[_id],mymenus_text[_id],_value);
    };
  }
/*  var f = concat("hello ");
  // ... later
  alert(f("world!"));*/
  
  function addEventListener( element, event_name, observer, capturing ) 
  {  
  if ( element.addEventListener ) 
  // the DOM2, W3C way  
  element.addEventListener( event_name, observer, capturing ); else if ( element.attachEvent ) 
  // the IE way  
  element.attachEvent( "on" + event_name, observer ); 
  }

function setvalue2(id,value_id,_value1,_value2)
{    
   if (document.getElementById &&
         document.getElementById(id) 
            )
            {      
              if(navigator.userAgent.indexOf('Netscape6')>0)
              {
                document.getElementById(id).setAttribute("value",_value1);
                document.getElementById(value_id).setAttribute("value",_value2.replace(/<BR>/g," "));
                if(document.getElementById(id).getAttribute('onchange'))
                eval(document.getElementById(id).getAttribute('onchange'));
              }
              else
              {
                document.getElementById(id).value=_value1;
                document.getElementById(value_id).value=_value2;
                if(document.getElementById(id).onchange)
                document.getElementById(id).onchange();
              }
            clearMenu();
            }
            
/*try{
if(navigator.userAgent.indexOf('Netscape6/6.0')>0 )
clearTimeout(t0);
}catch(e){};*/
}
function getvalue(__value)
{
   var _array2d = new Array();
    __td=__value.split('_');
    var _obj=mymenus_array[__td[1]].obj;    
		__k=1;
    for(var i=__td.length-1;i>=2;i--){_array2d[__k++]=__td[i];}
      __level=_array2d.length-1;

    return __get_value(_obj.n,__level,_array2d,0);

}
function setvalue(id,value_id,_value)
{
var appendmytext=false;
if(_value.indexOf('X')>0)
{
_value=_value.substr(0,_value.lastIndexOf('_'));
appendmytext=true;
}
    var array2d = new Array();
    td=_value.split('_');
    var obj=mymenus_array[td[1]].obj;
    var up_node_textbe=mymenus_array[td[1]].up_node_textbe;
    var up_node_textaf=mymenus_array[td[1]].up_node_textaf;    
    mymenus_array[td[1]];
		for(var i=1;i<td.length;i++){sT+="_"+td[i];}
    k=1;
    for(var i=td.length-1;i>=2;i--){array2d[k++]=td[i];}
      level=array2d.length-1;

    var array3d=__get_value(obj.n,level,array2d,0);
   
   if (document.getElementById &&
         document.getElementById(id) && array3d 
            )
            {      
              if(navigator.userAgent.indexOf('Netscape6')>0)
              {
                if(appendmytext)
                {
                document.getElementById(id).setAttribute("value",up_node_textbe+array3d.des.replace(/<BR>/g," ")+up_node_textaf);
                document.getElementById(value_id).setAttribute("value",array3d.no);
                if(document.getElementById(id).getAttribute('onchange'))
                eval(document.getElementById(id).getAttribute('onchange'));
                }
                else
                {
                document.getElementById(id).setAttribute("value",array3d.des.replace(/<BR>/g," "));
                document.getElementById(value_id).setAttribute("value",array3d.no);
                if(document.getElementById(id).getAttribute('onchange'))
                eval(document.getElementById(id).getAttribute('onchange'));
                }
              }
              else
              {
                if(appendmytext)
                {
                document.getElementById(id).value=up_node_textbe+array3d.des.replace(/<BR>/g," ")+up_node_textaf;
                document.getElementById(value_id).value=array3d.no;
                if(document.getElementById(id).onchange)
                document.getElementById(id).onchange();
                }
                else
                {
                document.getElementById(id).value=array3d.des.replace(/<BR>/g," ");
                document.getElementById(value_id).value=array3d.no;
                if(document.getElementById(id).onchange)
                document.getElementById(id).onchange();
                }
              }
            clearMenu();
            }
            
/*try{
if(navigator.userAgent.indexOf('Netscape6/6.0')>0 )
clearTimeout(t0);
}catch(e){};*/
}
function stopEvent(ev) {stopPropagation(ev);preventDefault(ev);}
function stopPropagation(ev) {if (ev.stopPropagation) {ev.stopPropagation();} else {ev.cancelBubble = true;}}
function preventDefault(ev) {if (ev.preventDefault) {ev.preventDefault();} else {ev.returnValue = false;}}
