@set @DEBUG = 0 // Debug Flag (=1:ON/=0:OFF)
var F = document.all;
var saveStyle;
var saveFgColor;
var saveBgColor;
var saveBC;
var saveFC;
var DCP  = '{89820200-ECBD-11CF-8B85-00AA005B4383}';
var CID  = 'componentid';
var tVer = 5;
/*
Address Book {7790769C-0471-11D2-AF11-00C04FA35D02}
Windows Desktop Update NT {89820200-ECBD-11CF-8B85-00AA005B4340}
DirectAnimation {283807B5-2C60-11D0-A31D-00AA00B92C03}
DirectAnimation Java Classes {4F216970-C90C-11D1-B5C7-0000F8051515}
DirectShow {44BBA848-CC51-11CF-AAFA-00AA00B6015C}
Dynamic HTML Data Binding {9381D8F2-0288-11D0-9501-00AA00B911A5}
Dynamic HTML Data Binding for Java {4F216970-C90C-11D1-B5C7-0000F8051515}
Internet Connection Wizard {5A8D6EE0-3E18-11D0-821E-444553540000}
Internet Explorer 5 Browser {89820200-ECBD-11CF-8B85-00AA005B4383}
Internet Explorer Classes for Java {08B0E5C0-4FCB-11CF-AAA5-00401C608555}
Internet Explorer Help {45EA75A0-A269-11D1-B5BF-0000F8051515}
Internet Explorer Help Engine {DE5AED00-A4BF-11D1-9948-00C04F98BBC9}
Windows Media Player {22D6F312-B0F6-11D0-94AB-0080C74C7E95}
NetMeeting NT {44BBA842-CC51-11CF-AAFA-00AA00B6015B}
Offline Browsing Pack {3AF36230-A269-11D1-B5BF-0000F8051515}
Outlook Express {44BBA840-CC51-11CF-AAFA-00AA00B6015C}
Task Scheduler {CC2A9BA0-3BDD-11D0-821E-444553540000}
Microsoft virtual machine {08B0E5C0-4FCB-11CF-AAA5-00401C608500}
*/

function GetScriptEngineInfo(){
    var s = '';
    s += ScriptEngine() + ': ';
    s += ScriptEngineMajorVersion() + '.';
    s += ScriptEngineMinorVersion() + '.';
    s += ScriptEngineBuildVersion();
    return(s);
}
function initStatus(){
    @if (@DEBUG == 1) alert("initStatus >> IN"); @end
    var x, strMsg;
    var sIEver = "";    // dummy 2006/07/29(Sat)-22:00:46
/*
    with(oBody){
        var bMSvmAvailable = isComponentInstalled( DCP, CID );
        var sMSvmVersion   = getComponentVersion( DCP, CID );
    }
    if (sMSvmVersion != ''){
        sMSvmVersion = 'IE' + ' Version ' + sMSvmVersion;
    }
    var sNeg = (bMSvmAvailable) ? '' : 'NOT ';
    if (!bMSvmAvailable) sMSvmVersion = 'IE6.x Browser';
    var sIEver = sMSvmVersion + ' is ' + sNeg + 'installed.';
    if (!bMSvmAvailable){
        window.alert(sIEver);
        with(oBody){
            addComponentRequest( DCP, CID );
            doComponentRequest();
        }
    } else {
        sIEver = 'IE: ' + oBody.getComponentVersion( DCP, CID );
    }
*/
    var sMver = GetScriptEngineInfo();
    if (sMver.substr(9, 1) < tVer){
        strMsg  = 'Your current Script Engine is "' + sMver + '".\n';
        strMsg += 'This HTML requires "JScript Version ' + tVer + '" or above.\n';
        strMsg += 'Please contact with this page author.';
        window.alert(strMsg);
    }
    if (! window.print){
        x = F[ 'PRN' ];
        if (x != null) x.disabled = true;
    }
    with(oBody.currentStyle){
        saveBgColor = backgroundColor;
        saveFgColor = color;
    }
    with(oBody){
        if ((width < 800) || (height < 600)){
            strMsg  = 'Your current screen resolution is ' + width + ' * ' + height + '.\n';
            strMsg += 'We recommend 800 * 600 and above resolution for the best view.';
            window.alert(strMsg);
        }
        if (colorDepth < 16){
            strMsg  = 'Your current screen color is ' + Math.pow(2, colorDepth) + ' colors.\n';
            strMsg += 'We recommend 65536 and above colors for the best view.';
            window.alert(strMsg);
        }
//        strMsg = 'Screen: ' + width + ' * ' + height + ', Color: ' + colorDepth + ', ' + sMver + ', ' + sIEver;
        strMsg = 'Screen: ' + width + ' * ' + height + ', Color: ' + colorDepth + ', ' + sMver;
        window.status = strMsg;
    }
//    fnUpdateProductInfo( "DUMMY", "MDATE2" );
    @if (@DEBUG == 1) alert("initStatus >> OUT"); @end
}
function toggle(){
    var x = F[ 'SCORE' ];
    var y = F[ 'VIEW' ];
    if ((x != null) && (y != null)){
        with(x.style){
            display = (display == 'none') ? '' : 'none';
            y.value = (display == 'none') ? 'View Score' : 'Hide Score';
        }
        window.scrollBy(0, 290);
    }
}
function beforePrint(){
    var x = F[ 'BTN' ];
    var y = F[ 'SCORE' ];
    if ((x != null) && (y != null)){
        x.style.display = 'none';
        with(y.style){
            saveStyle = display;
            if (display == 'none') display = '';
        }
    } else if (x != null){
        x.style.display = 'none';
    }
    with(oBody.currentStyle){
        saveBC = backgroundColor;
        saveFC = color;
    }
    with(oBody.style){
        backgroundColor = 'white';
        color = 'black';
    }
    var section, ans;
    ans = window.confirm('Click [OK] to print entire page. Click [CANCEL] to select print section.');
    if (!ans){
        var coll = F.tags( 'legend' );
        for (var i=0; i<coll.length; i++){
            x = F[ 'LEG' + i.toString() ];
            if (x != null){
                y = F[ 'FLD' + i.toString() ];
                section = x.innerText;
                ans = window.confirm('Click [OK] to print ' + section + '. Click [CANCEL] to skip.');
                if (!ans && (y != null)) y.style.display = 'none';
            }
        }
        ans = window.confirm('Click [OK] to print Footer Section. Click [CANCEL] to skip.');
        if (!ans){
            x = F[ 'FOOT' ];
            if (x != null) x.style.display = 'none';
        }
    }
    hideText();
}
function afterPrint(){
    var x = F[ 'BTN' ];
    var y = F[ 'SCORE' ];
    if ((x != null) && (y != null)){
        x.style.display = '';
        y.style.display = saveStyle;
    } else if (x != null){
        x.style.display = '';
    }
    with(oBody.style){
        backgroundColor = saveBC;
        color = saveFC;
    }
    var coll = F.tags( 'legend' );
    for (var i=0; i<coll.length; i++){
        x = F[ 'LEG' + i.toString() ];
        if (x != null){
            y = F[ 'FLD' + i.toString() ];
            if ((y != null) && (y.style.display == 'none')) y.style.display = '';
        }
    }
    x = F[ 'FOOT' ];
    if ((x != null) && (x.style.display == 'none')) x.style.display = '';
    hideColor(saveBC);
}
function swap(){
    with(oBody.currentStyle){
        var temp1 = backgroundColor;
        var temp2 = color;
    }
    with(oBody.runtimeStyle){
        backgroundColor = temp2;
        color = temp1;
    }
    hideColor(temp2);
}
function rubySwitch(flag){
    @if (@DEBUG == 1) alert("rubySwitch >> IN"); @end
    var i, coll, len;
    coll = F.tags( 'RT' );
    len = coll.length;
    if (len > 0){
        for (i=0; i<len; i++){
            with(coll.item(i).runtimeStyle){
                display = (display == 'none') ? '' : 'none';
            }
        }
        if (flag){
            var e = event.srcElement;
            with(e){
                if (value == 'Ruby On'){
                    value = 'Ruby Off';
                    title = 'Hide Kanji Ruby';
                } else {
                    value = 'Ruby On';
                    title = 'Show Kanji Ruby';
                }
            }
        }
    } else {
        var x = F[ 'RBTN' ];
        if (x) x.style.display = 'none';
    }
    @if (@DEBUG == 1) alert("rubySwitch >> OUT"); @end
}
function reset(){
    var e = event.srcElement;
    if (e.value == 'W/B'){
        var fgColor = 'black';
        var bgColor = 'white';
        e.value = 'Resume';
        e.title = 'Resume orginal color';
    } else {
        var fgColor = saveFgColor;
        var bgColor = saveBgColor;
        e.value = 'W/B';
        e.title = 'Reset screen color';
    }
    with(oBody.runtimeStyle){
        backgroundColor = bgColor;
        color = fgColor;
    }
    hideColor(bgColor);
}
function showCaps(){
    var sTempStr;
    with(oBody){
    sTempStr = 'width\t\t= ' + width + '\n' +
        'height\t\t= ' + height   + '\n' +
        'availWidth\t\t= ' + availWidth + '\n' +
        'availHeight\t= ' + availHeight    + '\n' +
        'bufferDepth\t= ' + bufferDepth + '\n' +
        'colorDepth\t\t= ' + colorDepth + '\n' +
        'connectionType\t= ' + connectionType + '\n' +
        'cookieEnabled\t= ' + cookieEnabled     + '\n' +
        'cpuClass\t\t= ' + cpuClass + '\n' +
        'platform\t\t= ' + platform + '\n' +
        'javaEnabled\t= ' + javaEnabled + '\n' +
        'systemLanguage\t= ' + systemLanguage + '\n' +
        'userLanguage\t= ' + userLanguage + '\n';
    }
    window.alert(sTempStr);
}
function showHitCounter(sID){
    if ((F.oBody.connectionType != "offline") && (F.oBody.connectionType != "lan")){
        var x = F[ sID ];
        if (x != null){
            with(x.style){
                display = (display == "none") ? "" : "none";
            }
        }
    }
}
function OnMouse(){
    var e = window.event.srcElement;
    with(e.style){
        color = 'lime';
        cursor = 'hand';
    }
}
function OutMouse(){
    var e = window.event.srcElement;
    with(e.style){
        color = '';
        cursor = '';
    }
}
function showTran2(sID){
    if (sID != "FLD99"){
        var x = F[ sID ];
        if (x != null){
            with(x.runtimeStyle){
                display = (display == 'none') ? '' : 'none';
            }
        }
    }
    showHitCounter('HCOUNT');
}
function showTran(){
    var x = F[ 'FLD1' ];
    if (x != null){
        with(x.runtimeStyle){
            display = (display == 'none') ? '' : 'none';
        }
    }
}
function hideColor(targetColor){
    var coll = F.tags( 'SPAN' );
    var clen = coll.length;
    if (clen > 0){
        for (var i=0; i < clen; i++){
            with(coll.item(i)){
                if (className == 'HIDE'){
                    runtimeStyle.color = targetColor;
                }
            }
        }
    }
}
function hideText(){
    var coll = F.tags( 'SPAN' );
    var clen = coll.length;
    var tlen, j;
    if (clen > 0){
        for (var i=0; i<clen; i++){
            with(coll.item(i)){
                if (className == 'HIDE'){
                    tlen = innerText.length;
                    innerText = '  ';
                    for (j=1; j<tlen; j++){
                        innerText += '  ';
                    }
                }
            }
        }
    }
}
function MyErrHandler(msg, url, line){
    var strMsg;
    strMsg  = 'UnAnticipated Error Occurred.';
    strMsg += '\n' + msg;
    strMsg += '\nat Line ' + line;
    strMsg += '\nin the ' + document.title + ' page.';
    window.alert(strMsg);
    return true;
}
function showCount(sID){
    var x = F[sID];
    if (x != null){
        with(x.style){
            display = (display == "none") ? "" : "none";
        }
    }
}
window.onerror = MyErrHandler;

