function sPack(unqID, name1, name2, day, date){
    this.UID   = unqID; // A: Unique ID for Cookie ID, etc.
    this.NameE = name1; // B: English String
    this.NameJ = name2; // C: Japanese String
    this.Day   = day;   // D: Tuition day(0:Sunday, 1:Monday...6:Saturday,7:Once a Week
    this.Date  = date;  // E: Tuition starting date (yyyy/mm/dd)
}
// Basic Student Information (Add/Delete/Modify here)
function makeStudent(){
    var i = 0;  //          P:A      P:B              P:C                  D   P:E
    this[i++] = new sPack( "STD01", "Sam Yang",      "サム・ヤング",       6, "2002/01/12" ) ;
    this[i++] = new sPack( "STD02", "Joanne Yang",   "ジョアンヌ・ヤング", 6, "2002/01/12" ) ;
    this[i++] = new sPack( "STD03", "Lily Yang",     "リリー・ヤング",     6, "2002/01/12" ) ;
    this[i++] = new sPack( "STD04", "Linda & Howard","リンダ＆ハワード",   3, "2002/03/12" ) ;
    this[i++] = new sPack( "STD05", "Susan Lee",     "スーザン・リー",     4, "2002/04/11" ) ;
    this[i++] = new sPack( "STD06", "Grace Liu",     "劉 孟女冊",          0, "2002/04/07" ) ;
    this[i++] = new sPack( "STD07", "Serena Liu",    "セリーナ・リュウ",   2, "2002/03/12" ) ;
    this[i++] = new sPack( "STD08", "Charles Chen",  "陳 昭旭",            2, "2002/03/19" ) ;
    this[i++] = new sPack( "STD09", "Lewis Hsueh",   "ルイス・スイ",       2, "2002/01/08" ) ;
    this[i++] = new sPack( "STD10", "Stan Chang",    "スタン・チェン",     3, "2002/02/06" ) ;
    this[i++] = new sPack( "STD11", "Fan-Ku Yang",   "ファンク・ヤング",   6, "2002/01/19" ) ;
    this[i++] = new sPack( "STD12", "Ruby Lee",      "ルビー・リー",       6, "2002/01/26" ) ;
    this[i++] = new sPack( "STD13", "Judy Yunling",  "端木 芸苓",          1, "2002/09/09" ) ;
    this[i++] = new sPack( "STD14", "Stephine",      "ステファニー",       4, "2002/03/28" ) ;
    this[i++] = new sPack( "STD15", "Mike Chen",     "陳 思銘",            2, "2002/03/26" ) ;
    this[i++] = new sPack( "STD16", "Emi Sekine",    "関根 絵美",          6, "2002/01/12" ) ;
    this[i++] = new sPack( "STD17", "Sara Chang",    "セーラ・チャン",     3, "2006/09/06" ) ;
    this[i++] = new sPack( "STD18", "John Smith",    "ジョン・スミス",     7, "" ) ;
    this.length = i;
}
var StudentNames = new makeStudent();

function updateCookieTopicValue(sName, tocVal, expDate){
    var unqID = getStudentID(sName);
    goCookiStudentTopicID = coCOOKIE_TOPIC_PREFIX + unqID;
    setCookieValue( goCookiStudentTopicID, tocVal, expDate );
}
function updateCookieNameValue(sName, expDate){
    var unqID = getStudentID(sName);
    goCookiStudentNameID = coCOOKIE_NAME_PREFIX + unqID;
    setCookieValue( goCookiStudentNameID, sName, expDate );
}
function getLastTopicNO(sName){
    var unqID = getStudentID(sName);
    goCookiStudentTopicID = coCOOKIE_TOPIC_PREFIX + unqID;
    return getCookieValue( goCookiStudentTopicID );
}
function getStudentID(aName){
    // Student First Name: string without spaces
    if (aName == "" || aName == null) return aName;
    var i, len;
    var sdName;
    var sName = aName.toUpperCase();
    len = StudentNames.length;

    for (i=0; i<len; i++){
        sdName = StudentNames[i].NameE.toUpperCase();
        if (sdName.indexOf(sName) != -1){   // Matched
            return StudentNames[i].UID;
        }
    }
    return "STD999";
}
function getCurrentStudentName(){
    return getCookieValue( coSTUDENT_NAME );
}
function getStudentName(sName, sw){
    // Student First Name: string without spaces
    // Name String Type: =1:English, =2:Japanese
    var i, len;
    var sdName;
    var sNameU = sName.toUpperCase();
    len = StudentNames.length;

    for (i=0; i<len; i++){
        sdName = StudentNames[i].NameE.toUpperCase();
        if ((sdName.indexOf(sNameU) != -1) && (sName != "")){   // Matched
            return ((sw == 1) ? StudentNames[i].NameE : StudentNames[i].NameJ);
        }
    }
    return ( (sName == "" ) ? "Japanese Beginners" : sName );
}
function getStudentStartDate(sName){
    // sName: proper student name string
    var i, len;
    var sdName;
    sName = sName.toUpperCase();
    len = StudentNames.length;

    for (i=0; i<len; i++){
        sdName = StudentNames[i].NameE.toUpperCase();
        if (sdName.indexOf(sName) != -1){   // Matched
            if (StudentNames[i].Date != ""){
                return(StudentNames[i].Date);
            } else {
                break;
            }
        }
    }
    return ( getToday() );  // Not Found=Today
}
function getStudentDay(sName, sw){
    // sName: proper student name string
    // sw: =1: Day String, =2: Day numeric value(0, 1, 2,...
    var i, len;
    var sdName;
    sName = sName.toUpperCase();
    len = StudentNames.length;

    for (i=0; i<len; i++){
        sdName = StudentNames[i].NameE.toUpperCase();
        if (sdName.indexOf(sName) != -1){   // Matched
            return((sw == 1) ? DayOfWeek[StudentNames[i].Day] : StudentNames[i].Day);
        }
    }
    return ( 7 );   // Not Found: Once a Week
}
