var intSize = 100;
var intMin = 80;
var intStd = 100;
var intMax = 120;
var intPer = 20;
var saveSpanColor;
var saveTdBgColor;
var saveBodyBgColor;
window.onload = function() {
    try {
        intSize = parseInt(getCookieInfo("strctrlsize"));
    } catch (e){
        intSize = intStd;
    }
    if ( intSize == "" || !( intMin <= intSize && intSize <= intMax ) ) {
        intSize = intStd;
    }
    if ( intSize != intStd ) {
        changeSize();
    }
    if ( !saveSpanColor && !saveTdBgColor && !saveBodyBgColor ){
        saveColor();
    }
    try{
        resetcolorflg = getCookieInfo("resetcolorflg");
        textcolor = getCookieInfo("textcolor");
        bgcolor = getCookieInfo("bgcolor");
    }catch(e){
        resetcolorflg = "1";
        textcolor = "";
        bgcolor = "";
    }    
    if ( resetcolorflg.length == 0 || resetcolorflg == "1" ){
        resetColor();
    }else{
        changeAllColor(textcolor,bgcolor);
    }
}
function strctrl( ctrlType ) {
    switch ( ctrlType ) {
    case 1:
        intSize = eval(intSize) - intPer;
        if ( intSize < intMin ) {
            intSize = intMin;
        }
        break;
    case 2:
        intSize = intStd;
        break;
    case 3:
        intSize = eval(intSize) + intPer;
        if ( intSize > intMax ) {
            intSize = intMax;
        }
        break;
    }
    saveCookieInfo("strctrlsize", intSize);
    changeSize();
}
function changeSize() {
    if ( document.getElementById ) {
        var nodeList = document.body.getElementsByTagName("span");
        var i;
        for ( i=0; i < nodeList.length; i++){
            if ( nodeList[i].hasChildNodes() ) {
                if ( nodeList[i].firstChild.nodeType == 3) {
                    nodeList[i].style.fontSize = intSize + "%";
                }
            }
        }
    }
}
function changeColor( resetcolorflg, textcolor, bgcolor){

    saveCookieInfo("resetcolorflg",resetcolorflg);
    saveCookieInfo("textcolor",textcolor);
    saveCookieInfo("bgcolor",bgcolor);
    
    if ( !saveSpanColor && !saveTdBgColor && !saveBodyBgColor ){
        saveColor();
    }
    if (resetcolorflg == "1" ){
        resetColor();
    }else{
        changeAllColor(textcolor, bgcolor);
    }
}
function changeAllColor( textcolor, bgcolor){
    if ( document.getElementById ){
        var spanNodeList = document.body.getElementsByTagName("span");
        var i;
        for ( i=0; i < spanNodeList.length; i++){
            spanNodeList[i].style.color = textcolor;
        }
        document.body.style.backgroundColor = bgcolor;
        var tableNodeList = document.body.getElementsByTagName("table");
        for ( i=0; i < tableNodeList.length; i++){
            if (tableNodeList[i].style.backgroundColor != "" ){
                tableNodeList[i].style.backgroundColor = bgcolor;
            }
        }
        var tdNodeList = document.body.getElementsByTagName("td");
        for ( i=0; i < tdNodeList.length; i++){
            if (tdNodeList[i].style.backgroundColor != "" ){
                tdNodeList[i].style.backgroundColor = bgcolor;
            }
        }
        var thNodeList = document.body.getElementsByTagName("th");
        for ( i=0; i < thNodeList.length; i++){
            if (thNodeList[i].style.backgroundColor != ""){
                thNodeList[i].style.backgroundColor = bgcolor;
            }
        }
    }
}
function resetColor() {
    var i = 0;
    var tableCnt = 0;
    var tdCnt = 0;
    if ( document.getElementById ) {
        var i;
        var spanNodeList = document.body.getElementsByTagName("span");
        for ( i=0; i < spanNodeList.length; i++){
            spanNodeList[i].style.color = saveSpanColor[i];
        }
        document.body.style.backgroundColor = saveBodyBgColor;
        var tableNodeList = document.body.getElementsByTagName("table");
        for ( i=0; i < tableNodeList.length; i++){
            tableNodeList[i].style.backgroundColor = saveTdBgColor[i];
            tableCnt++;
        }
        var tdNodeList = document.body.getElementsByTagName("td");
        for ( i=0; i < tdNodeList.length; i++){
            tdNodeList[i].style.backgroundColor = saveTdBgColor[i+tableCnt];
            tdCnt++;
        }
        var thNodeList = document.body.getElementsByTagName("th");
        for ( i=0; i < thNodeList.length; i++){
            thNodeList[i].style.backgroundColor = saveTdBgColor[i+tableCnt+tdCnt];
        }
    }
}
function saveColor() {
    var i = 0;
    var tableCnt = 0;
    var tdCnt = 0;
    if ( document.getElementById ) {
        var spanNodeList = document.body.getElementsByTagName("span");
        saveSpanColor = new Array(spanNodeList.length);
        for ( i=0; i < spanNodeList.length; i++){
            saveSpanColor[i] = spanNodeList[i].style.color;
        }
        saveBodyBgColor = document.body.style.backgroundColor;
        var tableNodeList = document.body.getElementsByTagName("table");
        var tdNodeList = document.body.getElementsByTagName("td");
        var thNodeList = document.body.getElementsByTagName("th");
        saveTdBgColor = new Array((tableNodeList.length)+(tdNodeList.length)+(thNodeList.length));
        for ( i=0; i < tableNodeList.length; i++){
            saveTdBgColor[i] = tableNodeList[i].style.backgroundColor;
            tableCnt++;
        }
        for ( i=0; i < tdNodeList.length; i++){
            saveTdBgColor[i+tableCnt] = tdNodeList[i].style.backgroundColor;
            tdCnt++;
        }
        for ( i=0; i < thNodeList.length; i++){
            saveTdBgColor[i+tableCnt+tdCnt] = thNodeList[i].style.backgroundColor;
        }
    }
}
function getCookieInfo( cookietype ){
    var ret = "";
    if ( document.cookie.indexOf( cookietype ) != -1) {
        try {
            var cookieList = document.cookie.split(";");
            for ( var i=0; i < cookieList.length; i++ ){
                var cookieInfo = cookieList[i].replace(" ", "");

                if ( cookieInfo != "" ){
                    var cookieData = cookieInfo.split("=");
                    if ( cookieData.length == 2 ){
                        var type = cookieData[0];
                        var data = cookieData[1];
                        if ( type == cookietype ){
                            ret = data;
                            break;
                        }
                    }
                }
            }
        } catch (ex) {
            return "";
        }
    }
    return ret;
}
function saveCookieInfo( cookietype, savedata ){
    var ret = false;
    var cookiedata= cookietype + "=";
    if ( savedata != "" ) {
        cookiedata = cookiedata + savedata;
        cookiedata = cookiedata + ";expires=Fri, 31-Dec-2030 0:0:0; path=/;";
        try {
            document.cookie = cookiedata;
            ret = true;
        } catch (ex) {
            return false;
        }
    }
    return ret;
}
function openPrintPage(temptype,laytype,itemtype,width,height ){
    var uri = document.URL;
    var uriParam;
    var winParam;
    if ( uri.indexOf("?") > -1 ) {
        uriParam = "&print=1";
    } else {
        uriParam = "?print=1";
    }
    uriParam = uriParam + "&temptype=" + temptype + "&laytype=" + laytype + "&itemtype=" + itemtype;
    winParam = "menubar=yes,toolbar=no,resizable=yes,scrollbars=yes";
    if ( width != 0 && width != undefined ) {
        winParam = winParam + ",width=" + width;
    }
    if ( height != 0 && height != undefined ) {
        winParam = winParam + ",height=" + height;
    }
    window.open(uri+uriParam,'',winParam);
}
function tabDisp( clickNode, tabIndex, lineColor, bgColor1, bgColor2 ){
  try{
    var tableNode = null;
    var trNode = null;
    var divNode = null;
    var checkNode = clickNode;
    while( checkNode != null ){
        if( checkNode.nodeName.toLowerCase() == "table" ){
            tableNode = checkNode;
            break;
        }
        checkNode = checkNode.parentNode;
    }
    var tdNodes = tableNode.getElementsByTagName("td");
    for( var i = 0; i < tdNodes.length; i++ ){
        if( i == (tabIndex-1) ){
            if( bgColor1.length > 0 ){
                tdNodes[i].style.backgroundColor = bgColor1;
            }
            if( lineColor.length > 0 ){
                tdNodes[i].style.borderBottom = "";
            }
            var className = tdNodes[i].className;
            if( className.length > 0 ){
                tdNodes[i].className = className.replace("_off","_on");
            }
        } else {
            if( bgColor2.length > 0 ){
                tdNodes[i].style.backgroundColor = bgColor2;
            }
            if( lineColor.length > 0 ){
                tdNodes[i].style.borderBottom = "1px solid " + lineColor;
            }
            var className = tdNodes[i].className;
            if( className.length > 0 ){
                tdNodes[i].className = className.replace("_on","_off");
            }
        }
    }
    checkNode = tableNode.parentNode;
    while( checkNode != null ){
        if( checkNode.nodeName.toLowerCase() == "tr" ){
            trNode = checkNode;
            break;
        }
        checkNode = checkNode.parentNode;
    }
    checkNode = trNode.nextSibling;
    while( checkNode != null ){
        if( checkNode.nodeType == 1 ){
            if( checkNode.nodeName.toLowerCase() == "tr" ){
                trNode = checkNode;
                break;
            }
        }
        checkNode = checkNode.nextSibling;
    }
    checkNode = trNode.firstChild;
    while( checkNode != null ){
        if( checkNode.nodeType == 1 ){
            if( checkNode.nodeName.toLowerCase() == "div" ){
                divNode = checkNode;
                break;
            }
            checkNode = checkNode.firstChild;
        } else {
            checkNode = checkNode.nextSibling;
        }
    }
    var cnt = 0;
    checkNode = divNode;
    while( checkNode != null ){
        if( checkNode.nodeType == 1 ){
            if( checkNode.nodeName.toLowerCase() == "div" ){
                cnt++;
                if( cnt == tabIndex ){
                    checkNode.style.display = "";
                } else {
                    checkNode.style.display = "none";
                }
             }
        }
        checkNode = checkNode.nextSibling;
    }
  }catch(e){}
}
