// #################################################################################
// #    File Name   : srctblg2.js
// #    Project     : Japanese Grammar Note
// #    System      : On-Line Japanese Reading Material
// #    Purpose     : Generate Dynamic Table of Contents
// #    Function    : DIARY Control
// #    Model       : This programe is based on the Document Object Model (DOM)
// #    Language    : JavaScript (Client Side Scripting. ver: 5.x)
// #    Include     : jpread.js
// #    Date Issued : 2006/09/18(Mon)-20:43:56
// #    Base URL    : http://www.all.co.nz/
// #    Location    : js/
// #    Usage       :
// #    Browsers    : IE5.x and above
// #    Requirement : <BODY ID='oBody'>
// #    Restriction : None
// #    Author      : H. Sekine (Able LL Systems Dpt. CHC, NZL)
// #    Copyright   : (C) 20026 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)/(==9) Test Release Mode
// ###########################################################################
// #                            << 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.の財産です。本プログラム  #
// # はトレード・シークレットとみなされ、当該権利者の書面による許可なくして、#
// # 漏洩または使用を禁じます。                                              #
// ###########################################################################


function ciPack(head, id){
    this.Header = head;
    this.ID     = id;
}

function makeTableHeaderName(){
    var i = 0;
    this[i++] = HCAPS0 ;	// "品　詞"
    this[i++] = HCAPS1 ;	// "読　み"
    this[i++] = HCAPS2 ;	// "単　語"
    this[i++] = HCAPS3 ;	// "意　味"
    this[i++] = HCAPS4 ;	// "レベル"
    this[i++] = HCAPS5 ;	// "備　考"
    this[i++] = HCAPS6 ;	// "FLAG1"
    this[i++] = HCAPS7 ;	// "FLAG2"
    this.length = i;
}

function makeSearchTable2(oTid){
    var oTBody, oRow, oCell, loop, i, TheCourse, iAiIndex, aWord;
    var oTable = F[oTid];
    if (oTable == null) return;

    oTBody = document.createElement( "TBODY" ); // Source Data to be Included here
    oTBody.id = SEARCH_BODY;    // "oSearchBody"use in tableAct3.htc
    oTable.appendChild(oTBody);
    goSPPPack = new makeSPS();

    loop = goSrcWrd.length;

    for (i=goSrcWrd.BuffOffSet1; i<loop; i++){

        if (goSrcWrd[i].FLAG == false) continue;
        TheCourse = goSrcWrd[i];

        oRow = document.createElement( "TR" );  // Append a new ROW
        oTBody.appendChild(oRow);

        oCell = document.createElement( "TD" ); // [0]:品詞名
        with(oCell){
            innerText = fnGetSppNameByCode( TheCourse.TYP );
            style.textAlign = "center";
        }
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [1]:読み
        oCell.innerHTML = StripSpaces( TheCourse.YOMI );
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [2]:単語
        oCell.innerHTML = StripSpaces( TheCourse.WORD );
        aWord = oCell.innerText;
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [3]:意味
        oCell.innerHTML = StripSpacesRev( TheCourse.MEAN );
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [4]:レベル
        with(oCell){
            innerText = "[ " + TheCourse.OPP + " ]";
            style.textAlign = "center";
        }
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [5]:備考
        if (TheCourse.TYP == SPP_ID01){	// イ形
			iAiIndex = ((TheCourse.ATTR == 0) ? 0 : TheCourse.ATTR-1);
			with( oCell ){
				innerText += AITYPES[iAiIndex];
				title = AITYPESM[iAiIndex];
			}
		} else if ((TheCourse.TYP == SPP_ID11) && (isLastLetterIt( aWord, "る" ) == false)){
			with( oCell ){
				innerText += "[五段]";
				title = "5-Step Verb";
			}
		} else if (TheCourse.TYP == SPP_ID15 || TheCourse.TYP == SPP_ID16){
			with( oCell ){
				innerText += ((TheCourse.TYP == SPP_ID15) ? "[一段]" : "[五段]");
				title = ((TheCourse.TYP == SPP_ID15) ? "1-Step Verb" : "5-Step Verb");
			}
		} else {
        	oCell.innerText += ((TheCourse.REM) ? TheCourse.REM : " ");
		}
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [6]:フラグ１
        with(oCell){
        	oCell.innerText = " ";
        	style.display = "none";
        }
        oRow.appendChild(oCell);

        oCell = document.createElement( "TD" ); // [7]:フラグ２
        with(oCell){
        	oCell.innerText = " ";
        	style.display = "none";
        }
        oRow.appendChild(oCell);
    }

    goSPPPack = null;
    cmbButtonReset();
}
function isLastLetterIt( aWord, aChr ){
	return(aWord.substr(aWord.length-1,1) == aChr);
}
function StripSpacesRev( sWord ){
	var	c;
	var	p = sWord.length-1;	//		 SP			 TAB		  BSP
	while(((c = sWord.substr(p,1)) == " " || c == "\t" || c == "　") && (p >= 0)) p--;
	return(sWord.substring(0, p+1));
}
function StripSpaces( sWord ){
	var	p=0, c;
	var	r = sWord.length;	//		 SP			 TAB		  BSP
	while((c = sWord.substr(p,1)) != " " && c != "\t" && c != "　" && p < r) p++;
	return(sWord.substring(0, p));
}
function stripBlaket(sWord){
	return(sWord);	// 2006/09/19(Tsu)-11:31:16
    var p;
    if ((p = sWord.indexOf( R_BRAKET )) == -1) return(sWord);   // "]"
    return(sWord.slice(p+1));
}

function getWordYomi(word){
    var TheWord;
    for (var i=0; i<giSrcWrdLen; i++){
        TheWord = goSrcWrd[i];
        if (word == TheWord.WORD) return(TheWord.YOMI + ":" + TheWord.MEAN);
    }
    return(word);
}

function makeComboControlID(){
    var i = 0;
    this[i++] = CTLID0;
    this[i++] = CTLID1;
    this[i++] = CTLID2;
    this[i++] = CTLID3;
    this[i++] = CTLID4;
    this[i++] = CTLID5;
    this.length = i;
}

// #################################################################################
// #    << End of srctblg2.js >> (C) 2006 Southern Cross Virtual Co., Ltd. (v1.2)
// #################################################################################

