// #################################################################################
// #    File Name   : jpread.js
// #    Project     : JPREAD
// #    System      : On-Line Japanese Reading Material
// #    Purpose     : Generate Dynamic Table of Contents
// #    Function    : JPREAD Control
// #    Medel       : his programe is based on the Document Object Model (DOM)
// #    Language    : JavaScript (Client Side Scripting. ver: 5.x)
// #    Include     : jpreadtoc.js
// #    Date Issued : 2002/03/27(Wed)-16:34:21
// #    Base URL    : http://www.all.co.nz/
// #    Location    : js/
// #    Usage       :
// #    Browsers    : IE5.x and above
// #    Requirement : <BODY ID='oBody'>
// #    Restriction : None
// #    Author      : Hiroto Sekine (Able LL Systems Dpt. CHC, NZL)
// #    Copyright   : (C) 2002 Southern Cross Virtual Co., Ltd. All Rights Reserved.
// #    Contact     : info@all.co.nz
// #    Tab Stop    : 4 (Suitable TAB stop size to view this Source Code)
// # ===============================================================================
// #    ** Revision **
// # Date   Description                                             Sign      Mark
// # ------+-------------------------------------------------------+---------+------
// #
// #################################################################################
@set @DEBUG = 0 // Program Debug Flag: ON(=1)/OFF(=0)
// ###########################################################################
// #                            << NOTICE >>                                 #
// # THIS PROGRAM CODE BELONGS TO SOUTHERN CROSS VIRTUAL CO., LTD. IT IS     #
// # CONSIDERED A TRADE SECRET AND IS NOT TO BE DIVULUGED OR USED BY PARTIES #
// # WHO HAVE NOT RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.             #
// # ----------------------------------------------------------------------- #
// #                            << 通  知 >>                                 #
// # 本プログラムはSOUTHERN CROSS VIRTUAL CO., LTD.の財産です。本プログラム  #
// # はトレード・シークレットとみなされ、当該権利者の書面による許可なくして、#
// # 漏洩または使用を禁じます。                                              #
// ###########################################################################

var F = document.all;
var DOCURL = document.URL;
var saveStyle;
var saveFgColor;
var saveBgColor;
var saveBC;
var saveFC;

var DCP         = '{89820200-ECBD-11CF-8B85-00AA005B4383}';
var CID         = 'componentid';
var tVer        = 5;
var OLIST       = "oTOC";   // OL Tag

var BOOK_TITLE  = "Japanese Reading";
var HEADER_ID   = "STUDENT";
var REPEAT      =  7;       // Once a week study
var IMAGE_EXP   = "14";     // Image Expire Period: days
var IMAGE_EXPDM = "15";     // Image Expire Period(dummy): days
var COPERIOD    = 60;       // Cookie Expire Period: days
var NEXT_PAGE   =  1;       // Move to Next Page
var PREV_PAGE   = -1;       // Move to Previous Page
var KEEP_PAGE   =  0;       // Keep Current Page (reload)
var HOME_PAGE   =  9;       // Move to Home Page
var HOME_URL    = "index.htm";  // Relative URL Address

var UPDATE_PIC  = "image/updated.gif";
var NEW_PIC     = "image/new2.gif";
var CONST_PIC   = "image/i13.gif";
var UPDATE_STR  = " Updated";
var NEW_STR     = " Released";
var CONST_STR   = " Construction";
var MAX_EXPIRY  = "90";

var LESSON_PREFIX   = BOOK_TITLE;
var SHORT_PREFIX    = "JPL Reading";
var giWidth = 0;    // Window Width size for "showCaps"

function GetScriptEngineInfo(){
    var s = '';
    s += ScriptEngine() + ': ';
    s += ScriptEngineMajorVersion() + '.';
    s += ScriptEngineMinorVersion() + '.';
    s += ScriptEngineBuildVersion();
    return(s);
}
function ReDirect(sURL){
    location.href = sURL;
}
function modifyDocTitleYear(){
  var d = new Date();
  var TheYear = d.getFullYear();
  document.title = document.title + "(" + TheYear + ")";
}

// ********************************************************
// *  Show Project specialized number
// ********************************************************
function updateTopPageData(){
//var giTipNum          = 565 ;               // HTML tag ID: "TIPNUM" in <SPAN>
//var giRchMsgNum       = 115 ;               // HTML tag ID: "RCHMSG" in <SPAN>
//var gsTipNum_Date     = "2009/01/10(Sat)" ; // HTML tag ID: "TIPNUM_DATE" in <SPAN>
//var gsRchMsgNum_Date  = "2009/01/10(Sat)" ; // HTML tag ID: "RCHMSG_DATE" in <SPAN>
//var gcTipNum_ID       = "TIPNUM" ;
//var gcRchMsgNum_ID    = "RCHMSG" ;
//var gcTipDate_ID      = "TIPNUM_DATE" ;
//var gcRchDate_ID      = "RCHMSG_DATE" ;

  var x;
  x = F[ gcTipNum_ID ];     if (x != null && typeof(giTipNum) == "number")         x.innerText = giTipNum;
  x = F[ gcRchMsgNum_ID ];  if (x != null && typeof(giRchMsgNum) == "number")      x.innerText = giRchMsgNum;
  x = F[ gcTipDate_ID ];    if (x != null && typeof(gsTipNum_Date) == "string")    x.innerText = gsTipNum_Date;
  x = F[ gcRchDate_ID ];    if (x != null && typeof(gsRchMsgNum_Date) == "string") x.innerText = gsRchMsgNum_Date;
}
function initStatus(){
    @if (@DEBUG == 1) alert('initStatus() >> IN:'); @end
    var x, y, strMsg;
    var homeFlag = (DOCURL.lastIndexOf(HOME_URL) != -1) ? true : false;

    if (homeFlag){
        var ua = window.navigator;
        var curStudentName = getCurrentStudentName();   // last used student name
//      var uniqID = getStudentID(curStudentName);
        if (curStudentName){
//          goCookiStudentDateID  = coCOOKIE_DATE_PREFIX  + uniqID;
            LastTopicNo = getLastTopicNO(curStudentName);
            LastTopicNo = (LastTopicNo >= "0") ? LastTopicNo : "0";
        }
        if (curStudentName == ""){
            do {
                curStudentName = window.prompt("(A)Specify Student First Name(new student available):", "");
                if (curStudentName == "" || curStudentName == null) window.alert("You can't skip this field.");
            }while(curStudentName == "" || curStudentName == null);
            curStudentName = getStudentName(curStudentName, 1);
            if (!ua.cookieEnabled){
                window.alert("This page requires Cookie function.\nCurrently your browser Cookie is Off.");
            } else {
                if (((F.oBody.connectionType != "offline")) || (gSw == 8 || gSw == 1)){ // 8:Local Mode only
                    setCookieValue( coSTUDENT_NAME, curStudentName, twoWeeks );
                }
            }
        }
    }
    with(oBody){
        var bMSvmAvailable = isComponentInstalled( DCP, CID );
        var sMSvmVersion   = getComponentVersion( DCP, CID );

        if (connectionType != "offline"){
            x = F["CBTN"];
            if (x != null){
                with(x){
                    title   = "Back to Able Home";
                    value   = "Able Home";
                }
                y = F["COTX4"];
                if (y != null) y.innerText = x.value;  // added on 2005/01/22(Sat)-22:53:43
            }
            x = F["SCLS"];
            if (x != null){
//                x.innerText = "[Able Home]: Back to Able Home page.(Top page only)";
                x.innerHTML = "<input type='button' value='Able Home' style='color:red;' />: Back to Able Home page.(Top page only)";
            }
            x = F["WBTN"];  // download all source files
            if (x != null){
                x.style.display = "";
                y = F["WBTN2"];  // added by SKN23 on 2005/01/23(Sun)-14:17:58
                if (y != null) y.style.display = "";

            }
            x = F["HDWN"];
            if (x != null){
                x.style.display = "";
            }
        }
    }
    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;
    }

//  var coll = document.all;
//  if (coll != null){
//      for (var i=0; i<coll.length; i++){
//          if (coll.item(i).tagName == "A"){
//              saveABgColor = coll.item(i).style.backgroundColor;
//              saveAFgColor = coll.item(i).style.color;
//              break;
//          }
//      }
//  }

    with(oBody){
        giWidth = width;
        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;
        window.status = strMsg;
    }
    CreateSelOptions( "SelJump" );
    CreateSelOptions( "SelJump2" ); // for ConText Menu, added 2005/01/22(Sat)-23:20:22
    repLastModifiedDate();
    fnUpdateProductInfo("THEVER","MDATE2");
    initTitles( "DEF", "DEF" );
    fnSetExpressions(); // added by SKN23 on 2005/01/23(Sun)-13:51:15
    modifyDocTitleYear();
    if (homeFlag) updateTopPageData();
    @if (@DEBUG == 1) alert('initStatus() >> IN:'); @end
}
function fnAddMsgIfany( sid, iNum ){
    var x = F[ sid ];
    if (x != null && oTocList[iNum].Msg != ""){
        var oSpan = document.createElement( "SPAN" );
        oSpan.innerHTML = oTocList[iNum].Msg;
        x.appendChild(oSpan);
        x.style.display = "";
        x.style.color   = "green";
    }
}
function fnAddMsgIfany3( sid ){
  @if (@DEBUG == 8) alert('fnAddMsgIfany3() IN'); @end
  var iNum = getDocumentAssignedNum(3);
  var x = F[ sid ];
  if (x != null && iNum >= 0 && oTocList[iNum].Msg != ""){
      var oSpan = document.createElement( "SPAN" );
      oSpan.innerHTML = oTocList[iNum].Msg;
      x.appendChild(oSpan);
      x.style.display = "";
      x.style.color   = "green";
  }
  @if (@DEBUG == 8) alert('fnAddMsgIfany3() OUT'); @end
}
function getDocumentAssignedNum( bRetType ){
  // IN: bRetType ==> Required Return Type 1:String, 2: Number, 3: Number-1
  // Return Sample (04): 1:"04" , 2:4, 3:3 [use as array index number, i.e. 0,1,2,...]
  @if (@DEBUG == 8) alert('getDucumentAssignedNum: IN type= ' + bRetType); @end
  var strTitle = document.title;
  var sp = strTitle.indexOf( "(" ); // position of AAAA[(]04)BBBBB
  var ep = strTitle.indexOf( ")" ); // position of AAAA(04[)]BBBBB

  if ((sp >= 0) && (ep > sp+1)){
    var strNum = strTitle.substr(sp+1,ep-sp-1); // ABC(nn)DEF ===> Extract "nn" only
    if ( bRetType == 1 ){
      return( strNum ); // Return String data (eg. "04")
    } else {
      strNum = removeZeroPadding( strNum ); // Strip off zero padding(eg.0004 ==> 4)
      if (!isNaN( strNum )){  // if valid numeric value
        return((bRetType == 2) ? parseInt( strNum ) : parseInt( strNum )-1);
      } else {
        return( -1 );
      }
    }
  }
  return((bRetType == 1) ? "" : -1);
}
function removeZeroPadding( strNum ){
  // IN: assume zero(0) padding numeric string (eg. "000123")
  // OUT: zero padding ("000") removed string ("123")
  @if (@DEBUG == 8) alert('removeZeroPadding: IN, strNum = ' + strNum); @end
  var iStrLength = strNum.length;
  var strRetValue = "";
  var p = 0;
  while(p < iStrLength && strNum.substr(p,1) == "0") p++;
  strRetValue = strNum.substr(p, iStrLength-p);
  @if (@DEBUG == 8) alert('removeZeroPadding: OUT, RET = ' + strRetValue); @end
  return( strRetValue );
}

function fnSetExpressions(){
    var x, y;
    x = F[ "COTX4" ]; y = F[ "CBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.CBTN.value",  "JavaScript" );
    x = F[ "COTXC" ]; y = F[ "CAL"   ]; if (x && y) x.setExpression( "innerText", "parent.CAL.value",   "JavaScript" );
    x = F[ "COTX2" ]; y = F[ "PRN"   ]; if (x && y) x.setExpression( "innerText", "parent.PRN.value",   "JavaScript" );
    x = F[ "COTX6" ]; y = F[ "QRY"   ]; if (x && y) x.setExpression( "innerText", "parent.QRY.value",   "JavaScript" );
    x = F[ "COTX7" ]; y = F[ "SWAP"  ]; if (x && y) x.setExpression( "innerText", "parent.SWAP.value",  "JavaScript" );
    x = F[ "COTX3" ]; y = F[ "RESET" ]; if (x && y) x.setExpression( "innerText", "parent.RESET.value", "JavaScript" );
    x = F[ "COTX1" ]; y = F[ "RBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.RBTN.value",  "JavaScript" );
    x = F[ "COTX8" ]; y = F[ "BBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.BBTN.value",  "JavaScript" );
    x = F[ "COTX9" ]; y = F[ "HBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.HBTN.value",  "JavaScript" );
    x = F[ "COTXA" ]; y = F[ "NBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.NBTN.value",  "JavaScript" );
    x = F[ "COTXB" ]; y = F[ "WBTN"  ]; if (x && y) x.setExpression( "innerText", "parent.WBTN.value",  "JavaScript" );
}
function fnStripBrackets( aStr ){
    var s = 0;
    var p = aStr.indexOf( "(", s );
    if (p == -1) return aStr;
    var r = aStr.length;
    var q = aStr.indexOf( ")", s );
    var sRet = "";
    do {
        sRet += aStr.substr( s, (p-s) );
        s = q + 1;
        p = aStr.indexOf( "(", s );
        q = aStr.indexOf( ")", s );
    } while( (p != -1) && (q != -1) );
    sRet += aStr.substr( s, (r-s) );
    return sRet;
}
var CUSTOM_TAG = "DEF"; // Defined in <HTML> tag above
function initTitles( sTag, sClass ){
    // arg1: HTML TAG element name (eg."SPAN")
    // arg2: Element Class name (eg. "DEF")
    var oColl = document.body.getElementsByTagName( sTag );
    var iCollLen = oColl.length;
    if (sTag == CUSTOM_TAG){
        for (var i=0; i<iCollLen; i++){
            oColl[i].title = "Click to view extended descripton for " + fnStripBrackets(oColl[i].innerText) + ".";
        }
    } else {
        for (var i=0; i<iCollLen; i++){
            if (oColl[i].className == sClass){
                oColl[i].title = "Click to view extended descripton for " + fnStripBrackets(oColl[i].innerText) + ".";
            }
        }
    }
}
function fnSetReading(){
    // Purpose: provide Hiragana reading for the word
    // This function can be used in the following case only.
    // <Ruby><MY:DEF TipID='M05' onmousedown='fnSetReading();'>****</MY:DEF><RP>...
    var oObj = event.srcElement;
//    alert("oObj.children.length= " + oObj.children.length + " TAG= " + oObj.tagName);
    var oOrg = oObj;
    if (oObj.tagName == "RUBY"){  // Added: 2006/10/16(Mon)-00:20:19 by SKN23
    } else if (oObj.parentElement.tagName == "RUBY"){
        oObj = oObj.parentElement;
    } else if (oObj.children.length > 0 && oObj.children(0).tagName == "RUBY"){
        oObj = oObj.children(0);
    } else if (oObj.children.length == 0){
        oOrg.addMessage = "";
        return;
    } else {
        do {
            oObj = oObj.parentElement;
        } while(oObj.tagName != "RUBY");
    }
    var i = 0;
    while(oObj.children(i).tagName != "RT") i++;
    oOrg.addMessage = oObj.children(i).innerHTML;   // Mod by SKN23 on 2005/01/30(Sun)-22:05:34
}
function fnSetFromNotes(){
    // Purpose: provide Hiragana reading for the word
    // This function can be used in the following case only.
    // <Ruby><MY:DEF TipID='M05' onmousedown='fnSetFromNotes();'>****</MY:DEF><RP>...
    // <span><ruby><rb>腫瘍</rb><rp>(</rp><rt>しゅよう</rt><rp>)</rp></ruby><span id="M01">...</span></span>
    var oObj = event.srcElement;
    var oOrg = oObj;
    var TargetID = F[ oObj.TipID ];
    if (TargetID != null){
        if (TargetID.parentElement.tagName == "SPAN"){
            oObj = TargetID.parentElement;
            var oObjP = oObj;
            var ChildLen = oObjP.children.length;
            var k = 0;
            do {
                oObj = oObjP.children(k);
            }while (++k < ChildLen && oObj.tagName != "RUBY");
            if (oObj.tagName == "RUBY"){
                oObjP = oObj;
                ChildLen = oObjP.children.length;
                k = 0;
                do {
                    oObj = oObjP.children(k);
                }while (++k < ChildLen && oObj.tagName != "RT");
                oOrg.addMessage = (oObj.tagName == "RT") ? oObj.innerHTML : "- Not Defined -<RT>";
            } else {
                oOrg.addMessage = "- Not Defined -<RUBY>";
            }
        } else {
            oOrg.addMessage = "- Not Defined -<SPAN>";
        }
    } else {
        oOrg.addMessage = "- Not Defined -<TipID>";
    }
}
function CreateSelOptions( sid ){
    var oSelTag = F[ sid ];
    if (oSelTag == null) return;
    var urlStr, TheList, oHeadTitle, headerText;
    var idx = 1;
    var homeFlag = (DOCURL.lastIndexOf(HOME_URL) != -1) ? true : false;
    oOpt = document.createElement( "OPTION" );
    oOpt.innerText = "Select a title Where to Go..";
    oOpt.value = "0";   // dummy
    oSelTag.appendChild( oOpt );
    for (var i=0; i<iTocLen; i++){
        if (!oTocList[i].Cnd) continue;
        TheList = oTocList[i];
        urlStr = TheList.UrlBody(); // extract "qyymmdd"
        if ((DOCURL.lastIndexOf(urlStr) != -1) && !homeFlag){
            oHeadTitle = F[ HEADER_ID ];
            headerText = LESSON_PREFIX + " (" + idx + ") - " + TheList.Cap;
            if (headerText.length > 64) headerText = SHORT_PREFIX + " (" + idx + ") - " + TheList.Cap;
//            if (oHeadTitle) oHeadTitle.innerText = headerText;
            if (oHeadTitle) oHeadTitle.innerHTML = headerText;
            continue;   // skip current page
        }
        oOpt = document.createElement( "OPTION" );
        oOpt.innerHTML =  "(" + itoStr(2, (i+1)) +")" + TheList.SelOpt() + ((TheList.Cap.length > CAPS_LEN) ? "・・" : "");
        oOpt.value     = TheList.URL;
        oSelTag.appendChild( oOpt );
        idx ++;
    }
    if (homeFlag){
        var x;
        x = F[ "IMG_NEW" ]; if (x != null && x.src != NEW_PIC   ) x.src = NEW_PIC;
        x = F[ "IMG_UPD" ]; if (x != null && x.src != UPDATE_PIC) x.src = UPDATE_PIC;
        x = F[ "IMG_CON" ]; if (x != null && x.src != CONST_PIC ) x.src = CONST_PIC;
    }
}
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);
    }
}
var originalTitle = "";
function beforePrint(){
    var x = F[ 'BTN' ];
    var y = F[ 'SCORE' ];
    var i, theItem;
    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';
    }
    x = F[ "STUDENT" ];
    originalTitle = "";
    if (x != null){
        originalTitle = x.innerHTML;
        var leftpPos = originalTitle.indexOf( "(" );
        if (leftpPos != -1){
            x.innerHTML = originalTitle.substr(leftpPos, (originalTitle.length-leftpPos));
        }
    }
    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 (i=0; i<coll.length; i++){
            x = F[ 'LEG' + i.toString() ];
            if (x != null){
                y = F[ 'FLD' + i.toString() ];
                section = fnStripBrackets(x.innerText);
                ans = window.confirm('Click [OK] to print ' + section + '. Click [CANCEL] to skip.');
                if (!ans && (y != null)) y.style.display = 'none';
                if ((y.style.display != 'none') && (y.innerText.indexOf("<< Homework >>") != -1)){
                    var z = F[ 'FLD' + i.toString() ];
                    if (z != null){
                        z.style.lineHeight = "300%";
                    }
                }
            }
        }
        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';
        }
    }
    var oContentTable = F[ "oTOC" ];
    if (oContentTable != null){
        var oImg = oContentTable.getElementsByTagName( "IMG" );
        for (i=0; i<oImg.length; i++){
            theItem = oImg.item(i);
            if ((theItem.className == IMAGE_EXP) && (theItem.style.display == "")){
                with(theItem){
                    style.display = "none";
                    className     = IMAGE_EXPDM;
                }
            }
        }
    }
    hideText();
}
function chgBtnCaps( caps ){
    var x = F[ "INF9" ];
    var strMsg = "";
    strMsg += "下記の「" + caps + "」ボタンにマウス・カーソルを重ねる"
    if (x != null) x.innerText = strMsg;
}
function afterPrint(){
    var x = F[ 'BTN' ];
    var y = F[ 'SCORE' ];
    var i, theItem;
    var homeFlag = (DOCURL.lastIndexOf(HOME_URL) != -1) ? true : false;

    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;
    }
    x = F[ "STUDENT" ];
    if (x != null && originalTitle != ""){
//        x.innerText = originalTitle;
        x.innerHTML = originalTitle;
    }
    var coll = F.tags( 'legend' );
    for (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 = '';
            if ((y != null) && (y.innerText.indexOf("<< Homework >>") != -1)){
                var z = F[ 'FLD' + i.toString() ];
                if (z != null){
                    z.style.lineHeight = "180%";
                }
            }
        }
    }
    var oContentTable = F[ "oTOC" ];
    if (oContentTable != null){
        var oImg = oContentTable.getElementsByTagName( "IMG" );
        for (i=0; i<oImg.length; i++){
            theItem = oImg.item(i);
            if ((theItem.className == IMAGE_EXPDM) && (theItem.style.display == "none")){
                with(theItem){
                    style.display = "";
                    className     = IMAGE_EXP;
                }
            }
        }
    }
    var idx = 1;
    var curIdx;
    for (var i=0; i<iTocLen; i++){
        TheList = oTocList[i];
        urlStr = TheList.UrlBody(); // extract "qyymmdd"
        if ((DOCURL.lastIndexOf(urlStr) != -1) && !homeFlag){
            var curStudentName = getCurrentStudentName();   // last used student name
            curIdx = getLastTopicNO(curStudentName);
            if ((idx == 1) || ((eval(curIdx) + 1) == idx)){
                updateCookieTopicValue( curStudentName, idx, twoWeeks );
            } else if ((curIdx == null && idx > 1) || ((eval(curIdx) > 0) && ((eval(curIdx) + 1) < idx))){
                alert("Warning: Lssson progress indicator has not updated.\nBecause you skip Topic: "+(eval(curIdx) + 1));              }
            break;
        }
        idx ++;
    }
    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;
    }
    var coll = F.tags( 'A' );
    var clen = coll.length;
//  if (clen > 0){
//      for (var i=0; i < clen; i++){
//          with(coll.item(i)){
//              runtimeStyle.backgroundColor = temp2;   // saveABgColor
//          }
//      }
//  }
    hideColor(temp2);
}
function rubySwitch(flag){
    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;
        x = F[ 'RBTN'    ]; if (x) x.style.display = 'none';
        x = F[ 'RubyOn'  ]; if (x) x.style.display = 'none';
        x = F[ 'RubyOff' ]; if (x) x.style.display = 'none';
    }
}
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';
//  var coll = F.tags( 'A' );
//  var clen = coll.length;
//  if (clen > 0){
//      for (var i=0; i < clen; i++){
//          with(coll.item(i)){
//              runtimeStyle.backgroundColor = bgColor; // saveABgColor
//          }
//      }
//  }
//      oBody.runtimeStyle[ "A" ] = bgColor;
    } else {
        var fgColor = saveFgColor;
        var bgColor = saveBgColor;
        e.value = 'W/B';
        e.title = 'Reset screen color';
//  var coll = F.tags( 'A' );
//  var clen = coll.length;
//  if (clen > 0){
//      for (var i=0; i < clen; i++){
//          with(coll.item(i)){
//              runtimeStyle.backgroundColor = saveABgColor;    // saveABgColor
//          }
//      }
//  }
//      oBody.runtimeStyle[ "A" ] = saveABgColor;
    }
    with(oBody.runtimeStyle){
        backgroundColor = bgColor;
        color = fgColor;
    }
    hideColor(bgColor);
}
function showCaps(){
    var bwLanguage = window.navigator.browserLanguage;
    var sTabSize = (giWidth < 1024) ? '\t\t= ' : '\t= ';
    var sTempStr;
    with(oBody){
    sTempStr = 'width\t\t= ' + width + '\n' +
        'height\t\t= ' + height   + '\n' +
        'availWidth' + sTabSize + availWidth + '\n' +
        'availHeight\t= ' + availHeight    + '\n' +
        'bufferDepth\t= ' + bufferDepth + '\n' +
        'colorDepth' + sTabSize + 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' +
        'browserLanguage\t= ' + bwLanguage + '\n';
    }
    window.alert(sTempStr);
}
function itoStr(w, n){
    var i;
    var r = n.toString();
    var d = w - r.length;
    for (i=0; i<d; i++){
        r = "0" + r;
    }
    return(r);
}
function getFirstDueDate(){
    var d = new Date();
    var StudentName, ToDay, cStudentDate;
    var cStudentName = getCurrentStudentName();
    if (cStudentName != null){
        StudentName = getStudentName(cStudentName, 1);
        ToDay = getStudentStartDate(StudentName);
        cStudentDate = getCookieValue( coSTUDENT_DATE );
        if (ToDay < cStudentDate){
            ToDay = (cStudentDate != null) ? cStudentDate : getToday();
        }
    } else {    // Guest or New Student
        StudentName = window.prompt("(B)Please specify your name:", "Guest Student");
        setCookieValue( coSTUDENT_NAME, StudentName, twoWeeks );
        ToDay = getToday();
    }
    return(ToDay);
}
var UNDERCONST = "jpreadex99hr.htm";
function getTargetURL(base, dir){
    // base: Current URL: string (format: qyymmdd)
    // dir: Direction(1:Next, 0:Current, -1;Previous, 9: Home
    var urlStr, i, k, LinkTo;

    if (dir == HOME_PAGE){
        location.href = HOME_URL;
        return;
    }
    if (base.lastIndexOf(HOME_URL) != -1){
        for (i=0; i<iTocLen; i++){
            if (!oTocList[i].Cnd) continue;
            location.href = (oTocList[i].Mod.substr(0,1) != "N") ? oTocList[i].URL : UNDERCONST;
            return;
        }
        return;
    }
    for (i=0; i<iTocLen; i++){
        urlStr = oTocList[i].UrlBody();     // extract "qyymmdd"
        if (base.lastIndexOf(urlStr) != -1){    // matched
            if ((dir == PREV_PAGE) && (i > 0)){
                k = 1;
                LinkTo = (oTocList[i-k].Mod.substr(0,1) != "N") ? oTocList[i-k].URL : UNDERCONST;
                while(!oTocList[i-k].Cnd){
                    if (i == k){
                        LinkTo = HOME_URL;
                        break;
                    }
                    k++;
                    LinkTo = (oTocList[i-k].Mod.substr(0,1) != "N") ? oTocList[i-k].URL : UNDERCONST;
                }
                location.href = LinkTo;
            } else if ((dir == NEXT_PAGE) && (i < (iTocLen-1))){
                k = 1;
                LinkTo = (oTocList[i+k].Mod.substr(0,1) != "N") ? oTocList[i+k].URL : UNDERCONST;
                while(!oTocList[i+k].Cnd){
                    if ((i+k) == (iTocLen-1)){
                        LinkTo = HOME_URL;
                        break;
                    }
                    k++;
                    LinkTo = (oTocList[i+k].Mod.substr(0,1) != "N") ? oTocList[i+k].URL : UNDERCONST;
                }
                location.href = LinkTo;
            } else if (dir == KEEP_PAGE){
                location.href = (oTocList[i].Mod.substr(0,1) != "N") ? oTocList[i].URL : UNDERCONST;
            } else {    // default: Home Pge
                location.href = HOME_URL;
            }
            return;
        }
    }
    location.href = HOME_URL;
}
function IsFileExist(filespec){
    @if ( @DEBUG == 1 )
    var s = filespec;
    @end
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    if (fso.FileExists(filespec)){
        @if ( @DEBUG == 1 )
        alert(s += " exists.");
        @end
        return true;
    } else {
        @if ( @DEBUG == 1 )
        alert(s += " doesn't exist.");
        @end
        return false;
    }
}
function createTocTable(ids){
    var oOL = F[ ids ];
    if (oOL == null) return;
    var oList, oSpan, oHref, oImg, oCell;
    var StatImg, StatStr, CapStr, stepMark;
    var idx = 1;

    var dueDate = getFirstDueDate();

    for (var i=0; i<iTocLen; i++){
        oCell  = oTocList[i];
        if (! oCell.Cnd) continue;
        stepMark = ((i+1) <= LastTopicNo) ? "■ " : "□ ";

        with(document){
            oList = createElement( "LI"   );
            oSpan = createElement( "SPAN" );
            oHref = createElement( "A"    );
            oImg  = createElement( "IMG"  );
        }
        with(oSpan){
            id        = "L" + itoStr(2, idx);
//            innerText = stepMark + "[Due By " + dueDate.substr(2, 8) + "]: Topic " + itoStr(2, i+1) + " ";
            innerHTML = stepMark + "[Due By " + dueDate.substr(2, 8) + "]: Topic " + itoStr(2, i+1) + " ";
        }
        with(oHref){
            href      = (oCell.Mod.substr(0,1) != "N") ? oCell.URL : UNDERCONST;
//            innerText = oCell.Cap;
            innerHTML = oCell.Cap;
        }
        switch(oCell.Mods()){
            case "R":
                StatImg = NEW_PIC;
                StatStr = NEW_STR;
                break;

            case "U":
                StatImg = UPDATE_PIC;
                StatStr = UPDATE_STR;
                break;

            case "N":
                StatImg = CONST_PIC;
                StatStr = CONST_STR;
                break;
        }
        with(oImg){
            style.display = "none"; // default
            className  = IMAGE_EXP;
            id     = oCell.UrlBody();
            border = "0";
            src    = StatImg;
            title  = oCell.DT() + StatStr;
        }
        with(oList){            // LI   tag
            appendChild(oSpan); // SPAN tag
            appendChild(oHref); // A    tag
            appendChild(oImg);  // IMG  tag
        }

        oOL.appendChild(oList); // LI tag
//<li><span id="Lnn">[By yy/mm/dd]:</span> <a href='qyymmddhr.htm'>sss..ss</a><img class='nn' id='qyymmdd' border='0' src='new.gif' title='yyyy/mm/dd(ddd)-hh:mm:ss ss..ss.' /></li>

        dueDate = getDueDate(dueDate, REPEAT);  // get next due date
        idx ++;
    }   // for end

//  var oP = document.createElement( "P" );
//  with(oP){
//      style.textAlign = "center";
//      innerHTML = "−出典：<a href='http://www.tv-asahi.co.jp/davinci/' target='_blank'>Predictions</a> of <a href='navigatorhr.htm' target='_blank'>Da Vinci</a> (TV. Asahi : Japan)−";
//  }
//  oOL.appendChild(oP);    // P tag

//  initSchedule(Date, Day, Student, SP, EP, Mode(1,2, 8 or 9), NameType)
//  Default Parm("", 7, "", 1, iTocLen, 1, 1)
    initSchedule("", 7, "", 1, iTocLen, 1, 1);
    imgDateCheck();
}

function fmPack(pos, chr, len){
    this.Pos    = pos;  // Start Offset: based 0
    this.Chr    = chr;  // Format Qualifier
    this.Len    = len;  // Symbol Length
}
function makePatnArray(n){
    for (var i=0; i<n; i++){
        this[i] = new fmPack( -1, "", 0 );
    }
    this.length = n;
}
function getQualifyLen(cSYM){
    for (i=0; i<iCurLen; i++){
        if (cSYM == CPATN[i].Chr) return(CPATN[i].Len);
        if (CPATN[i].Chr == "") break;
    }
    return(-1);
}

function getQualifyPos(cSYM){
    for (i=0; i<iCurLen; i++){
        if (cSYM == CPATN[i].Chr) return(CPATN[i].Pos);
        if (CPATN[i].Chr == "") break;
    }
    return(-1);
}
function getQualifyChr(cSYM){
    for (i=0; i<iCurLen; i++){
        if (cSYM == CPATN[i].Chr) return(i);
        if (CPATN[i].Chr == "") break;
    }
    return(-1);
}
if (typeof(makeDayOfWeek) == "undefined"){
    function wdPack(jday, eday){
        this.Jday = jday;   // JP
        this.Eday = eday;   // EN
    }
    function makeDayOfWeek(){
        var i = 0;
        this[i++] = new wdPack( "日", "Sun" ) ; // 0
        this[i++] = new wdPack( "月", "Mon" ) ; // 1
        this[i++] = new wdPack( "火", "Tue" ) ; // 2
        this[i++] = new wdPack( "水", "Wed" ) ; // 3
        this[i++] = new wdPack( "木", "Thu" ) ; // 4
        this[i++] = new wdPack( "金", "Fri" ) ; // 5
        this[i++] = new wdPack( "土", "Sat" ) ; // 6
        this.length = i;
    }
}

var CURRENT_DTIME_PTN = "MM/DD/YYYY hh:mm:ss";
var STANDARD_DATE_ID  = "MDATE";
var ThisVersion       = "2.40"; // 2004/03/11(Thu)-08:51:17
var CPATN   = null;
var NPATN   = null;
var iNewLen = 0;
var iCurLen = 0;

function fnFormatData( sNewPatn, sCurPatn, sDate ){

    // sNewPatn: New     output date format (string) eg. "YYYY/MM/DD(ddd)-hh:mm:ss"
    // sCurPatn: Current input  date format (string) eg. "MM/DD/YYYY hh:mm:ss"
    // sDate   : Input raw data (string)             eg. "02/26/2003-10:08:30" ---> 2003/02/26(ddd)-10:08:30
    // sDate is expected as single byte data

    /* *---------------------------------------------------------------
    << Pre-Defined Symbols as place holder >>
        Y: Year  Symbol (eg. YYYY stands for 2003, YY is 03)
        M: Month Symbol (eg. MM   stands for 10, 02,... so on)
        D: Day   Symbol (eg. DD   stands for 06, 28,... so on)
        h: Hour  Symbol (eg. hh   stands for 10, 05,... so on)
        m: Min.  Symbol (eg. mm   stands for 01, 20,... so on)
        s: Sec.  Symbol (eg. ss   stands for 10, 59,... so on)
    ----------------------------------------------------------------* */
    var i, j, k;    // General use purpose
    var aChr;       // Current  character
    var pChr;       // Previous character
    var sYEAR;
    var s1 = "";
    var s2 = "";
    var s3 = "";
    var s  = "";

    iNewLen = sNewPatn.length;
    iCurLen = sCurPatn.length;
    CPATN   = new makePatnArray(iCurLen);
    NPATN   = new makePatnArray(iNewLen);

    pChr = null;
    for (i=0, j=0, k=0; i<iCurLen; i++){
        aChr = sCurPatn.substr(i,1);
        if (aChr == pChr){
            CPATN[k].Len ++;
            continue;
        }
        CPATN[j].Pos = i;
        CPATN[j].Chr = aChr;
        CPATN[j].Len ++;    // 1
        k = j++;
        pChr = aChr;
    }

    for (i=0; i<iCurLen; i++){
        if (CPATN[i].Pos == -1) break;
        s1 += CPATN[i].Chr + " ";
        s2 += CPATN[i].Pos + " ";
        s3 += CPATN[i].Len + " ";
    }

    pChr = null;
    for (i=0, j=0, k=0; i<iNewLen; i++){
        aChr = sNewPatn.substr(i,1);
        if (aChr == pChr){
            NPATN[k].Len ++;
            continue;
        }
        NPATN[j].Pos = i;
        NPATN[j].Chr = aChr;
        NPATN[j].Len ++;    // 1
        k = j++;
        pChr = aChr;
    }

    s1 = "";
    s2 = "";
    s3 = "";
    for (i=0; i<iNewLen; i++){
        if (NPATN[i].Pos == -1) break;
        s1 += NPATN[i].Chr + " ";
        s2 += NPATN[i].Pos + " ";
        s3 += NPATN[i].Len + " ";
    }

    for (i=0; i<iNewLen; i++){
        if ((nc = NPATN[i].Chr) == "") break;
        cp = getQualifyChr(nc);
        if ((cp != -1) && (CPATN[cp].Len == NPATN[i].Len)){ // nc is found in sDate
            s += sDate.substr(CPATN[cp].Pos, CPATN[cp].Len);
        } else if (cp != -1 && (CPATN[cp].Chr == 'Y' && CPATN[cp].Len != NPATN[i].Len)){
            if (NPATN[i].Len == 4){
                sYEAR = sDate.substr(CPATN[cp].Pos, CPATN[cp].Len);
                if (sYEAR > "50"){
                    sYEAR = "19" + sYEAR;   // 19XX
                } else {
                    sYEAR = "20" + sYEAR;   // 20XX
                }
            } else {
                sYEAR = sDate.substr(CPATN[cp].Pos+(CPATN[cp].Len-NPATN[i].Len), NPATN[i].Len);
            }
            s += sYEAR;
        } else if (cp == -1){
            if (NPATN[i].Len == 1){ // should be a delimiter such as "/"
                s += ((nc == 'S') ? ' ' : nc);
            } else if ((nc == "d") && (NPATN[i].Len >= 3)){ // ddd ===> day of week
                var d = new Date();
                pY = getQualifyPos('Y'); lY = getQualifyLen('Y');
                pM = getQualifyPos('M'); lM = getQualifyLen('M');
                pD = getQualifyPos('D'); lD = getQualifyLen('D');
                sYEAR = (pY >= 0) ? sDate.substr(pY, lY) : d.getFullYear();
                if (sYEAR.length == 2){
                    if (sYEAR > 50){
                        sYEAR = "19" + sYEAR;   // 19XX
                    } else {
                        sYEAR = "20" + sYEAR;   // 20XX
                    }
                }
                var iYEAR  = eval(sYEAR);
                var iMONTH = eval(sDate.substr(pM, lM));
                var iDAY   = eval(sDate.substr(pD, lD));
                d = new Date(iYEAR, iMONTH-1, iDAY);
                day = d.getDay();
                var DaysOfWeek = new makeDayOfWeek();
                s += DaysOfWeek[day].Eday;
                DaysOfWeek = null;
            } else {
                s += sNewPatn.substr(NPATN[i].Pos, NPATN[i].Pos);   // copy from NewPatn
            }
        }
    }
    return s;
}
function fnUpdateMdate( sID ){
    var oID = F[ sID ];
    if ((oID != null) &&
        ((oID.innerText.indexOf("YY") != -1) ||
         (oID.innerText.indexOf("MM") != -1) ||
         (oID.innerText.indexOf("DD") != -1) ||
         (oID.innerText.indexOf("hh") != -1) ||
         (oID.innerText.indexOf("mm") != -1) ||
         (oID.innerText.indexOf("ss") != -1))){  // (oID.innerText.substr(0,2) == "YY") is emergency to avoid twice call
        with(oID){
            style.display = "";
            //                       New Ptn     Current Pattern       Current Data(Date)
            innerText = fnFormatData(innerText, "MM/DD/YYYY hh:mm:ss", document.lastModified);
        }
    }
}

function repLastModifiedDate(){
    fnUpdateMdate( "MDATE" );
}
function fnUpdateVersion( sID ){
    var oConectType = F.oBody.connectionType;
    var pType = (oConectType != "offline") ? "w" : "c";
    var coll = F.tags("SPAN");
    for (var i=0; i<coll.length; i++){
        if (coll[i].className == sID) coll[i].innerText = ThisVersion + pType;
    }
//    var x = F["HCOUNT"];
//    if (x != null){
//        x.style.display = ((pType == "w") ? "" : "none");
//    }
    @if (@DEBUG == 1) alert("Connection Type= " + oConectType); @end
}

function fnUpdateMdate2( sID ){
    @if (@DEBUG == 1) alert("fnUpdateMdate2 >> IN: SID=" + sID); @end
    var coll = F.tags("SPAN");
    for (var i=0; i<coll.length; i++){
        if (coll[i].className == sID && coll[i].innerText.substr(0,2) == "YY"){  // (oID.innerText.substr(0,2) == "YY") is emergency to avoid twice call
            with(coll[i]){
                style.display = "";
                //                       New Ptn    Current Pattern    Current Data(Date)
                innerText = fnFormatData(innerText, CURRENT_DTIME_PTN, document.lastModified);
                @if (@DEBUG == 1) alert("fnUpdateMdate2 >> New Date=" + innerText); @end
            }
        }
    }
    @if (@DEBUG == 1) alert("fnUpdateMdate2 >> OUT"); @end
}

function fnUpdateProductInfo( sID1, sID2 ){
    // sID1: Version SPAN-Tag ClassName
    // sID2: Update Date SPAN-Tag ClassName
    fnUpdateVersion( sID1 );
    fnUpdateMdate2( sID2 );
}

function repLastModifiedDate2(){
    var oModDate = F[ "MDATE" ];
    if (oModDate == null) return;

    var urlStr;
    var homeFlag = (DOCURL.lastIndexOf(HOME_URL) != -1) ? true : false;
    var curModifiedDate = oModDate.innerText.substr(0, 10); // yyyy/mm/dd
    var curModifiedTime = oModDate.innerText.substr(16, 8); // hh:mm:ss

    for (var i=0; i<iTocLen; i++){
        urlStr = (homeFlag) ? HOME_URL : oTocList[i].UrlBody(); // extract "qyymmdd"
        if (DOCURL.lastIndexOf(urlStr) != -1){      // matched
            if (( curModifiedDate <  oTocList[i].Date()) ||
                ((curModifiedDate == oTocList[i].Date()) &&
                 (curModifiedTime <= oTocList[i].Time()))){
                oModDate.innerText = oTocList[i].DT();
                curModifiedDate    = oTocList[i].Date();    // yyyy/mm/dd
                curModifiedTime    = oTocList[i].Time();    // hh:mm:ss
                @if ( @DEBUG == 1 )
                window.status = "Replaced Last Modified Date As: " + oModDate.innerText;
                @end
            }
            if (!homeFlag) return;
        }
    }
}
function OnMouse2(base, dir){
    var e = window.event.srcElement;
    var urlStr, LinkCap, k, i, sp;
    var pageTitle = "";

    if (base.lastIndexOf(HOME_URL) != -1){
        for (i=0; i<iTocLen; i++){
            if (!oTocList[i].Cnd) continue;
            pageTitle = oTocList[i].Cap;
            break;
        }
    } else {

    for (i=0; i<iTocLen; i++){
        urlStr = oTocList[i].UrlBody(); // extract "qyymmdd"
        if (base.lastIndexOf(urlStr) != -1){        // matched
            if ((dir == PREV_PAGE) && (i > 0)){
                k = 1;
                LinkCap = oTocList[i-k].Cap;
                while(!oTocList[i-k].Cnd){
                    if (i == k){
                        LinkCap = "Home Page of " + BOOK_TITLE;
                        break;
                    }
                    k++;
                    LinkCap = oTocList[i-k].Cap;
                }
                pageTitle = LinkCap;
            } else if ((dir == NEXT_PAGE) && (i < (iTocLen-1))){
                k = 1;
                LinkCap = oTocList[i+k].Cap;
                while(!oTocList[i+k].Cnd){
                    if ((i+k) == (iTocLen-1)){
                        LinkCap = "Home Page of " + BOOK_TITLE;
                        break;
                    }
                    k++;
                    LinkCap = oTocList[i+k].Cap;
                }
                pageTitle = LinkCap;
            } else if (dir == KEEP_PAGE){
                pageTitle = oTocList[i].Cap;
            } else {    // default: Home Pge
                pageTitle = "Home Page of " + BOOK_TITLE;
            }
            break;
        }
    }
    }

    if (dir == HOME_PAGE) pageTitle = "Home Page of " + BOOK_TITLE;
    with(e.style){
        color  = 'lime';
        cursor = 'hand';
    }
    e.title = (pageTitle != "") ? fnStripHtmlTags(pageTitle) : fnStripHtmlTags(e.title);
}
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 showHitCounter_Pre(sID){
    if (F.oBody.connectionType != "offline"){
        var x = F[ sID ];
        if (x != null){
            with(x.style){
                display = (display == "none") ? "" : "none";
            }
        }
    }
}
function showHitCounter(sID, sStatus){
    if (F.oBody.connectionType != "offline"){
        var x = F[ sID ];
        if (x != null){
            x.style.display = sStatus;
//            with(x.style){
//                display = (display == "none") ? "" : "none";
//            }
        }
    }
}
function showTran(){
    var x = F[ 'FLD1' ];
    if (x != null){
        with(x.runtimeStyle){
            display = (display == 'none') ? '' : 'none';
        }
    }
    showHitCounter('HCOUNT');
}
function showTran2(sID){
    if (sID != "FLD99"){
        var x = F[ sID ];
        if (x != null){
            if (!(x.runtimeStyle.display == 'none' && x.innerText == "<< Notes >>")){
                with(x.runtimeStyle){
                    display = (display == 'none') ? '' : 'none';
                }
                if (x.runtimeStyle.display == ""){  // added by SKN23 on 2005/01/23(Sun)-14:47:57
                    x.scrollIntoView( true );       // top align
                    showHitCounter('HCOUNT', x.runtimeStyle.display);
                }
            }
        }
    }
//    showHitCounter('HCOUNT');
}
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;
                } else if (className == 'CREDIT'){
                    runtimeStyle.backgroundColor = targetColor;
                }
            }
        }
    }
//  coll = F.tags( 'A' );
//  clen = coll.length;
//  if (clen > 0){
//      for (var i=0; i < clen; i++){
//          with(coll.item(i)){
//              if (targetColor == 'black' || targetColor == 'white'){
//                  runtimeStyle.backgroundColor = targetColor;
//              } else {
//                  runtimeStyle.backgroundColor = saveABgColor;    // saveABgColor
//              }
//          }
//      }
//  }
}
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 dispToggle(e){
    var x = F[ e ];
    if (x != null){
        with(x.runtimeStyle){
            display = (display == 'none') ? '' : 'none';
        }
    }
}
function swapLang( sid ){
  var x = document.all[ sid ];
  if (x == null) return;
  x.style.display = (x.style.display == "none") ? "" : "none";
  var e = event.srcElement;
  with(e){
    if (x.style.display == "none"){
      innerText = "Show English >>";
      title = "Show English passage";
    } else {
      innerText = "Hide English >>";
      title = "Hide English passage";
    }
  }
}
function visibleToggle(e){
    var x = F[ e ];
    if (x != null){
        with(x.runtimeStyle){
            visibility = (visibility == 'hidden') ? 'visible' : 'hidden';
        }
    }
}
function showTips(ids){
    var e = event.srcElement;
    var x = F[ ids ];
    if (x != null){
        e.title = e.innerText + "= " + x.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;
}
window.onerror = MyErrHandler;
// #################################################################################
// #    << End of jpread.js >> (C) 2002 Southern Cross Virtual Co., Ltd. (v1.2)
// #################################################################################
