﻿//2009/3/12 更新 □ ■
var tdColor = "#000";
var tdBgColor = "#f5f5f5";
var hlColor = "#000";
var hlBgColor = "#d4d4d4";
var ti = -1;
var oTd = null;
var t0;
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_inputcount=new Array();
var mymenus_hidden = new Array();
var itemMouseOut = false;
//var downcanuse = false;
var for104temp = false;
var isIE = navigator.appVersion.match(/MSIE/) == "MSIE";
var mymenus_value = new Array();
var mymenus_value_des = new Array();
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;
    this.style = null;
    //this.style = null;
    
}


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;
    mymenus_array[menu_no].style = 1;
    //mymenus_array[menu_no].dropInputCount = 1;
}

function CreateDropDownMenu_CheckBox(obj, menu_id, menu_title, include_up_node, up_node_textbe, up_node_textaf, show_node, hide_node, can_choice_level, AppendRootNode) {
    CreateDropDownMenu(obj, menu_id, menu_title, include_up_node, up_node_textbe, up_node_textaf, show_node, hide_node, can_choice_level, AppendRootNode);
    var menu_no = menu_id.split('_')[1];
    mymenus_array[menu_no].style = 2;
}

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( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
   if (which == 1) return myWidth;
    else return myHeight;
}/*
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,inputcount) {
/*id:顯示的,v_id隱藏的hidden*/
    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) {
        if (document.getElementById(v_id).options) {
            mymenus_id[tda[1]] = id;
            mymenus_text[tda[1]] = v_id;
            mymenus_inputcount[tda[1]] = inputcount;
            var temp_mymenus_id = '';
            if (document.getElementById(v_id).length > 0 && document.getElementById(v_id).options[0].value.length > 0) temp_mymenus_id = document.getElementById(v_id).options[0].value;

            for (xi = 1; xi < document.getElementById(v_id).length; xi++) {
                temp_mymenus_id = temp_mymenus_id + ',' + document.getElementById(v_id).options[xi].value;
            }

            _temptd = setlastvalue(td, temp_mymenus_id);
            if (document.getElementById(v_id).value) _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);
        } else {
            mymenus_id[tda[1]] = id;
            mymenus_text[tda[1]] = v_id;
            mymenus_inputcount[tda[1]] = inputcount;
            if(mymenus_array[td.split('_')[1]].style==2)
            _temptd = null;
            else
            _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 (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(mymenus_array[td.split('_')[1]].style==2)
{id=rt;}


    if (id != null && rt != null) {
        sT += "_" + tda[1];
        document.getElementById(sT).style.visibility = "visible";
        click_all_checkbox(sT);
        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);
            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';

        }
    }


    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';

            }

            /*當前一個選單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";

            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 {
                    oxTScrollWidth = 12;
                }
            }
            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) - 20)+"px";//key1
            }
            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);
                        /*螢幕高度+滑動軸高度*/
                        /*取得第一個選單是向上還是向下*/
                        //alert(document.getElementById(sT).style.top);
                        if ((y - x - 25) > 0) {
                            document.getElementById(sT).style.top = (y - x - 25) + "px";
                        } else {
                            document.getElementById(sT).style.top = "10px";
                        }//alert(1);
                         if ((getRootCoord(id, rt, sT, 1).replace('px;left', '').replace('px">', '').split(':')[0] - getScrollXY(2)) > ((alertSize(2)) / 2))
                        if(GetAbsoluteLocationEx(document.getElementById(sT), 4)>alertSize(2))
                            {
                              document.getElementById(sT).style.top=document.getElementById("tbl_" + tda[1]).style.top;
                              document.getElementById(sT).style.height=document.getElementById("tbl_" + tda[1]).style.height;
                            }
                    }
                }

                if (tda.length >= 2) {
                    First_sT = "tbl_" + tda[1];
                    /*選單全部靠左*/
                     // alert(GetAbsoluteLocationEx(document.getElementById(First_sT), 2));
                     // alert((alertSize(1) / 2));
                    if (GetAbsoluteLocationEx(document.getElementById(First_sT), 2) > ((alertSize(1) / 2)+10)) {
                        before_sT = "tbl";
                        for (j = 1; j < i; j++) before_sT += "_" + tda[j];

                        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";
                            else document.getElementById(sT).style.left = (GetAbsoluteLocationEx(document.getElementById(before_sT), 2) - GetAbsoluteLocationEx(document.getElementById(sT), 3)) + "px";
                        } else document.getElementById(sT).style.left = (GetAbsoluteLocationEx(document.getElementById(before_sT), 2) - GetAbsoluteLocationEx(document.getElementById(sT), 3)) + "px";
                    } 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";
                        }
                    }
                }
            }

            if (for104temp == true && tda[1] == 2 && tda.length > 2) {
                document.getElementById('tbl_2').style.visibility = "visible";
                click_all_checkbox('tbl_2');
            } else {
                document.getElementById(sT).style.visibility = "visible";
                click_all_checkbox(sT);
            }


        }
 
        /*選單高度重設後要調整位置*/
        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)) {
                    if (i >= 2) {
                        rootst = "tbl_" + tda[1];
                        if ((GetAbsoluteLocationEx(document.getElementById(rootst), 4)) < (GetAbsoluteLocationEx(document.getElementById(sT), 4))) {
                            if((GetAbsoluteLocationEx(document.getElementById(sT), 4)) >= ((GetAbsoluteLocationEx(document.getElementById(rootst), 1))-getScrollXY(2)+(GetAbsoluteLocationEx(document.getElementById(rootst), 4))))
                            document.getElementById(sT).style.height = (GetAbsoluteLocationEx(document.getElementById(rootst), 1))-getScrollXY(2)+(GetAbsoluteLocationEx(document.getElementById(rootst), 4))+"px";
                        }
                    }
                    document.getElementById(sT).style.top = getRootCoord(id, rt, sT, 2).replace('px;left', '').replace('px">', '').split(':')[0] + 'px';
                }
            }
        }
                           
        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";
                } 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)) {
                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 click_all_checkbox(_td) {

    var level = _td.split('_').length - 1;
    var _mymenus = mymenus_array[_td.split('_')[1]];
    if(_mymenus.style!=2)return;
    var can_choice_Max = _mymenus.can_choice_level;
    var my_input_count = mymenus_inputcount[_td.split('_')[1]];
    
    var drop_Max = checkdeep(_mymenus.obj.n, 0);
    var drop_include_up_node = _mymenus.include_up_node;
    //  alert(can_choice_Max+":"+drop_Max+":"+drop_include_up_node+":"+level);
    if (level == can_choice_Max || (level + drop_include_up_node) >= can_choice_Max) {
        var mymenubox = document.getElementById(_td);
        for (incress_i = 0; incress_i < mymenubox.childNodes.length; incress_i++) {
            var mymenubox_child = mymenubox.childNodes[incress_i].childNodes;
            for (incress_j = 0; incress_j < mymenubox_child.length; incress_j++) {
                if (mymenubox_child[incress_j].tagName == 'INPUT') {
                
                    var _mymenus_value = document.getElementById(mymenus_text[_td.split('_')[1]]);
                    var check_hts_id = mymenubox_child[incress_j].id.split('_');
                        check_hts_id = check_hts_id[check_hts_id.length - 1];
                    if(_mymenus_value.value.split(',').length>=my_input_count)
                    {
                    mymenubox_child[incress_j].setAttribute("DISABLED","DISABLED");
                    mymenubox_child[incress_j].disabled=true;
                    nextnode=myfindNextNode(mymenubox_child[incress_j],mymenubox_child[incress_j].nodeType);
                    nextnode.style.color='#888';
                        if(_mymenus_value.value.indexOf(check_hts_id)>=0)
                        {
                        mymenubox_child[incress_j].removeAttribute("DISABLED");
                        mymenubox_child[incress_j].disabled=false;
                        nextnode=myfindNextNode(mymenubox_child[incress_j],mymenubox_child[incress_j].nodeType);
                        nextnode.style.color='#000';
                        }                                        
                    }
                    else
                    {
                    mymenubox_child[incress_j].removeAttribute("DISABLED");
                    mymenubox_child[incress_j].disabled=false;
                    nextnode=myfindNextNode(mymenubox_child[incress_j],mymenubox_child[incress_j].nodeType);
                    nextnode.style.color='#000';                      
                    }
                    
                    if (mymenubox_child[incress_j].checked == true) {
                        mymenubox_child[incress_j].checked=false;
                    }
                    if(_mymenus_value.value.indexOf(check_hts_id)>=0)
                    {
                        mymenubox_child[incress_j].checked=true;
                    }
                    //my_input_count

                    //mymenubox_child[incress_j].disabled  == false;
                    
                    //var check_hts_id_main = check_hts_id[1];
                    
                    

                    //
                }
            }
        }
    }
}
function myallcheckbox(obj,enabled)
{
			 var mynodethis=null;	
       if (typeof(obj) == 'string')
       	mynodethis=document.getElementById(obj);
       else
       	mynodethis=obj;
				//alert(mynodethis.parentNode.parentNode.innerHTML);
        mymenubox=mynodethis.parentNode.parentNode;
       for (incress_i = 0; incress_i < mymenubox.childNodes.length; incress_i++) {
              var mymenubox_child = mymenubox.childNodes[incress_i].childNodes;
              for (incress_j = 0; incress_j < mymenubox_child.length; incress_j++) {
                  if (mymenubox_child[incress_j].tagName == 'INPUT') {
                      if(enabled=='disabled')
                      {
                        if (mymenubox_child[incress_j].checked == false) {
                            mymenubox_child[incress_j].setAttribute("DISABLED","DISABLED");
                            mymenubox_child[incress_j].disabled=true;
                            nextnode=myfindNextNode(mymenubox_child[incress_j],mymenubox_child[incress_j].nodeType);
                            nextnode.style.color='#888';
                        }
                      }
                      else
                      {
                        mymenubox_child[incress_j].removeAttribute("DISABLED");
                        mymenubox_child[incress_j].disabled=false;
                        nextnode=myfindNextNode(mymenubox_child[incress_j],mymenubox_child[incress_j].nodeType);                        
                        nextnode.style.color='#000';
                      }
                  }        
              }
       }
}
function myfindNextNode(root, nodeType) {
    var e = root;
    do {
        e = e.nextSibling;
    }
    while (e && e.nodeType != nodeType);
    return (e);
}
function _getdescript(id, no) {
    var obj = mymenus_array[id].obj;
    var array2d = new Array();
    var value_array = no;

    var ins_curtddd = '';
    if (value_array.substr(value_array.length - 6, 6) == '000000') {
        ins_curtddd = value_array;
    } else if (value_array.substr(value_array.length - 3, 3) == '000') {
        ins_curtddd = value_array.substr(0, value_array.length - 6) + "000000_" + value_array;
    } else {
        ins_curtddd = value_array.substr(0, value_array.length - 6) + "000000_" + value_array.substr(0, value_array.length - 3) + "000_" + value_array;
    }
    td = ins_curtddd.split('_');
    k = 1;
    for (var i = td.length - 1; i >= 0; i--) {
        array2d[k++] = td[i];
    }
    level = array2d.length - 1;

    var array3d = __get_value(obj.n, level, array2d, 0);
    if (array3d != null) return array3d.des;
}
/*判斷大類是否存在
判斷中類是否存在
判斷小類是否存在

1-2-3
決定如何串接
*/
function setlastvalue(td, inputvalue) {
  
    var dtd = '';
    var _curtddd = '';
    if(isUndefined(inputvalue))return false;
    var _mymenus = mymenus_array[td.split('_')[1]];
    var _myobj_root_no = _mymenus.obj.n[0].no;
    var _Star_order=1;
    if (_myobj_root_no.substr(_myobj_root_no.length - 6, 6) == '000000') {
        _Star_order=1;
    } else if (_myobj_root_no.substr(_myobj_root_no.length - 3, 3) == '000') {
        _Star_order=2;
    } else {
        _Star_order=3;
    }
          
    var sp_inputvalue = inputvalue.split(',');
    
    if (navigator.userAgent.indexOf('MSIE 5') > 0) return;
    if (inputvalue.length <= 0) return td;
    if (inputvalue.substr(inputvalue.length - 6, 6) == '000000') {
        if(_Star_order==1)
        _curtddd = td + "_" + inputvalue;
    } else if (inputvalue.substr(inputvalue.length - 3, 3) == '000') {
        if(_Star_order==1)
        _curtddd = td + "_" + inputvalue.substr(0, inputvalue.length - 6) + "000000_" + inputvalue;
        else if(_Star_order==2)
        _curtddd = td + "_" + inputvalue;
    } else {
        if(_Star_order==1)
        _curtddd = td + "_" + inputvalue.substr(0, inputvalue.length - 6) + "000000_" + inputvalue.substr(0, inputvalue.length - 3) + "000_" + inputvalue;
        else if(_Star_order==2)
        _curtddd = td + "_" + inputvalue.substr(0, inputvalue.length - 3) + "000_" + inputvalue;
        else if(_Star_order==3)
        _curtddd = td + "_" + inputvalue;
    }
    if (isUndefined(inputvalue.length) == false) dtd = inputvalue;
    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);
        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();
        }
    }

    return _curtddd;
}
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) {
            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 = "";
    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 (obj1) {
        obj2y = GetAbsoluteLocationEx(obj2, 1);
        obj2x = GetAbsoluteLocationEx(obj2, 2);
        obj2w = obj2.offsetWidth;
        obj2h = obj2.offsetHeight;

        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;
    }
}

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 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\">";
    }
}

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) {
        delta = -event.detail / 3;
    }
    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();
}

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"  scrolling="no" src="/public/function01/img/bottom-middle.gif" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>  <iframe id="dropdownmenu_DivShim3"  scrolling="no" src="/public/function01/img/bottom-middle.gif" frameborder="0" style="position:absolute; top:0px; left:0px; display:none;"></iframe>    <div id="dropdownmenu_menu" name="dropdownmenu_menu"  style="visibility: hidden" ></div>');
}
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) {}

function checkhaddefined(myid) {
    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);
    }
}

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");
    var myid = '';
    var nod;
    var text;
    var level = 0;
    if (typeof(td) == 'string') myid = td;
    else {
        myid = td.id;
    }
    if (checkhaddefined(myid)) return;
    sT = "";
    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;

    if (array3d && level < (drop_dwon_Max)) {
        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的那一個的開頭*/
        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";
        }
        if (AppendRootNode.length > 0 && mymenus_array[td[1]].style == 1) {
            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];
                nod.onclick = setvalue2_fun(td[1], AppendRootNode.split(',')[0], AppendRootNode.split(',')[1]);
                nod.id = "td" + sT + "_0";
            }

            nod.onmouseout = unHilightus;
            nod.onmouseover = nodmouseoverclick;
            nod.className = "abc";
        }
        if (td.length != 2) {
            var parentvalue = getvalue(myid);
            if (parentvalue.no != '6001000000' && ShowOptions(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) && mymenus_array[td[1]].style == 1) {
                    menu.insertBefore(nod, null);
                    nod.innerHTML =  up_node_textbe + parentvalue.des + up_node_textaf;
                    nod.id = "td" + sT + "_" + parentvalue.no + "X";
                    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 (!ShowOptions(show_node, array3d[i].no)) continue;
            }
            if (hide_node != '') {
                if (HideOption(hide_node, array3d[i].no)) continue;
            }
            menu.appendChild(nod);
            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);
                }
            }
            var nodid = "td" + sT + "_" + array3d[i].no;
            nod.name = "td" + sT + "_" + (i + 1);
            nod.id = nodid;
            if (level < (drop_dwon_Max - 1) && drop_dwon_Max != 1) {
                nod.onmouseover = Hilightus;
                nod.onmouseout = unHilightus;
                nod.className = "def";
                nod.innerHTML = sH;
            } else {
                nod.onmouseout = nodmouseout;
                if (level == (drop_dwon_Max - 1) || drop_dwon_Max == 1) {
                    
                    
                    nod.onmouseover = nodmouseoverclick;
                    if (mymenus_array[td[1]].style == 1) {
                        nod.onclick = setvalue_fun(td[1], "td" + sT + "_" + array3d[i].no);
                        nod.innerHTML = sH;                        
                        nod.className = "abc";
                    } else {
                         nod.className = "abcchk";
                        var my_img = theDoc.createElement("input");
                        var my_lbl = theDoc.createElement("label");
                        my_img.id = "check" + nodid;
                        my_img.type='checkbox';
                        my_img.onclick = setvalue_fun(td[1], "td" + sT + "_" + array3d[i].no);
                        if(isIE)
                        my_lbl.htmlFor="check" + nodid;
                        else
                        my_lbl.setAttribute('for', "check" + nodid);
                        my_lbl.innerHTML=sH;
                        my_lbl.style.cursor='pointer';
                        nod.insertBefore(my_img,null);
                        nod.insertBefore(my_lbl,null);  
                    }
                } else {
                    nod.onmouseover = Hilightus;
                    nod.className = "abc";
                    nod.innerHTML = sH;
                }
            }
        }
    }
    if (menu.innerHTML.length > 0) theBody.insertBefore(menu, null);
    else menu = null;
    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 ShowOptions(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);
    };
}
function setvalue_fun(_id, _value) {
    return function() {
        setvalue(mymenus_id[_id], mymenus_text[_id], _value, _id,this);
    };
}

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();
    }
}
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, _id,myobj) {

    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;
    var my_input_count = mymenus_inputcount[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(mymenus_array[td[1]].style==1){
        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();}
        else
        {
            if (myobj.checked == true) {
            
               tempval=document.getElementById(value_id).value;
               if(tempval)
               {
               tempval=tempval.split(',');
               if(tempval.length>=(my_input_count-1)){myallcheckbox(myobj,'disabled');}
               if(tempval.length>=my_input_count){myobj.checked=false;return false;}
               //if(tempval.length>=my_input_count){disaballcheckbox(myobj);return false;}
               tempval[tempval.length]=array3d.no;
               document.getElementById(value_id).value=tempval.toString();
               }
               else
               document.getElementById(value_id).value= array3d.no;
            
               var _elOptNew = document.createElement('li');
               document.getElementById(id).insertBefore(_elOptNew,null);             
               _elOptNew.id='cert_'+Math.round(Math.random()*100000000)+'_'+ array3d.no ;
               //_elOptNew.setAttribute("id",'cert_'+ array3d.no );
               var elOptimg=document.createElement('IMG');
               elOptimg.onclick=function(){clear_certClick(this,array3d.no,value_id)};
               elOptimg.src='/public/function01/img/del.gif';
               elOptimg.style.width='14px';
               elOptimg.style.height='14px';               
               elOptimg.style.cursor='pointer';
                
               _elOptNew.insertBefore( document.createTextNode(" " + array3d.des+"　"),null);
               _elOptNew.appendChild(elOptimg);
            } else {
              myallcheckbox(myobj,'enabled');
              tempvaldel=document.getElementById(value_id).value;
              if(tempvaldel)
              {
              tempvaldel=tempvaldel.split(',');
              tempvaldel.myremove(array3d.no);
              document.getElementById(value_id).value=tempvaldel.toString();
              }
              if(document.getElementById(id).hasChildNodes()){
                  My_child=document.getElementById(id).childNodes;
                  for(i=0;i<My_child.length;i++)
                  {
                  
                  if(My_child[i].id && My_child[i].id.indexOf(array3d.no)>0)
                    clear_certClick2(My_child[i],value_id);
                  }
              }
            }
            if (document.getElementById(value_id).onchange) document.getElementById(value_id).onchange();
            //判斷物件type選擇不同回傳方式
        }
    }
}
Array.prototype.myremove = function(obj)
{
    for ( var i=0 ; i < this.length ; ++i )
    {
        if ( this[i] == obj )
        {
            if ( i > this.length/2 )
            {
                for ( var j=i ; j < this.length-1 ; ++j )this[j] = this[j+1];
                
                this.pop();
            }
            else
            {
                for ( var j=i ; j > 0 ; --j )this[j] = this[j-1];
                this.shift();
            }
            break;
        }
    }
};

		  function clear_certClick2(obj,value_id){
			 var mynodethis=null;	
       if (typeof(obj) == 'string')
       	mynodethis=document.getElementById(obj);
       else
       	mynodethis=obj;
				mynodethis.parentNode.removeChild(mynodethis);
				if (document.getElementById(value_id).onchange) document.getElementById(value_id).onchange();
			}
			function clear_certClick(obj,no,value_id){
       var mynodethis=null;	
       var tempvaldel=document.getElementById(value_id).value;
       
       if(tempvaldel)
         {
            tempvaldel=tempvaldel.split(',');
            tempvaldel.myremove(no);
            
            document.getElementById(value_id).value=tempvaldel.toString();
         }
       if (typeof(obj) == 'string')
       	mynodethis=document.getElementById(obj);
       else
       	mynodethis=obj;
				mynodethis.parentNode.parentNode.removeChild(mynodethis.parentNode);
				if (document.getElementById(value_id).onchange) document.getElementById(value_id).onchange();
			}
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;
    }
}
function clear_certClick_fun( _textbox, _valuebox) {
    return function() {
        clear_certClick(this, _textbox, _valuebox);
    };
}
function init_checkbox_menu(jsonobj,_textbox,_valuebox){

  tempoj='';                                                                                  
  //if(jsonobj.length>0)tempoj=jsonobj[0].no;
  for(i=0;i<jsonobj.length;i++)
  {
    if(i==0)
    tempoj=jsonobj[i].no;
    else
    tempoj=tempoj+','+jsonobj[i].no;
    
     var _elOptNew = document.createElement('li');
     document.getElementById(_textbox).insertBefore(_elOptNew,null);             
     _elOptNew.id='cert_'+Math.round(Math.random()*100000000)+'_'+ jsonobj[i].no ;
              //_elOptNew.setAttribute("id",'cert_'+ array3d.no );
     var elOptimg=document.createElement('IMG');
     elOptimg.onclick=clear_certClick_fun(jsonobj[i].no,_valuebox);
     
     elOptimg.src='/public/function01/img/del.gif';
     elOptimg.style.cursor='pointer';
     elOptimg.style.width='14px';
     elOptimg.style.height='14px';
     _elOptNew.insertBefore( document.createTextNode(" " + jsonobj[i].des+"　"),null);
     _elOptNew.appendChild(elOptimg);
     document.getElementById(_valuebox).value=tempoj;    
  }
  
 
}
 

