<!--

/*
 *
 *  File Name : EHWScript.js
 *
 *  Description : eHomeWork Project JavaScript Collections
 *
 *  Copyright (c) 2004, 2006  All Rights Reserved by eHomeWrok Ditital Culture, Inc.
 *
 *  Modification
 *
 *  Date        Version     Author                Description
 *  ----------  ----------  --------------------  ---------------------------------------
 *  2004/04/27  0.1         George S.H. Wang      :Q
 *
 */

function check_digit(obj, tSize, wSign)
{
    var oValue = obj.value;
    var str = "";

    if(!tSize){
        tSize = 0;
    }

    for(var i = 0; i < oValue.length; i++){
        if(wSign && i == 0 && oValue.charAt(i) == '-'){
            str += oValue.charAt(i);
        }
        else if(oValue.charAt(i) >= '0' && oValue.charAt(i) <= '9'){
            str += oValue.charAt(i)
        }
    }

    if(tSize > 0 && str.length > tSize){
        str = str.substring(0, tSize);
    }

    if(obj.value != str){
        obj.value = str;
    }
}

function check_alnum(obj, tSize, toCase)
{
    var oValue = obj.value;
    var str = "";

    if(!tSize){
        tSize = 0;
    }

    for(var i = 0; i < oValue.length; i++){
        if(oValue.charAt(i) >= '0' && oValue.charAt(i) <= '9'){
            str += oValue.charAt(i)
        }
        if(oValue.charAt(i) >= 'a' && oValue.charAt(i) <= 'z'){
            str += oValue.charAt(i)
        }
        if(oValue.charAt(i) >= 'A' && oValue.charAt(i) <= 'Z'){
            str += oValue.charAt(i)
        }
    }

    if(toCase == "l"){
        str = str.toLowerCase();
    }
    else if(toCase == "u"){
        str = str.toUpperCase();
    }

    if(tSize > 0 && str.length > tSize){
        str = str.substring(0, tSize);
    }

    if(obj.value != str){
        obj.value = str;
    }
}

function check_receiver(obj, tSize, toCase)
{
    var oValue = obj.value;
    var str = "";

    if(!tSize){
        tSize = 0;
    }

    for(var i = 0; i < oValue.length; i++){
        if(oValue.charAt(i) >= '0' && oValue.charAt(i) <= '9'){
            str += oValue.charAt(i)
        }
        if(oValue.charAt(i) >= 'a' && oValue.charAt(i) <= 'z'){
            str += oValue.charAt(i)
        }
        if(oValue.charAt(i) >= 'A' && oValue.charAt(i) <= 'Z'){
            str += oValue.charAt(i)
        }
        if(oValue.charAt(i) == '@' || oValue.charAt(i) == '.' || oValue.charAt(i) == ',' || oValue.charAt(i) == ';' || oValue.charAt(i) == '_' || oValue.charAt(i) == '-'){
            str += oValue.charAt(i)
        }
    }

    if(toCase == "l"){
        str = str.toLowerCase();
    }
    else if(toCase == "u"){
        str = str.toUpperCase();
    }

    if(tSize > 0 && str.length > tSize){
        str = str.substring(0, tSize);
    }

    if(obj.value != str){
        obj.value = str;
    }
}

function check_float(obj, tSize, fSize, wSign)
{
    var oValue = obj.value;
    var str = "";
    var dot = 0;

    if(!tSize){
        tSize = 0;
    }

    if(!fSize){
        fSize = -1;
    }

    if((dot = oValue.indexOf(".")) != -1){
        for(var i = 0; i < oValue.length; i++){
            if(i <= dot && oValue.charAt(i) == '.' && fSize == 0){
                continue;
            }
            else if(i > dot && oValue.charAt(i) == '.'){
                continue;
            }
            str += oValue.charAt(i);
        }

        if(oValue != str){
            oValue = str;
        }
    }

    str = "";
    for(var i = 0; i < oValue.length; i++){
        if(wSign && i == 0 && oValue.charAt(i) == '-'){
            str += oValue.charAt(i);
        }
        else if(oValue.charAt(i) >= '0' && oValue.charAt(i) <= '9' || oValue.charAt(i) == '.'){
            str += oValue.charAt(i);
        }
    }

    if(oValue != str){
        oValue = str;
    }

    str = "";
    dot = oValue.indexOf(".") != -1 ? oValue.indexOf(".") + (1 + fSize) : oValue.length;
    dot = fSize > -1 ? dot : oValue.length + 1;

    for(var i = 0; i < dot; i++){
        if(wSign && i == 0 && oValue.charAt(i) == '-'){
            str += oValue.charAt(i);
        }
        else if(oValue.charAt(i) >= '0' && oValue.charAt(i) <= '9' || (oValue.charAt(i) == '.' && i < dot - 1 && str.indexOf(".") == -1)){
            str += oValue.charAt(i);
        }
    }

    if(tSize > 0 && str.length > tSize){
        str = str.substring(0, tSize);
    }

    if(obj.value != str){
        obj.value = str;
    }
}

function checkMaxLength(textObj, maxLength)
{
    var i, j, l, s = textObj.value;

    for(i = 0, j = 0, l = 0; i < textObj.value.length; i++){
        l += textObj.value.charCodeAt(i) > 255 ? 2 : 1;
        if(l <= maxLength){
            j = i + 1;
        }
    }

    if(l > maxLength){
        alert("±z©Ò¿é¤Jªº¸ê®Æ¹Lªø!");
        textObj.value = s.substring(0, j);
    }
}

function checkLength(str)
{
    var i, j;

    for(i = 0, j = 0; i < str.length; i++){
        j += str.charCodeAt(i) > 255 ? 2 : 1;
    }

    return(j);
}

function toUpper()
{
    if(window.event){
       if(window.event.keyCode == 34 || window.event.keyCode == 39 || window.event.keyCode == 44 || window.event.keyCode == 92 || window.event.keyCode == 38 || window.event.keyCode == 63){
           return false;
       }
       if(window.event.keyCode >= 97 && window.event.keyCode <= 122){
            window.event.keyCode -= 32;
       }
    }

    return true;
}

function toLower()
{
    if(window.event){
       if(window.event.keyCode == 34 || window.event.keyCode == 39 || window.event.keyCode == 44 || window.event.keyCode == 92 || window.event.keyCode == 38 || window.event.keyCode == 63){
           return false;
       }
       if(window.event.keyCode >= 65 && window.event.keyCode <= 90){
            window.event.keyCode += 32;
       }
    }

    return true;
}

function checkCR()
{
    if(window.event && window.event.keyCode == 13){
        return(doSubmit('search'));
    }
}

function checkESC()
{
    if(window.event && window.event.keyCode == 27){
        return(false);
    }
}

function replaceString(source, from, to)
{
    if(source == null || source.length <= 0){
        return("");
    }

    while(source.indexOf(from) != -1){
        var target = "";
        var pos = source.indexOf(from);
        var pos1 = pos + from.length >= source.length ? -1 : pos + from.length;
        if(pos != -1){
            target = source.substring(0, pos);
        }
        target += to;
        if(pos1 != -1){
            target += source.substring(pos1);
        }
        source = target;
    }

    return(source);
}

function normalContext(source)
{
    if(source == undefined || source == null || source.length <= 0){
        return("");
    }

    source = source.replace(/ùØ/g, "&#35023;");
    source = source.replace(/\"/g, "&#34;");
    source = source.replace(/\'/g, "&#39;");
    source = source.replace(/\\/g, "&#92;");
    source = source.replace(/\r/g, "");

    return(source);
}

function stripContext(source, stripArray, to)
{
    if(source == undefined || source == null || source.length <= 0){
        return("");
    }

    if(stripArray == undefined || stripArray == null || stripArray.length <= 0){
        stripArray = [ " ", "\\.", "\\,", "\\;", "\\'", '\\"' ];
    }

    if(to == undefined){
        to = '';
    }

    for(var i in stripArray){
        var temp = "source = source.replace(/" + stripArray[i] + "/g, '" + to + "')";
        eval(temp);
    }

    return(source);
}

function checkMail(str)
{
    var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;

    return(filter.test(str));
}

function showMessageDialog(msgType , transfer , message)
{
    window.showModalDialog("tw.com.synergy.epms.gui.ShowMessage?msgType="+msgType+"&transfer="+transfer+"&message=" + message, "ShowMessage", "dialogHeight:250px;dialogWidth:500px;scroll:no;status:no;")
}

function show_calendar(sourceObj)
{
    window.showModalDialog("../SCRIPT/date-picker.htm", sourceObj, "dialogHeight:280px;dialogWidth:400px;scroll:no;status:no;");
}

function show_calendar1(sourceObj)
{
    window.showModalDialog("../SCRIPT/date-picker1.htm", sourceObj, "dialogHeight:280px;dialogWidth:400px;scroll:no;status:no;");
}

function show_calendar2(sourceObj)
{
    window.showModalDialog("../SCRIPT/date-picker2.htm", sourceObj, "dialogHeight:310px;dialogWidth:400px;scroll:no;status:no;");
}

function show_calendar3(sourceObj)
{
    window.showModalDialog("../SCRIPT/date-picker3.htm", sourceObj, "dialogHeight:310px;dialogWidth:400px;scroll:no;status:no;");
}

function rpad(s, l, c)
{
    if(!isNaN(s)){
        s = new String(s);
    }

    var len = s.length;
    var t = "";

    if(len < l){
        for(var i = len; i < l; i++){
            t += c;
        }
    }

    return(s + t);
}

function lpad(s, l, c)
{
    if(!isNaN(s)){
        s = new String(s);
    }

    var len = s.length;
    var t = "";

    if(len < l){
        for(var i = len; i < l; i++){
            t += c;
        }
    }

    return(t + s);
}

function rTrim(s)
{
    var i;

    for(i = s.length - 1; i >= 0; i--){
        if(s.charAt(i) != ' '){
            break;
        }
    }

    return(s.substring(0, i + 1));
}

function lTrim(s)
{
    var i;

    for(i = 0; i < s.length; i++){
        if(s.charAt(i) != ' '){
            break;
        }
    }

    return(s.substring(i, s.length));
}

function Trim(s)
{
    return(lTrim(rTrim(s)));
}

function splitToken(s, t, trimFlag)
{
    var i = 0;
    var j = 0;
    var k = 0;

    var a = new Array();

    var ss = "";

    while((j = s.indexOf(t)) != -1){
        a[k] = s.substring(0, j);
        i = j + t.length;
        s = s.substring(i, s.length);
        k++;
    }

    a[k] = s;

    if(trimFlag != undefined && trimFlag == true){
        for(var i in a){
            a[i] = Trim(a[i]);
        }
    }

    return(a);
}

function joinToken(ary, delim)
{
    var result = "";
    var count = 0;

    for(var i in ary){
        if(count == 0){
            result = ary[i];
        }
        else{
            result += delim + ary[i];
        }
        count++;
    }

    return(result);
}

function helpWindow()
{
    window.open('Help.jsp','HELP','width=650,height=600,left=0,top=0,scrollbars=yes');
}

var subWindows = new Array();

function closeSubWindows()
{
    for(var win in subWindows){
        if(subWindows[win] != null){
            subWindows[win].close();
            subWindows[win] = null;
            delete subWindows[win];
        }
    }
}

function inOptions(obj, value)
{
    if(obj && obj.options){
        for(var i = 0; i < obj.options.length; i++){
            if(obj.options[i].text == value){
                return(true);
            }
        }
    }

    return(false);
}

function clearOption(obj)
{
    obj.selectedIndex = -1;
}

function setOptionByValue(obj, dataArray)
{
    if(obj && obj.options){
        for(var i = 0; i < obj.options.length; i++){
            if(aryContain(dataArray, obj.options[i].value)){
                obj.options[i].selected = true;
            }
        }
    }
}

function setOptionByText(obj, dataArray)
{
    if(obj && obj.options){
        for(var i = 0; i < obj.options.length; i++){
            if(aryContain(dataArray, obj.options[i].text)){
                obj.options[i].selected = true;
            }
        }
    }
}

function getSelectedOptionValues(obj, count)
{
    var temp = new Array();
    var j = 0;

    if(obj && obj.options){
        for(var i = 0; i < obj.options.length; i++){
            if(count != undefined && j >= count){
                break;
            }
            if(obj.options[i].selected){
                temp.push(obj.options[i].value);
                j++;
            }
        }
    }

    return(temp);
}

function appendOption(select, optionValue, optionText)
{
    for(var i = 0; i < select.length; i++){
        if(select.options[i].value == optionValue && select.options[i].text == optionText){
            return;
        }
    }

    var no   = new Option();
    no.value = optionValue;
    no.text  = optionText;

    select.options[select.options.length] = no;
    // select.selectedIndex = select.options.length - 1;
}

function appendOptions(select, valueArray, textArray)
{
    for(var i in valueArray){
        appendOption(select, valueArray[i], textArray[i]);
    }
}

function removeOption(select, optionValue, optionText)
{
    if(optionValue == undefined && optionText == undefined){
        return;
    }

    if(optionValue == undefined){
        for(var i = 0; i < select.length; i++){
            if(select.options[i].text == optionText){
                select.options[i] = null;
            }
        }
    }
    else if(optionText == undefined){
        for(var i = 0; i < select.length; i++){
            if(select.options[i].value == optionValue){
                select.options[i] = null;
            }
        }
    }
    else{
        for(var i = 0; i < select.length; i++){
            if(select.options[i].value == optionValue && select.options[i].text == optionText){
                select.options[i] = null;
            }
        }
    }
}

function removeOptions(select, valueArray, textArray)
{
    if(valueArray == undefined){
        for(var i in valueArray){
            removeOption(select, undefined, textArray[i]);
        }
    }
    else if(textArray == undefined){
        for(var i in valueArray){
            removeOption(select, valueArray[i], undefined);
        }
    }
    else{
        for(var i in valueArray){
            removeOption(select, valueArray[i], textArray[i]);
        }
    }
}

function removeAllOptions(select)
{
    select.options.length = 0;
}

function clearSelect(obj)
{
    if(obj && obj.length){
        for(var i = 0; i < obj.length; i++){
            obj[i].checked = false;
        }
    }
    else if(obj){
        obj.checked = false;
    }
}

function setSelect(obj, val)
{
    if(val == undefined){
        if(obj && obj.length){
            for(var i = 0; i < obj.length; i++){
                obj[i].checked = true;
            }
        }
        else if(obj){
            obj.checked = true;
        }
    }
    else{
        if(obj && obj.length){
            for(var i = 0; i < obj.length; i++){
                if(obj[i].value == val){
                    obj[i].checked = true;
                }
            }
        }
        else if(obj){
            if(obj.value == val){
                obj.checked = true;
            }
        }
    }
}

function toggleSelect(obj)
{
    if(checkSelect(obj) > 0){
        clearSelect(obj);
    }
    else{
        setSelect(obj);
    }
}

function checkSelect(obj)
{
    var total = 0;

    if(obj && obj.length){
        for(var i = 0; i < obj.length; i++){
            total += obj[i].checked ? 1 : 0;
        }
    }
    else if(obj){
        total += obj.checked ? 1 : 0;
    }

    return(total);
}

function getSelect(obj, count, skipArray)
{
    var data = "";
    var checkcnt = 0;

    if(obj && obj.length){
        for(var i = 0, j = 0; i < obj.length; i++){
            if(obj[i].checked){
                if(aryContain(skipArray, obj[i].value) == true){
                    continue;
                }
                checkcnt++;
            }
        }
        if(count == undefined || count <= 0){
            count = checkcnt;
        }
        for(var i = 0, j = 0; i < obj.length; i++){
            if(obj[i].checked){
                if(aryContain(skipArray, obj[i].value) == true){
                    continue;
                }
                data += obj[i].value;
                if(j >= count - 1){
                    break;
                }
                if(j < obj.length - 1 && j < count - 1 && j < checkcnt - 1){
                    data += ",";
                }
                j++;
            }
        }
    }
    else if(obj){
        if(obj.checked && aryContain(skipArray, obj.value) == false){
            data = obj.checked ? obj.value : "";
        }
    }

    return(data);
}

function getSelectIndex(obj, count, skipArray)
{
    var data = "";
    var checkcnt = 0;

    if(obj && obj.length){
        for(var i = 0, j = 0; i < obj.length; i++){
            if(obj[i].checked){
                if(aryContain(skipArray, obj[i].value) == true){
                    continue;
                }
                checkcnt++;
            }
        }
        if(count == undefined || count <= 0){
            count = checkcnt;
        }
        for(var i = 0, j = 0; i < obj.length; i++){
            if(obj[i].checked){
                if(aryContain(skipArray, obj[i].value) == true){
                    continue;
                }
                data += i;
                if(j >= count - 1){
                    break;
                }
                if(j < obj.length - 1 && j < count - 1 && j < checkcnt - 1){
                    data += ",";
                }
                j++;
            }
        }
    }
    else if(obj){
        if(obj.checked && aryContain(skipArray, obj.value) == false){
            data = obj.checked ? "0" : "";
        }
    }

    return(data);
}

function aryContain(ary, val)
{
    if(ary == null || ary == undefined){
        return(false);
    }

    for(var i in ary){
        if(ary[i] === val){
            return(true);
        }
    }

    return(false);
}

function aryIndexOf(ary, value)
{
    if(ary == undefined || ary.length <= 0){
        return(-1);
    }

    for(var i in ary){
        if(ary[i] === value){
            return(i);
        }
    }

    return(-1);
}

function aryAdd(ary, value)
{
    if(ary == undefined){
        return(ary);
    }
    if(value == undefined){
        return(ary);
    }

    if(typeof(value) == "object"){
        for(var i in value){
            ary.push(value[i]);
        }
    }
    else{
        ary.push(value);
    }

    return(ary);
}

function aryRemove(ary, value)
{
    if(ary == undefined || ary.length <= 0){
        return(0);
    }

    if(typeof(value) != "object"){
        if(aryIndexOf(ary, value) == -1){
            return(0);
        }
    }

    var len = ary.length;
    var cnt = 0;

    if(typeof(value) == "object"){
        for(var i = 0; i < len; i++){
            var temp = ary.shift();
            if(aryIndexOf(value, temp) != -1){
                cnt++;
                continue;
            }
            ary.push(temp);
        }
    }
    else{
        for(var i = 0; i < len; i++){
            var temp = ary.shift();
            if(temp === value){
                cnt++;
                continue;
            }
            ary.push(temp);
        }
    }

    return(cnt);
}

function aryUnique(ary, sortFlag)
{
    if(ary == undefined || ary.length <= 0){
        return(ary);
    }

    var ary1 = new Array();
    var len = ary.length;

    for(var i = 0; i < len; i++){
        var temp = ary.shift();
        if(aryIndexOf(ary1, temp) == -1){
            ary1.push(temp);
        }
    }

    var len = ary1.length;

    for(var i = 0; i < len; i++){
        ary.push(ary1.shift());
    }

    if(sortFlag != undefined && sortFlag == true){
        ary.sort();
    }

    return(ary);
}

function dec2hex(dec)
{
    var xTable = "0123456789ABCDEF";
    var temp = "";

    dec = parseInt(dec);

    if(dec == 0){
        return("00");
    }

    for(; dec > 0; dec = dec >> 8){
        var dec1 = dec % 256;
        hi = dec1 >> 4;
        lo = dec1 % 16;
        temp = xTable.charAt(hi) + xTable.charAt(lo) + temp;
    }

    return(temp);
}

function hex2dec(hex)
{
    var temp = 0;
    var xTable = "0123456789ABCDEF";

    hex = hex.toUpperCase();

    for(var i = hex.length - 1, j = 1; i >= 0; i--, j = j << 4){
        temp += j * xTable.indexOf(hex.charAt(i));
    }

    return(temp);
}

function unicodeEncode(source)
{
    if(source == undefined || source == null || source.length <= 0){
        return("");
    }

    var mi, hi, lo;
    var target = "";

    for(var i = 0; i < source.length; i++){
        mi = source.charCodeAt(i);
        hi = mi >> 8;
        lo = mi & 0xff;
        target += dec2hex(hi);
        target += dec2hex(lo);
    }

    return(target);
}

function unicodeDecode(source)
{
    if(source == undefined || source == null || source.length <= 0){
        return("");
    }

    var temp = "";

    for(var i = 0; i < source.length - 3; i += 4){
        temp += String.fromCharCode("0x" + source.substring(i, i + 4));
    }

    return(temp);
}

function clickIE()
{
    if(document.all){
        (message);
        return false;
    }
}

function clickNS(e)
{
    if(document.layers ||(document.getElementById && !document.all)){
        if(e.which == 2 || e.which == 3){
            (message);
            return false;
        }
    }
}

if(document.layers){
    //document.captureEvents(Event.MOUSEDOWN);
    //document.onmousedown = clickNS;
}
else{
    //document.onmouseup = clickNS;
    //document.oncontextmenu = clickIE;
}

//document.oncontextmenu = new Function("return false")

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function overTD(obj)
{
    var tbl = obj.parentNode.parentNode.parentNode;
    var rowIndex = obj.parentNode.rowIndex;
    var cellIndex = obj.cellIndex;

    tbl.rows[rowIndex].cells[cellIndex].backgroundColor = tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor;
    tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor = "#ff4d00";

    for(var i = 0; i < rowIndex; i++){
        tbl.rows[i].cells[cellIndex].backgroundColor = tbl.rows[i].cells[cellIndex].style.backgroundColor;
        tbl.rows[i].cells[cellIndex].style.backgroundColor = "#ffddcc";
    }
    for(var i = 0; i < cellIndex; i++){
        tbl.rows[rowIndex].cells[i].backgroundColor = tbl.rows[rowIndex].cells[i].style.backgroundColor;
        tbl.rows[rowIndex].cells[i].style.backgroundColor = "#ffddcc";
    }
}

function outTD(obj)
{
    var tbl = obj.parentNode.parentNode.parentNode;
    var rowIndex = obj.parentNode.rowIndex;
    var cellIndex = obj.cellIndex;

    tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor = tbl.rows[rowIndex].cells[cellIndex].backgroundColor;

    for(var i = 0; i < rowIndex; i++){
        tbl.rows[i].cells[cellIndex].style.backgroundColor = tbl.rows[i].cells[cellIndex].backgroundColor;
    }
    for(var i = 0; i < cellIndex; i++){
        tbl.rows[rowIndex].cells[i].style.backgroundColor = tbl.rows[rowIndex].cells[i].backgroundColor;
    }
}

function overTD1(obj)
{
    var tbl = obj.parentNode.parentNode.parentNode;
    var rowIndex = obj.parentNode.rowIndex;
    var cellIndex = obj.cellIndex;

    tbl.rows[rowIndex].cells[cellIndex].backgroundColor = tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor;
    tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor = "#ff4d00";
    tbl.rows[rowIndex].cells[cellIndex].color = tbl.rows[rowIndex].cells[cellIndex].style.color;
    tbl.rows[rowIndex].cells[cellIndex].style.color = "#ffffff";
}

function outTD1(obj)
{
    var tbl = obj.parentNode.parentNode.parentNode;
    var rowIndex = obj.parentNode.rowIndex;
    var cellIndex = obj.cellIndex;

    tbl.rows[rowIndex].cells[cellIndex].style.backgroundColor = tbl.rows[rowIndex].cells[cellIndex].backgroundColor;
    tbl.rows[rowIndex].cells[cellIndex].style.color = tbl.rows[rowIndex].cells[cellIndex].color;
    tbl.rows[rowIndex].cells[cellIndex].className="";
}

function overTR(obj)
{
    obj.style.oldBackgroundColor = obj.style.backgroundColor;
    obj.style.backgroundColor = "#ff4d00";
    obj.style.oldColor = obj.style.color;
    obj.style.color = "white";
}

function outTR(obj)
{
    obj.style.backgroundColor = obj.style.oldBackgroundColor;
    obj.style.color = obj.style.oldColor;
}

function overButton(obj)
{
    obj.style.oldBackgroundColor = obj.style.backgroundColor;
    obj.style.backgroundColor = "#ff4d00";
    obj.style.oldColor = obj.style.color;
    obj.style.color = "white";
}

function outButton(obj)
{
    obj.style.backgroundColor = obj.style.oldBackgroundColor;
    obj.style.color = obj.style.oldColor;
}

function overLink(obj)
{
    obj.bgLink = obj.style.backgroundColor;
    obj.fgLink = obj.style.color;
    obj.fwLink = obj.style.fontWeight;

    obj.style.fontWeight = 'bold';
    obj.style.backgroundColor = '#ff4e00';
    obj.style.color = 'yellow';
}

function outLink(obj)
{
    obj.style.fontWeight = obj.fwLink;
    obj.style.backgroundColor = obj.bgLink;
    obj.style.color = obj.fgLink;
}

function printCharacterTable()
{
    document.writeln("<table width=100% border=0 cellpadding=0 cellspacing=1 style='font-family:Times New Roman,Arial,Tahoma;font-size:14px;background-color:#cccccc;'><tbody bgcolor=white>");
    for(var i = 0; i < 100; i++){
        document.writeln("<tr height=20>");
        for(var j = 0; j < 32; j++){
            document.writeln("  <td style='cursor:crosshair;' onmouseover=this.style.backgroundColor='#ff4d00'; onmouseout=this.style.backgroundColor=''; width=30 align=center title='&#38;#" + (i * 32 + j) + ";'>&#" + (i * 32 + j) + ";</td>");
        }
        document.writeln("</tr>");
    }
    document.writeln("</tbody></table>");
}

var voiceWin = null;

function doVoice(obj)
{
    if(voiceWin != null){
        voiceWin.close();
        voiceWin = null;
    }

    voiceWin = window.open("", "VOICE", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=400,height=400,left=100,top=100");
    voiceWin.document.write("<html><head><title>Voice from www.ehomework.com.tw</title></head><body oncontextmenu='return(false);'>");
    voiceWin.document.write("<embed src='" + obj + "' autostart=true loop=false ShowAudioControls=true ShowTracker=true EnableContextMenu=false ShowStatusBar=true ShowDisplay=true hidden=false width=100% height=100%>");
    voiceWin.document.write("</body></html>");
}

function closeVoice()
{
    if(voiceWin != null){
        voiceWin.close();
    }
}

function doBlink(tagName)
{
    if(tagName == undefined || tagName == ""){
        tagName = "BLINK";
    }

    var blink = document.all.tags(tagName)

    for(var i = 0; i < blink.length; i++){
        blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
    }
}

function startBlink(tagName, delay)
{
    if(delay == undefined || isNAN(delay)){
        delay = parseInt(500);
    }

    if(tagName == undefined || tagName == ""){
        tagName = "BLINK";
    }

    if(document.all){
        setInterval("doBlink('" + tagName + "');", delay)
    }
}

-->