/**
* @fileoverview<pre>
* tutorial.js
*
* A JavaScript library file for TutorialsOnline.info
*
* ----------------------------------------------------------------------------
* Copyright Notice
* This file contains proprietary information of Alan Kelsey, Ltd.
* Copying or reproduction is only allowed provided Alan Kelsey of
* Alan Kelsey, Ltd. is acknowledged in all code and in any copyright notice.
* The software in this file is not guaranteed to perform as specified but
* Alan Kelsey, Ltd. has done its best to ensure that it does behave as specified.
* Copyright (c) 2007
* ----------------------------------------------------------------------------
*
* <b>Alan Kelsey, Ltd.</b>
*
* www.TutorialsOnline.info
*
* @author				Alan Kelsey
* @version 				2.3
* @date  				May 1, 2011
*</pre>
*/

/**
*<p>
*Revision History
*</p>
*
*<dl>
*<dt>1.7</dt>
*<dd>Added quizInfo[ ] object</dd>
*
*<dt>1.8</dt>
*<dd>Expanded to allow for blended classes</dd>
*
*<dt>1.9</dt>
*<dd>Differentiated the prePost dates for blended classes and for blended Homework postings</dd>
*
*<dt>2.1</dt>
*<dd>Employed jQuery and AJAX extensively</dd>
*
*<dt>2.3</dt>
*<dd>Added UTIL namespace</dd>
*
*</dl>
*/
/*********************************************************************************/

/*********************************************************************************/
/******************************   Global variables   *****************************/
/*********************************************************************************/

/*********************   Set the path to the Common folder   *********************/
/***********   Use ./ if one course per domain, ../ if more than one   ***********/
var commonFolder = "./Common/";

var hmidSemBreak = "";          //    Short description for vevent

var syllPage = false;           //		Boolean - Is this a syllabus page?
var repeatCustomer = false;
var lastVisit = 0;              //		Hold the date & time of previous access
                                //			in GMT milliseconds
var dateAdjustment = 0;         //		Accommodate date bugs on some platforms
var scKey = 298;

/*
var is_fx = false;
var is_ie = false;
*/

/***   The date cookies expire is two days after the last day of the semester   **/
/*********************   This is used in other calculations   ********************/
var CookiesOBJ = new CookieHandler();
var cookie1 = "lastVisit";
var cookie2 = "nextPrevVisit";
var cookie3 = "class101";
var expires = new Date("2012/5/18");

/************   This short script gets the date/time from the server   ***********/
/***************   from http://www.mresoftware.com/serverdate.htm   **************/

var nowDay = new Date(); //		Make today's date a global variable
$.ajax( {
    url: "./Common/css_js/time.php",
    success: function(data) {
        nowDay = new Date(data);
        },
    async: false
    });


/****************   If server time not passed, use client's time   ***************/
if (typeof nowDay !== "undefined" && nowDay !== "NaN") {
    nowDay = new Date();
    }

var nowDate = nowDay.getDate();
var nowMonth = nowDay.getMonth();
var nowYear = nowDay.getFullYear();
var twoWeeks = false;           //		Set the due date out two weeks, instead of the normal one

var ssDay = new Date();         //		Make the specific class day a global variable
var satDay = new Date();        //		Make the previous Saturday a global variable

var onlineDueDate = new Date(); //      Make online due dates a global variable
var quizToday;                  //		A boolean to say if there is a quiz soon

/***********   evalDate is used to turn on the course evaluation link   **********/
var evalDate = new Date("1/1/2013");
evalDate.setMonth(expires.getMonth() - 1);

var quizLocation = "http://TutorialsOnline.info/cgi-bin/quizTest/";
var quizPDFLocation = "http://TutorialsOnline.info/";

if (document.title.indexOf("Homework") > -1) {
    shortSem = false;
    }

var showIt = false;
var quizNum = -1;               //		Variable to hold the quiz numbers

var courseArray = new Array();  //      ("","","","","","","","","","")
var cookieVal = "";
var cNum;                       //		The course number
var iNum = 1;                   //		The instructor number
var iNumExMenu;                 //		Temp var to hold iNum
var tW = 0;

//  classes start Monday, August 22, 2011
//	classes end December 17, 2011

//  classes start Tuesday, June 1, 2010
//	classes end July 24, 2010

var startYr = 2012;             //		Starting day of class: year
var startMo = 1 - 1;            //		Starting day of class: month
var startDy = 8;               //		Starting day of class: day
var startHour = 18;
var endHour = 21;

var dueDate = new Date(startYr, startMo, startDy);
var movieArray = new Array(1,11,21,31,41,51,61,71,81,91);
var movieNum = 0;               //		Cycle through the above array 20123 was 0 

var nextAssn = 2;
var labNum = 0;                  //     Hold the lab numbers if shortSem
var titleFlag = true;
var declareWin;                  //		The popup window used to declare the instructor
var windowStats = new Array();   //		An array to hold popup window parameters
scKey = scKey % 17;
/**********************************************************************************
                We need to calculate an offset from a day of the week
                    that is before the day of the week the semester starts.
***********************************************************************************
***********************************************************************************
If the semester starts on		the offSet is
    Online                          0
    Monday                          1
    Tuesday                         2
    Wednesday                       3
    Thursday                        4
    Friday                          5

    Online courses will have classes on Sundays and
    may "start" before the semester actually begins.
**********************************************************************************/ 
var startOffSet = dueDate.getDay();

/******   Almost all dates are calculated from a Sunday so we have to have   *****/ 
/****   the "starting day" be the Sunday before the actual start of the term   ***/
dueDate.setDate(dueDate.getDate() - startOffSet);
/*********************************************************************************/ 

var nextAssn = 2;
var labNum = 0;                 //     Hold the lab numbers if shortSem
var titleFlag = true;
var declareWin;                 //		The popup window used to declare the instructor
var windowStats = new Array();  //		An array to hold popup window parameters
scKey = scKey % 17;

/*********************************************************************************/                  
/***********   This prePost variable globally controls how many days   ***********/
/*****************   before the class a link should be active.   *****************/

/***   This can be set independently for each class in the index.shtml files.   **/
/*********************************************************************************/
var linkActive = new Function('a', 'return a * 86400000;');

var prePost = linkActive(3.5);         //  When the links become active
var prePostHw = linkActive(4.5);       //  When the Homework links become active
var prePostBlended = linkActive(12.5); //  When the links become active in a blended class

var CCIS = new Array();                //  class specifics
var InstrButton = new Array();         //  instructors for specific class

/*********************************************************************************/
/*********************************************************************************/
/*****************   The variable cNum sets the specific course   *****************
1 -     HTML
2 -     Advanced HTML
3 -     JavaScript
4 -     Java
5 -     XML
6 -     AJAX
7 -     [extra spot]
8 -     [extra spot]
9 -     admin
**********************************************************************************/
/*****************************   Set up the arrays   *****************************/
/********************************   Directories   ********************************/
var dirs = new Array();
x = 1;
dirs[x++] = "http://HTMLTutorialOnline.info/";
dirs[x++] = "http://CSSTutorialOnline.info/";
dirs[x++] = "http://JavaScriptTutorialOnline.info/";
dirs[x++] = "http://JavaTutorialOnline.info/";
dirs[x++] = "http://XMLTutorialOnline.info/";
dirs[x++] = "http://AJAXTutorialOnline.info/";
dirs[x++] = "http://Orientation.Tutorialsonline.info/";
dirs[x++] = "http://Programming.Tutorialsonline.info/";
dirs[x++] = "admin/";

/************************   Set the next arrays to hold   ************************/
/**************   the numbers of the classes offered this semester   *************/
var courses =
    new Array("", "HTML", "Advanced HTML", "JavaScript", "Java", "XML", "AJAX", "", "", "admin", "");
var classesOffered = new Array(0, 1, 2, 3, 4, 6);

/**************   Set up a multi-dimensional array of instructors   **************/
/*******************   The first dimension holds which course   ******************/
/****************   The second dimension holds which instructor   ****************/

var MasterInstr = new Array();

for (i = 0; i < x; i++) {
    MasterInstr[i] = new Array();
    }
/*********************************************************************************/

/*********************************************************************************/
/************************   Create MastrInstr[] objects  *************************/
function makeInstrBasic() {
    x = 0;
    this.CCIS = makeInstrBasic.arguments[x++];
    this.cDesc = makeInstrBasic.arguments[x++];
    this.cPre = makeInstrBasic.arguments[x++];
    }

/*********************************************************************************/
/***********************   Create MastrInstr[][] objects  ************************/
function makeInstr() {
    x = 0;
    this.name = makeInstr.arguments[x++];   //  Instructor's name
    this.clNum = makeInstr.arguments[x++];  //  Number of the day the class meets
    this.clDay = makeInstr.arguments[x++];  //  Name of the day the class meets
    this.email = makeInstr.arguments[x++];  //  Instructor's email
    this.page = makeInstr.arguments[x++];   //  Instructor's syllabus page
    this.hwDay = makeInstr.arguments[x++];  //  Day the homework is due

    if (makeInstr.arguments.length > 6) {
        //  Set the next variable to true if class runs two consecutive days
        this.iTwoTimes = makeInstr.arguments[x++];
        //  If running this class twice a week in a shortened semester
        this.iShortSem = makeInstr.arguments[x++];
        } else {
        //  Set the next variable to true if class runs two consecutive days
        this.iTwoTimes = false;
        //  If running this class twice a week in a shortened semester
        this.iShortSem = false;
        }

    this.blended = false;
    this.hwemail = this.email;

    if (makeInstr.arguments.length > 8) {
        this.blended = makeInstr.arguments[x++];
        }

    if (makeInstr.arguments.length > 9) {
        this.hwemail = makeInstr.arguments[x++];
        }
    if (this.clNum === 0) { //		Test if this is an online course
        this.online = true;
        }
    }

/*********************************************************************************/
/*************************   Create quizInfo[] objects   *************************/

var quizInfo = new Array();

for (xmq = 0; xmq < 8; xmq++) {
    quizInfo[xmq] = new Object();
    /*  Put in the same information for all quizzes  */
    quizInfo[xmq].online = true;
    quizInfo[xmq].dayActive = 6;
    quizInfo[xmq].numDays = 9;

    }

/*  Change Quiz 0  */
quizInfo[0].online = true;
quizInfo[0].dayActive = 12;
quizInfo[0].numDays = 12;

/*********************************************************************************/
/*************************   Create makeQuiz[] objects   *************************/
function makeQuizBasic() {
    x = 0;
    this.quizDate = makeQuizBasic.arguments[x++];
    this.quizURL = makeQuizBasic.arguments[x++];
    this.quizOn = makeQuizBasic.arguments[x++];
    this.quizOnline = makeQuizBasic.arguments[x++];
    }

/*********************************************************************************/
/***************************   Set up standard arrays   **************************/

var mos = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
var months = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var monthNames = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
var dayNames = new Array("Online", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var ordinals = new Array("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten","Eleven","Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen");

var todayStr = monthNames[nowMonth] + " " + nowDate + ", " + nowYear;

/*********************************************************************************/

/*********************************************************************************/
/****************   Calculate the width and height of the frame   ****************/
function frameDim() {
    frameWidth = $(window).width();
    frameHeight = $(window).height();
    }

/*********************************************************************************/

/*********************************************************************************/
/************************  Try to read instructor cookie  ************************/

if (CookiesOBJ.getCookie(cookie3) == null) {
    courseArray[0] = 0;
    } else {
    cookieVal = CookiesOBJ.getCookie(cookie3)

    for (x = 0; x < cookieVal.length; x = x + 2) {
        courseArray[cookieVal.charAt(x)] = cookieVal.charAt(x + 1)
        }
    }

/*********************************************************************************/
/*********************   Create a declaration popup window   *********************/

var winStats = "";
function changeInstr(cN) {
    windowStats[1] = "height=250px,width=500px,";

    for (i = 0; i < windowStats.length; i++) {
        winStats += windowStats[i];
        }

    var newWindCodTitle = "<html><head><title>Change Instructors</title>";
    var chngInstrForm0 = "<h2>Indicate your Instructor</h2>";
    var chngInstrForm1 = "<form action=\"javascript:void(0)\">";
    var chngInstrForm2 = "<input type=\"radio\" name=\"chngInstrGrp\" id=\"chngInstr";
    var chngInstrForm3 = "\" onclick=\"opener.changeInstrClose(";
    var chngInstrForm3b = ")\" />\n";
    var chngInstrForm4 = "<label for=\"chngInstr";
    var chngInstrForm5 = "\">";
    var chngInstrForm6 = "</label><br />\n";
    var chngInstrForm7 = "</form>";
    var chngInstrFormHTML = "<body>" + chngInstrForm0 + chngInstrForm1;


    if (MasterInstr[cN].length > 3) {
        for (x = 1; x < MasterInstr[cN].length; x++) {
            InstrButton[x] = MasterInstr[cN][x].clDay + " - " + MasterInstr[cN][x].name + "\n";
            chngInstrFormHTML += chngInstrForm2 + x + chngInstrForm3 + x + chngInstrForm3b;
            chngInstrFormHTML += chngInstrForm4 + x;
            chngInstrFormHTML += chngInstrForm5 + InstrButton[x] + chngInstrForm6;
            }
        chngInstrFormHTML += chngInstrForm7;


        makeNewWindow(winStats, newWindCodTitle);
        newWindow.document.write(newWindCodHead);
        newWindow.document.write(chngInstrFormHTML);
        newWindow.document.write("</body></html>");
        newWindow.document.close();
        }

    if (MasterInstr[cN].length == 3) {
        iNum = (iNum == 1) ? 2 : 1;
        wrapUp(cN, iNum);
        }
    }

function changeInstrClose(instrNum) {
    iNum = instrNum;
    newWindow.close();
    wrapUp(cNum, iNum);
    }

/*********************************************************************************/

/*********************************************************************************/
/*********************   Create a declaration popup window   *********************/
/********************************   Old version   ********************************

function buildPage(cN) {
	alert("buildPage(cN) is an outdated function - remove it);
    courseNum = cN
    getInstr(cN)

    if (MasterInstr[cN].length > 3) {
        declareWin = window.open(declInstrHtml, "declare", winStats)
        }

    if (MasterInstr[cN].length == 3) {
        iNum = (iNum == 1) ? 2 : 1;
        wrapUp(cN, iNum);
        }
    }
    
*********************************************************************************/

function wrapUp(cNum, iNum) {
    cookieVal = (CookiesOBJ.getCookie(cookie3) == null) ? "" : CookiesOBJ.getCookie(cookie3);

    for (x = 0; x < cookieVal.length; x = x + 2) {
        courseArray[cookieVal.charAt(x)] = cookieVal.charAt(x + 1);
        }

    courseArray[cNum] = iNum;
    cookieVal = "";

    for (x = 0; x < courseArray.length; x++) {
        if (courseArray[x] > 0) {
            cookieVal += x + "" + courseArray[x];
            }
        }

    CookiesOBJ.setCookie(cookie3, cookieVal, expires);
    window.location.reload();

    if (!syllPage) {
        moveOn(cNum);
        }
    }

function moveOn(cN2) {
    iNum = (iNum > 0) ? iNum : courseArray[cN2];
    tmpPage = (iNum > 0) ? MasterInstr[cN2][iNum].page : MasterInstr[cN2][1].page;

    tmp = (tmpPage.indexOf("http") >= 0) ? tmpPage : dirs[cN2] + tmpPage;

    if (declareWin) {
        declareWin.close()
        opener.location.href = tmp;
        }

    location.href = tmp;
    }
/*********************************************************************************/

function readInstr() {
    /*****************************************************************************/
    /**********************  Try to read instructor cookie  **********************/

    if (CookiesOBJ.getCookie(cookie3) == null) {
        courseArray[0] = 0;
        } else {
        cookieVal = CookiesOBJ.getCookie(cookie3);

        for (x = 0; x < cookieVal.length; x = x + 2) {
            courseArray[cookieVal.charAt(x)] = cookieVal.charAt(x + 1);

            if (cookieVal.charAt(x) == cNum) {
                iNum = cookieVal.charAt(x + 1);
                }
            }

        /*************   If the instructor hasn't been declared yet   ************/
        if (courseArray[cNum] < 1) {
            buildPage(cNum);

            /*************   Set Cookie with this instructor number   ************/
            cookieVal = "";
            courseArray[cNum] = iNum;

            for (x = 0; x < courseArray.length; x++) {
                if (courseArray[x] > 0) {
                    cookieVal += x + "" + courseArray[x];
                    }
                }

            CookiesOBJ.setCookie(cookie3, cookieVal, expires);
            }
        }
    }

/*********************************************************************************/

/*********************************************************************************/
/************   Function to start calculation of date after one week   ***********/

function weeksTime(cDay) {
    shortSem = MasterInstr[cNum][iNum].iShortSem;

    cDay += (twoWeeks) ? 1 : 0;

    wkInMs = firstDay.getTime();
    /** 	Normally, the formula to compute the number of ms in a week is
            wkInMs += 60000 * 60 * 24 * 7 * (cDay -1)
            However, to balance for some servers using standard time vs. DST,
            we adjust the formula slightly. **/
    if (!shortSem) {
        wkInMs += 60100 * 60 * 24 * 7 * (cDay - 1); //		Balanced for CST switch
        }                                           //		Class meets once a week

    if (shortSem) {                                 //      Balanced for CST switch
        var numDays = parseInt(((cDay - 1) * 7) + (cDay) % 2) - 1;
        var numDaysMod = numDays % 7;
        numDays = (numDaysMod > 3) ? numDays + (7 - numDaysMod) : numDays - (numDaysMod);
        wkInMs += 60100 * 60 * 24 * numDays;
        }

    return wkInMs
    }

/*********************************************************************************/
/**
 * Add a "0" in front of single digit numbers
 * @param vNumber a single digit number
 * @return If the number was less than 10, it is returned with a leading "0"
 */

function addZero(vNumber) {
    return ((vNumber < 10) ? "0" : "") + vNumber
    }

/*********************************************************************************/
/**
 * Format a date to one of many date formats
 * <p>
 * [Write an explanation here of the various format possibilities ]<br />
 * dd for Date of the month, (currently set for no leading zero)<br />
 * DD for Day name<br />
 * MM for month number,
 * Mon3 for 3 char month,
 * MonFull for full month name,<br />
 * yy or yyyy for Year,<br />
 * hh for hours,
 * mm for minutes,
 * ss for seconds
 * @param vDate the date to be formatted
 * @param vFormat how the date should be formatted
 * @return String of the desired date in the chosen format.
 */

function formatDate(vDate, vFormat) {
    var vDateString = "";
    var vDayName = vDate.getDay();
    vDayName = (vDayName > 6) ? dayNames[vDayName] : dayNames[vDayName + 7];
    var vDay0 = addZero(vDate.getDate());
    var vDay = vDate.getDate();
    var vMonNum = addZero(vDate.getMonth() + 1);
    var vMon = mos[vDate.getMonth()];
    var vMonth = months[vDate.getMonth()];
    var vYearLong = addZero(vDate.getFullYear());
    var vYearShort = addZero(vDate.getFullYear().toString().substring(3,4));
    var vYear = (vFormat.indexOf("yyyy") > -1 ? vYearLong : vYearShort)
    var vHour = addZero(vDate.getHours());
    var vMinute = addZero(vDate.getMinutes());
    var vSecond = addZero(vDate.getSeconds());
    var vTimeOffset = vDate.getTimezoneOffset()/60 + ":00"; 
    if (vFormat == "iCal") {
        vDateString = vYearLong + "-" + vMonNum + "-" + vDay0;
        vDateString += "T" + vHour + ":" + vMinute;
        //vDateString += "-" + vTimeOffset;
        } else {
        vDateString = vFormat.replace(/dd/g,vDay).replace(/MM/g,vMonNum).replace(/y{1,4}/g,vYear)
        vDateString = vDateString.replace(/hh/g,vHour).replace(/mm/g,vMinute).replace(/ss/g,vSecond).replace(/Mon3/g,vMon).replace(/MonFull/g,vMonth)
        vDateString = vDateString.replace(/DD/g, vDayName)
        }
    return vDateString
    }

/******************   Build the Course name String for events   ******************/
function hCalStr() {
    var hClassStr = CCIS[cNum].cDesc;
    if (CCIS[cNum].cDesc.indexOf("ced H") > 0) {
        hClassStr = "Advanced-HTML";
        }
    if (CCIS[cNum].cDesc.indexOf("Scri") > 0) {
        hClassStr = "JavaScript";
        }
        return hClassStr;
    }

/*********************************************************************************/
/******   Function to calculate and build the header on Class Notes pages   ******/

function customInstr(cCI, iCI) {
    //headCI = ;
    headCI = buildVcard ("INSTRUCTOR: ", " noShow");
    //headCI += MasterInstr[cCI][iCI].name;
    //headCI += "<br /></span><span style=\"font-size: 60%;\">";
    //headCI += "<a href=\"./Common/emailPage.html\" rel=\"external\">";
    //headCI += MasterInstr[cCI][iCI].email;
    //headCI += "</a>";
    return headCI
    }

/*********************************************************************************/
/**************   Function to calculate semester weekly dates and   **************/
/****************   build the header used on the syllabus pages   ****************/

function customDateString(chapters, cCDS, iCDS) {
    var classWeek = document.title.substring(document.title.indexOf('ss') + 3, document.title.length);
    firstDay.setTime(weeksTime(classWeek));

    /**************************   Add in the chapters   **************************/
    if (chapters.length > 0) {
        header += chapters;
        }

    /***********************   Finish building the header   **********************/
    header += customInstr(cCDS, iCDS);
    return header;
    }

/*********************************************************************************/
/****   Part of building the window to select which class on the first page   ****/
function getInstr(courseNum) {
    for (x = 1; x < MasterInstr[courseNum].length; x++) {
        InstrButton[x] = MasterInstr[courseNum][x].clDay + " - " + MasterInstr[courseNum][x].name;
        }

    InstrButton[0] = MasterInstr[courseNum][0].name;
    }

/*********************************************************************************/
/*************   Function to calculate weekly dates on the Syllabus   ************/

var cwAdj = 0;

function syllabusDates(classWeek, classNum, ref) {
    quizToday = false;
    var sDay = new Date();
    cW = classWeek;
    cW = cW + cwAdj;

    if (MasterInstr[cNum][iNum].blended && classWeek == noClass[nc]) {
        cW++;
        cwAdj = cwAdj + (classNum % 2);
        nc++;


        /**********  Adjust if there are two 'No Class' days in a row  ***********/
        if (noClass[nc] - 1 == noClass[nc - 1]) {
            cW++;
            cwAdj = cwAdj + (classNum % 2);
            nc++;
            }
        }

    /*   Move the class date up one week due to oddity in schedule.   */
    if (MasterInstr[cNum][iNum].blended && classWeek == -noClass[nc]) {
        cW--;
        cwAdj = cwAdj - (classNum % 2);
        nc++;
        }
    /*              Above is to move the class date up one week       */

    if (MasterInstr[cNum][iNum].blended && (classNum % 2 === 0)) {
        cW--;
        }

    sDay.setTime(weeksTime(cW));

    ssDay = new Date((sDay.getMonth() + 1) + "/" + sDay.getDate() + "/" + sDay.getFullYear());
    satDay = new Date(ssDay - ((ssDay.getDay() + 1) * 24 * 60 * 60 * 1000));

    showIt = (ssDay - prePost < nowDay) ? true : false;
    showItHw = (ssDay - prePostHw < nowDay) ? true : false;

    /*************   Turn on the last homework link one week early   *************/
    if (hw + 1 == MasterInstr[cNum][iNum].hwClass.length && ssDay - prePostHw - (60000 * 60 * 24 * 14) < nowDay) {
        showItHw = true;
        }

    /********   Between semesters, turn on a couple of weeks as examples   *******
            if (classWeek == 1 || classWeek == 24) {
                    showIt = true;
	    			showItHw = true;
                    }
    ******************************************************************************/

    /*****************************************************************************/
    /*************   Turn on all links to notes for the instructors   ************
            showIt = true;
    ******************************************************************************/

    /*************   Turn on all links to notes for one instructor   *************
            if (cNum == 1 && iNum == 2) {
                    showIt = true;
                    showItHw = true;
                    }
    *****************************************************************************/

    /*****************************************************************************/
    /*************   Turn on all links to notes for just one class   *************
            switch(cNum){
                    case 2: showIt = true;
                            showItHw = true;
                    case 4: showIt = true;
                            showItHw = true;
                    }
    ******************************************************************************/

    classNum = (classNum <= 9 && cW != noClass[nc]) ? "0" + classNum : classNum;
    clDesc = (shortSem || MasterInstr[cNum][iNum].blended) ? "Class " : "Week ";

    if (MasterInstr[cNum][iNum].online) {
        clDesc = "Unit ";
        showIt = true;
        showItHw = true;
        prePostHw = linkActive(180);    //  When the Homework links become active
        //showIt = false;								//	Turn off all links during week before class starts
        //showItHw = false;							//	Turn off all links during week before class starts
        }

    if (ref != 0 && showIt && cW != noClass[nc]) {
        ref1 = csRef + "Notes" + classNum;

        switch (cNum) {
            case 1: exten = ".html"; break;
            case 2: exten = ".html"; break;
            case 3: exten = ".html"; break;
            case 4: exten = ".html"; break;
            case 5: exten = ".html"; break;
            case 6: exten = ".html"; break;
            //case 6: if (cW > 1) {exten = ".mht";} else {exten = ".html";} break;
            case 7: exten = ".pdf"; break;
            case 8: exten = ".html"; break;
            }
        ref1 += exten + "' target=\"_blank\">";
        } else {
        ref1 = "";
        }

    ref2 = (ref == 0 || !showIt) ? "" : "</a>";

    classWeekStr = "<h5 class=\"eighty\">" + ref1 + clDesc + ordinals[(classWeek - 1)] + ref2 + "</h5>";

    if (MasterInstr[cNum][iNum].clNum > 0) {
        classWeekStr += "<span class='justCentr, eighty'>" + (sDay.getMonth() + 1);
        classWeekStr += "/" + sDay.getDate();

        if (twoTimes) {
            var ttDay = new Date((60100 * 60 * 24 * dNum) + sDay.getTime());
            classWeekStr += ", " + ttDay.getDate();
            }

        classWeekStr += "/" + sDay.getFullYear();
        classWeekStr += (cW != noClass[nc]) ? newAsOf(ref) : "";
        classWeekStr += "</span>";
        }

        var breakLine = "";

/**   Use parseFloat because parseInt can sometimes return an incorrect value.   */
/******************   Example: classNum = "08"   *********************************/
/*********************   parseInt(classNum) returned "0"     *********************/
/*********************   parseFloat(classNum) returned "8"   *********************/

    if (cW == noClass[nc] - 20) {
        nextAssn++;
        nc++;
        }

/***   Use the noClass array to post the notice and move on to the next week   ***/

    if (MasterInstr[cNum][iNum].clNum > 0 && !MasterInstr[cNum][iNum].blended && cW == noClass[nc]) {
        classWeekStr = classWeekStr + "</div><div class=\"boxRight2\"><h5>No Class</h5></div>";
        classWeekStr += "<div class=\"space-line\">&nbsp;</div></div><div class=\"box\">";
        classWeekStr += "<div class=\"boxLeft\">";

        if (noClass[nc] + 1 == noClass[nc + 1]) {
            classWeekStr += syllabusDates(yy++, classNum, ref);
            classWeekStr += "</div><div class=\"boxRight2\"><h5>No Class</h5></div>";
            classWeekStr += "<div class=\"space-line\">&nbsp;</div></div><div class=\"box\">";
            classWeekStr += "<div class=\"boxLeft\">";
            }
        classWeekStr += syllabusDates(yy++, classNum, ref);
        nc++;
        }
        
        hcalendarStr = hCalStr();
        classEventDay = new Date(sDay.getTime());
        classEventDay.setHours(startHour,00);
        
        classEv = new Array();    
        classEv[0] = "\n<div class=\"vevent noShow\" id=\"hcalendar-" + hcalendarStr + "-Class" + classWeek + "\">";        
        classEv[1] = "<a href=\"" + dirs[cNum] + "\" class=\"url\">";        
        classEv[2] = "<abbr title=\"" + formatDate(classEventDay, "iCal") + "\" class=\"dtstart\">";
        classEv[3] = formatDate(classEventDay, "MonFull dd hh:mm") + "</abbr> to ";
        classEventDay.setHours(endHour,50);
        classEv[4] = "<abbr title=\"" + formatDate(classEventDay, "iCal") + "\" class=\"dtend\">";
        classEv[5] = formatDate(classEventDay, "MonFull dd hh:mm") + "</abbr> ";
        classEv[6] = "<span class=\"summary\">" + CCIS[cNum].cDesc + " Class " + ordinals[(classWeek - 1)] + "</span></a>";
        classEv[7] = "<div class=\"description\">Read the Class " + ordinals[(classWeek - 1)] + " Notes</div></div>";
        
        if (MasterInstr[cNum][iNum].blended && (classNum % 2 === 1)) {
            classEv[7] = "<div class=\"description\">Read the Class " + ordinals[(classWeek - 1)];
            classEv[7] +=  " and " + ordinals[(classWeek)] + " Notes</div></div>";
            }

        if (hmidSemBreak.length > 6) {
            classEv[7] = "<div class=\"description\">" + hmidSemBreak + "</div></div>";
            hmidSemBreak = "";
            }
        
        classEvent = "";
        for (i = 0; i < classEv.length; i++) {
            classEvent += classEv[i];
            }

        if ((MasterInstr[cNum][iNum].blended && (classNum % 2 === 0)) || MasterInstr[cNum][iNum].online || classWeekStr.indexOf("No Class") > 0) {
            //  cW - 1 == noClass[nc - 1] || 
            classEvent = "";
        }
        
    classWeekStr = classEvent + classWeekStr;    

    return classWeekStr;
    }

function setPrePost(){
    var prePostArray = new Array();
    for (i=0; i < setPrePost.arguments.length; i++){
        prePostArray[i] = setPrePost.arguments[i];
        }

    if (MasterInstr[cNum][iNum].blended) {
        prePost = prePostArray[0];
        prePostHw = linkActive(prePostArray[1]);    //  When the Homework links become active in a blended class        
        //prePost = linkActive(0.5);                //  Turn off all links during week before class starts     
        //prePostHw = linkActive(0.5);              //  Turn off all links during week before class starts
        }
      }
/*********************************************************************************/
/*****************   Function to calculate semester values and   *****************/
/****************   build the header used on the syllabus pages   ****************/
/*************************   The result looks like this   ************************/
/****   CCIS 2591 Tutorial Notes                                  JavaScript   ***/
/****   Monday - Spring, 2012                        INSTRUCTOR: Alan Kelsey   ***/
/****                               instructor@JavaScriptTutorialOnline.info   ***/
/*********************************************************************************/

function customSemester(cN3, iN3) {
    var classSem = dayNames[firstDay.getDay()];

    //		List two days, if necessary
    if (twoTimes) {
        classSem += " &amp; " + dayNames[firstDay.getDay() + dNum];
        }

    //		Choose the season
    if (firstDay.getMonth() <= 3) {
        classSem += " - Spring";
        } else {
        if (firstDay.getMonth() <= 6) {
            classSem += " - Summer";
            } else {
            classSem += " - Fall";
            }
        }

    //		Start building the header
    header = "<div class=\"headLeft\">";

    //		Add in the CCIS number
    header += "<h3>" + CCIS[cNum].CCIS + " Tutorial Notes<br />";

    //		Add in the day, season, and year
    classSem += ", " + firstDay.getFullYear();
    header += "<span style=\"font-size: 75%;\">" + classSem + "</span></h3></div>";
    header += "<div class=\"headRight\"><h3>";

    //		Add in the CCIS description (top row, right)
    header += CCIS[cNum].cDesc + "<br />";

    //		Add the instructor's name and email
    header += "<span style=\"font-size: 75%;\">";
    header += customInstr(cN3, iN3) + "</span></h3></div>";
    
    //  Build the main heading for the page
    mainHeading = "<h2>" + CCIS[cNum].cDesc + " Class Schedule</h2>";
    return header;
    }

/*********************************************************************************/
/**
 * Build the actual Homework/Lab link or just text
 * @param hwRef1
 * @param hwRef2
 * @param hwRef3
 * @return If the number was less than 10, it is returned with a leading "0"
 */

function adjDay() {
    //	Add in one day for Monday or subtract for Friday if online
    //var dayAdj = (MasterInstr[cNum][iNum].online) ? -2 : 1;
    var dayAdj = 0;
    dayAdj = 24 * 60 * 60 * 1000 * dayAdj;
    return dayAdj;
    }

function hwAssgn(hwRef1, hwRef2, hwRef3) {
    hwRef2a = CCIS[cNum].cPre + "lab0";
    hwRef2b = "Lab 0";
    hwRef2c = "";
    hwRef3a = "";

    if (hwRef2 == 1 || hwRef2 == 2) {
        //		It's a homework, not a lab
        hwRef2a = CCIS[cNum].cPre + "hw0";
        hwRef2b = "HW #";
        //if (cNum == 4) {hwRef2b = "Program #";}
        }

    //		If there's been a change, display the 'New' graphic
    if (hwRef2 == 2 || hwRef2 == 3) {
        //hwRef2c = "<img src='../images/updated.gif' height=10 width=30>";
        }

    //		Add a new line if there's also a quiz
    if (hwRef3 == 1) {
        hwRef3a = "<br />";
        }

    hwEvent = "";
    if (hwRef2b == "HW #" && !MasterInstr[cNum][iNum].online) {

        hwDueDt = MasterInstr[cNum][iNum].hwWeek[hwRef1-1] + 1;
        hwDueDt += ((MasterInstr[cNum][iNum].hwDay - MasterInstr[cNum][iNum].clNum) / 7);
        hwDueDate = new Date(weeksTime(hwDueDt));
        hwDueDate.setHours(23);
        hwDueDate.setMinutes(59); 
        
        hcalendarStr = hCalStr();
               
        hwEvent = "\n<div class=\"vevent noShow\" id=\"hcalendar-" + hcalendarStr + "-HW" + hwRef1 + "\">";        
        hwEvent += "<abbr title=\"" + formatDate(hwDueDate, "iCal") + "\" class=\"dtstart\">";
        hwEvent += formatDate(hwDueDate, "MonFull dd hh:mm") + "</abbr>";
        hwEvent += "<span class=\"summary\">" + CCIS[cNum].cDesc + " HW #" + hwRef1 + " Due</span></div>";
        
    }
        
    hwStrAssgn = hwEvent + hwRef3a;    

    var hwRefShortSem = "";
    if (shortSem && cNum != 4 && showItHw) {
        with (MasterInstr[cNum][iNum]) {
            while (labWeek[labNum] < zz && labNum < labWeek.length - 1) {
                addLabs = "<a href=\"" + CCIS[cNum].cPre + "lab0" + (labNum + 1);
                addLabs += ".html\" target=\"_blank\">" + "Lab" + (labNum + 1) + "</a>";
                hwRefShortSem += addLabs + "<br />";
                labNum++;
                }
            }
        }
    hwStrAssgn += hwRefShortSem;
    closeA = "";

    //		Make it a link at the right time

    if (showItHw) {
        hwStrAssgn += "<a href='" + hwRef2a + hwRef1 + ".html' target='_blank'>";
        closeA = "</a>";
        }

    //		Finish the assembly
    hwStrAssgn += hwRef2b + hwRef1 + closeA + hwRef2c;
    hwStrAssgn = (quizToday) ? "<br />" + hwStrAssgn : "<h5 class=\"eighty\">" + hwStrAssgn;
    dueDate.setTime(weeksTime(nextAssn++) + adjDay());
    hwStrAssgn += (MasterInstr[cNum][iNum].online)
                    ? "<br /><span class=\"sixty\">" + formatDate(dueDate, "MonFull dd, yyyy") + "</span>"
                    : ""
          
    hwStrAssgn += "</h5>";
    
    return hwStrAssgn;
    }

/* ********************************************************************************/
/* ************************   Function to determine if a   ************************/
/* *******************   homework link, lab link, or no link   ********************/
/* ********************   should be displayed on a given day   ********************/
/* ********************************************************************************/
/**
 * Determines if a homework link, lab link, or no link should be displayed on a given day
 * @param assignByClass boolean to differentiate between assignments set by class number (true) or by week number (false)
 * @return String - html code, either a link or just text
 */
function work(assignByClass) {
    workToday = -1;
    assgnToday = -1;
    assignByClass = (work.arguments.length < 1) ? false : assignByClass;

    with (MasterInstr[cNum][iNum]) {
        if (assignByClass) {
            if (hwClass[hw - 1] == (zz - 1)) {
                assgnToday = hw++;
                workToday = 1;
                }

            if (labClass[lb - 1] == (zz - 1) && !shortSem) {
                assgnToday = lb++;
                workToday = 0;
                }
            } else {
            if (hwWeek[hw - 1] == (yy - 1)) {
                assgnToday = hw++;
                workToday = 1;
                }

            if (labWeek[lb - 1] == (yy - 1) && !shortSem) {
                assgnToday = lb++;
                workToday = 0;
                }
            }
        }

    tasks = (workToday > -1) ? hwAssgn(assgnToday, workToday, 0) : "</h5>";
    return tasks;
    }


/******************   Function to calculate homework due date   ******************/
function hwDue(hDue) {
    hintsPosted = "Hints:";
    labHintsPosted = "";
    firstDay.setTime(weeksTime(hDue));

    var dueDay = "";
    var hwNum2 = document.title.charAt(document.title.length - 1);
    /*
    if (hwNum2 == MasterInstr[cNum][iNum].hwWeek.length - 1) {
        firstDay.setDate(expires.getDate()-7);
        }
    */

    timeToHints = 1;    //  Set the lab solution to appear 1 day later

    /**********************   firstDay is always a Sunday   **********************/
    /*****   Take 7 (one week), subtract the day of the week of the class,    ****/
    /********   then subtract how many days to wait for the lab solution   *******/
    labDay.setTime(firstDay.getTime() - 60000 * 60 * 24 * (7 + MasterInstr[cNum][iNum].hwDay - MasterInstr[cNum][iNum].clNum - timeToHints));

    timeToHints = 7;    //  Set the Homework hints to appear 7 days later

    secondDay.setTime(firstDay.getTime() + 60000 * 60 * 24 * timeToHints);
    hintsDay.setTime(firstDay.getTime() + 60000 * 60 * 24 * 1.5);
    /******************   Is it time to post the lab solution?   *****************/

    if (labDay < nowDay || MasterInstr[cNum][iNum].online) {
        labHintsPosted = "<a href=\"" + keyHTML;
        labHintsPosted += "\">Here's one way to do this assignment.</a>";
        }

    /*****************   Is it time to post the homework hints?   ****************/
    if (hintsDay < nowDay && !MasterInstr[cNum][iNum].online) {
        hintsPosted = "<a href=\"" + keyHTML + "\">Hints:</a>";
        }
    if (MasterInstr[cNum][iNum].online) {
        firstDay = new Date(startYr, startMo, startDy);
        var dayNum = hDue + 1;

        dueDate.setTime(weeksTime(dayNum) + adjDay());
        dueDay = "<p>Two extra credit points will be added to your score ";
        dueDay += "if you submit this assignment <strong>before</strong></p><h4>";
        dueDay += formatDate(dueDate, "MonFull dd");
        dueDay += "</h4>";
        } else {
        dueDay = "<h4>Due: ";
        dueDay += formatDate(firstDay, "MonFull dd");
        if (hwNum2 != MasterInstr[cNum][iNum].hwWeek.length - 1) {
            dueDay += "</h4><p>The last day this assignment will be accepted is ";
            dueDay += formatDate(secondDay, "MonFull dd");
            dueDay += "</p>";
            } else {
            dueDay += "</h4>";
            }
        }

    return dueDay;
    }
/*********************************************************************************/

/*********************************************************************************/
/*********************   Function to deliver an online Quiz   ********************/

function quizLink() {
    if ((zz - 1) != makeQuizWeek[mq] || !showQuiz) {
        return "";
        }

    with (makeQuiz[mq]) {
        if (quizDate > 0) {
            quizToday = true;
            quizNum++;
            } else {
            return "";
            }

        if (quizDate == 6) {
            quizDate = satDay;
            //quizDate = nowDay;		//		This turns on all of the Quiz links
            }

        if (quizDate == 12) {
            sat2Day = new Date(satDay - (2 * 24 * 60 * 60 * 1000));
            quizDate = sat2Day;
            //quizDate = nowDay;		//		This turns on all of the Quiz links
            }

        /***********   Turn on all the quiz links if this is an online course   **********/
        quizDate = (MasterInstr[cNum][iNum].online) ? nowDay : quizDate;
        quizDate = (cNum ===5) ? nowDay : quizDate;
        quizDate = (quizNum == 0) ? nowDay : quizDate;    // take out after week 2

        /*********************************************************************************/
        
        /************************   Turn on one quiz for one course   ********************/
        quizDate = (cNum == 3 && quizNum == 2) ? nowDay : quizDate;

        /*********************************************************************************/
        
        /***********   Turn off all the quiz links if this is an online course   *********/
        /*
        sat2Day = new Date(nowDay + (20 * 24 * 60 * 60 * 1000));
        quizDate = (MasterInstr[cNum][iNum].online) ? sat2Day : quizDate;
        */
        /*********************************************************************************/

        var hour12 = 12 * 60 * 60 * 1000; //  12 hours
        var quizText = "Quiz #" + quizNum;

        /*********************************************************************************/

        var quizHTML = quizText;

        if (quizOnline) {
            quizOffDay = new Date(((quizOn * hour12 * 2) - .1) + quizDate.getTime());
            quizOffWarn = quizOffDay + "";

            if (quizOffWarn.indexOf("GMT") > 1) {
                quizOffWarn = quizOffWarn.substring(0, quizOffWarn.indexOf("GMT") - 1);
                }

            if (quizOffWarn.indexOf("ST") > 1) {
                quizOffWarn = quizOffWarn.substring(0, quizOffWarn.indexOf("ST") - 2);
                }

            timeAvail = (zz == 2) ? "thirty minutes" : "two hours";

            confirmText = "confirm('Once you begin, ";
            confirmText += "you will have " + timeAvail + " to complete this quiz.\\n";
            confirmText += "Do NOT click OK unless you are ready to finish the ";
            confirmText += "quiz in the next " + timeAvail + "!\\nDo you want to proceed?\\n";
            confirmText += (MasterInstr[cNum][iNum].online) ? "')" : "[This link will be active only until " + quizOffWarn + "]')";

            linkFirstPart = "<a href=\"javascript:void(0)\" onclick=\"if (";
            linkFirstPart += confirmText + "){ quizWin = window.open('";
            linkSecondPart = "', 'quizWinName')} else {return false;}\">";

            if (quizDate <= nowDay && nowDay <= quizOffDay) {
                quizHTML = linkFirstPart;
                quizHTML += quizLocation;
                quizHTML += quizURL;
                quizHTML += linkSecondPart;
                quizHTML += quizText + "</a>";
                }
        
            hcalendarStr = hCalStr();

            satDay.setHours(01,00,00);   
            quizEvent = "\n<div class=\"vevent noShow\" id=\"hcalendar-" + hcalendarStr + "-Quiz" + quizNum + "\">";
            quizEvent += "<abbr class=\"dtstart\" title=\"" + formatDate(satDay, "iCal") + "\">";
            quizEvent += formatDate(satDay, "MonFull dd hh:mm") + "</abbr> to ";
            quizEvent += "<abbr title=\"" + formatDate(quizOffDay, "iCal") + "\" class=\"dtend\">";
            quizEvent += formatDate(quizOffDay, "MonFull dd hh:mm") + "</abbr> : ";
            quizEvent += "<span class=\"summary\">" + CCIS[cNum].cDesc + " Quiz #" + quizNum + "</span>";
            quizEvent += "</div>";
            quizEvent = (quizNum === 0 || MasterInstr[cNum][iNum].online) ? "" : quizEvent;
            }

        if (!quizOnline) {
            quizOffDay = new Date(((quizOn * hour12 * 2) - .1) + quizDate.getTime());
            quizOffWarn = quizOffDay + "";

            /**************   Set a special day to turn off Java Quiz 4   ****************
            if (cNum == 4 && quizNum == 4) {
                quizOffDay = new Date(2006, 3, 27)
                }
            *****************************************************************************/

            if (quizOffWarn.indexOf("GMT") > 1) {
                quizOffWarn = quizOffWarn.substring(0, quizOffWarn.indexOf("GMT") - 1);
                }

            if (quizOffWarn.indexOf("ST") > 1) {
                quizOffWarn = quizOffWarn.substring(0, quizOffWarn.indexOf("ST") - 2);
                }

            confirmText = "confirm('This is a take-home quiz. ";
            confirmText += "You need to print it out, complete it,\\n";
            confirmText += "and get it back to me by the date it is due.\\n";
            confirmText += "It is due at the beginning of class on that date.\\n";
            confirmText += "If you cannot make it to class that day, you will need ";
            confirmText += "to find another method to get it to me by that time.\\n";
            confirmText += "[This link will be active only until " + quizOffWarn + "]')"

            linkFirstPart = "<a href=\"javascript:void(0)\" onclick=\"if ("
            linkFirstPart += confirmText + "){ quizWin = window.open('"
            linkSecondPart = "', 'quizWinName')} else {return false;}\">"

            if (quizDate <= nowDay && nowDay <= quizOffDay) {
                quizHTML = linkFirstPart;
                quizHTML += quizPDFLocation;
                quizHTML += quizURL;
                quizHTML += linkSecondPart;
                quizHTML += quizText + "</a>";
                }
            }
        }
    quizHTML = quizEvent + "<h5 class=\"eighty\">" + quizHTML;
    mq++;
    return quizHTML;
    }

/*********************************************************************************/
/**
 * Enables a special quiz link for make up quizzes
 * @param forWhom (string) the name of the student taking the quiz
 * @param quizNo (integer) which quiz they want to make up
 * @return String - html code for the link
 */
function specialQuiz(forWhom, quizNo) {
    var forClass1, forClass2;

    switch (cNum) {
        case (1):
            forClass1 = "HTML";
            forClass2 = "html";
            break;

        case (2):
            forClass1 = "HTMLAdv";
            forClass2 = "htmladv";
            break;

        case (3):
            forClass1 = "JavaScript";
            forClass2 = "javascript";
            break;

        case (4):
            forClass1 = "Java";
            forClass2 = "java";
            break;

        case (5):
            forClass1 = "XML";
            forClass2 = "xml";
            break;

        case (6):
            forClass1 = "Ajax";
            forClass2 = "ajax";
            break;
        }


/**********************   Global variables for this class   **********************/
/*********************************************************************************/
/*****************   The variable cNum sets the specific course   *****************
1 -     HTML
2 -     Advanced HTML
3 -     JavaScript
4 -     Java
5 -     XML
6 -     AJAX
7 -     [extra spot]
8 -     [extra spot]
9 -     admin
**********************************************************************************/
    if (specialQuiz.arguments.length < 2) {
        quizNo = 1;
        }

    var quizSpecial = "quizTest" + forClass1 + ".cgi?" + forClass2 + "quiz" + quizNo

    var quizSpecialLink = "<a href=\"" + quizLocation + quizSpecial + "\">Special quiz for ";
    quizSpecialLink += forWhom
    quizSpecialLink += "</a>"

    return quizSpecialLink;
    }

/*********************************************************************************/
/**************   Store the cookie that keeps track of the visits   **************/

function visits() {
    var lastStoredVisit = CookiesOBJ.getCookie(cookie1)
    var nextPrevStoredVisit = CookiesOBJ.getCookie(cookie2)
    adjustDate()

    if (lastStoredVisit == null || lastStoredVisit == "") { // never been here before
        saveCurrentVisit()
        repeatCustomer = false
        } else {              // been here before...
        if (nextPrevStoredVisit == null
            || nextPrevStoredVisit == "")
            {                 // but first time this session
            CookiesOBJ.setCookie(cookie2, lastStoredVisit,
                      nowDay) // only for current session
            lastVisit = parseFloat(lastStoredVisit)
            saveCurrentVisit()
            repeatCustomer = true
            } else
            { // back again during this session (perhaps reload or Back)
            lastVisit = parseFloat(nextPrevStoredVisit)
            repeatCustomer = true
            }
        }
    }

/*********************************************************************************/
/**************   Function to display 'NEW' graphic appropriately   **************/

function newAsOf(authorDate) {
    authorDate = new Date(authorDate)
    var authorZoneOffset = 210
    var base = new Date()
    var localZoneOffset = base.getTimezoneOffset()
    var netOffset = authorZoneOffset - localZoneOffset
    var itemUpdated = authorDate.getTime() - dateAdjustment + (netOffset * 60000)
    return ((itemUpdated > lastVisit) && repeatCustomer && showIt)
        ? "<img src=\"" + commonFolder + "images/updated.gif\" height=\"10\" width=\"30\">" : ""
    }

/*****************************   Set dateAdjustment   ****************************/
/******************   to accommodate Mac bug in Navigator 2.0x   *****************/

function adjustDate() {
    var base = new Date()
    var testDate = base
    testDate = testDate.toLocaleString()
    testDate = new Date(testDate)
    dateAdjustment = testDate.getTime() - base.getTime()
    }

/************   Write date of current visit (in GMT time) to cookie   ************/

function saveCurrentVisit() {
    var visitDate = new Date()
    var nowGMT = visitDate.getTime() - dateAdjustment
    //expires = new Date(expires)
    //expires = expires.toGMTString()
    CookiesOBJ.setCookie(cookie1, nowGMT, expires)
    }
/*********************************************************************************/

/*********************************************************************************/
/********************   JavaScript Cookie Object and Methods   *******************/
/*********************************************************************************/
function CookieHandler() {
    /*   SetCookie (myCookieVar, cookieValueVar, null, "/myPath", null, true);   */
    this.setCookie = function(name, value, expr, path, domain, secure) {
        document.cookie = name + "=" + escape(value) + ((expr) ? "; expires=" + expr.toGMTString() : "")
            + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : "");
        }

    /*****   Function to return the value of the cookie specified by "name".   ***/
    /*****       name - String object containing the cookie name.      ***********/
    /*****       returns - String object containing the cookie value,  ***********/
    /*****       or null if the cookie does not exist.                 ***********/
    this.getCookie = function(name) {
        name += "=";
        var carray = document.cookie.split(';');

        for (var i = 0; i < carray.length; i++) {
            var c = carray[i];

            while (c.charAt(0) == ' ')
                {
                c = c.substring(1, c.length);
                }

            if (c.indexOf(name) == 0)
                {
                return unescape(c.substring(name.length, c.length));
                }
            }
        return null;
        }

    //  Function to delete a cookie. (Sets expiration date to start of epoch)
    //    name -   String object containing the cookie name
    //    path -   String object containing the path of the cookie to delete.  This MUST
    //             be the same as the path used to create the cookie, or null/omitted if
    //             no path was specified when creating the cookie.
    //    domain - String object containing the domain of the cookie to delete.  This MUST
    //             be the same as the domain used to create the cookie, or null/omitted if
    //             no domain was specified when creating the cookie.
    //
    this.deleteCookie = function(name, path, domain) {
        var expr = new Date("0/0/0");
        var value = null;
        var path = (path) ? "; path=" + path : "";
        var domain = (domain) ? "; domain=" + domain : "";
        this.setCookie(name, value, expr, path, domain);
        }
    }

/*     Examples
var CookiesOBJ = new CookieHandler();
var cookieName1 = "someName";
*/
/*     To set a cookie, use
var expDate = new Date("12/30/2009");
CookiesOBJ.setCookie(cookieName1, cookieVal, expDate); 
*/
/*     To get a cookie, use
var cookieVal = CookiesOBJ.getCookie(cookieName);
if (cookeVal == null) {
    alert("null");
    //  place code in here to return a default value
    }
*/
/*     To delete a cookie, use
CookiesOBJ.deleteCookie(cookieName1);
*/

/*********************************************************************************/
/*************   The following lines and those several lines lower   *************/
/**************   are used to keep my email address from spambots   **************/

var emailByJS1 = "<a hr";
var emailByJS2_1 = "nCM";
var emailByJS2_1a = "n@";
var emailByJS3_1 = "<a class=\"email\" hr";
var emailByJS2_2 = "ne.i";
var emailByJS3 = "lto:ala";
var emailByJS3_3 = "n/emailPage.ht";
var emailByJS9 = "me.com</a><br />";
var emailByJS2_3 = "ials";
var emailByJS4 = "n@rar";
var emailByJS2_4 = "Ala";
var emailByJS3_4 = "ml\" rel=\"e";
var emailByJS6 = "om\">Alan Kelse";
var emailByJS2_5 = "nfo";
var emailByJS2 = "ef=\"mai";
var emailByJS3_2 = "ef=\"./Commo";
var emailByJS3_2b = "ef=\"";
var emailByJS2_6 = "onli";
var emailByJS2_6a = "Onli";
var emailByJS7 = "y</a> at ";
var emailByJS2_7 = "utor";
var emailByJS2_7a = "Tutor";
var emailByJS8 = "ef=\"..\" rel=\"external\">RareHo";
var emailByJS2_8b = "nfo\" rel=\"external\">";
var emailByJS2_8 = "K13t";
var emailByJS5 = "ehome.c";
var emailByJS3_5 = "xternal\">";

var emailName = emailByJS2_4 + emailByJS2_1a + emailByJS2_7a + emailByJS2_3;
emailName += emailByJS2_6a + emailByJS2_2 + emailByJS2_5;

/*********************************************************************************/
/**********************   Build a vcard for the instructor   *********************/

function buildVcard () {
    var classVcard = "";
    var instrVcardName = MasterInstr[cNum][iNum].name;
    vcardName = instrVcardName.replace(" ","-");
    var instrVcard = "";
    if (buildVcard.arguments.length > 0) {
        instrVcardName = buildVcard.arguments[0] + instrVcardName;
        }
    if (buildVcard.arguments.length > 1) {
        classVcard = buildVcard.arguments[1];
        }
    instrVcard += "<div id=\"hcard-" + vcardName + "\" class=\"vcard\">";    
    instrVcard += "\n<img style=\"margin:4px;\" src=\"./Common/images/AlanPortraitSQ.jpg\"";
    instrVcard += "height=\"96\" width=\"96\" alt=\"photo of \" class=\"photo" + classVcard + "\"/>";
    instrVcard += "\n<a class=\"url fn\" href=\"http://TutorialsOnline.info\">" + instrVcardName + "</a>";
    instrVcard += "\n<div class=\"org" + classVcard + "\">HTC</div>";
    instrVcard += "\n<br /></span><span class=\"eighty\">";
    instrVcard += "\n<a href=\"./Common/emailPage.html\" rel=\"external\">";
    instrVcard += MasterInstr[cNum][iNum].email + "</a>";
    
    instrVcard += "\n<div class=\"adr" + classVcard + "\">";
    instrVcard += "\n<span class=\"street-address\">13100 College View Drive</span>";
    instrVcard += "\n<span class=\"locality\">Eden Prairie</span>, ";
    instrVcard += "\n<span class=\"region\">MN</span>, ";
    instrVcard += "\n<span class=\"postal-code\">55347</span>";
    instrVcard += "\n</div></div></div>";
    
    return instrVcard;
    }
/*********************************************************************************/

/*********************************************************************************/
/**
 * Adds a style rule to the embedded styles in the html file
 * @param selector the new selector to be added
 * @param rule the new rule for the selector
 * @param val the value for the rule
 * @return None
 */
function addRule(selector, rule, val) {
    if (document.styleSheets) {
        var SS = document.styleSheets.item(0)['cssRules'];

        var new_rule = document.styleSheets[0]
        var selectorRule;

        if (new_rule.insertRule) {
            var numRules = SS.length;
            selectorRule = '{' + rule + ": " + val + ';}';
            new_rule.insertRule(selector + selectorRule, numRules);
            }

        else {
            if (new_rule.addRule)
                {
                selectorRule = rule + ": " + val + ";";
                new_rule.addRule(selector, selectorRule);
                }
            }
        }
    }

/*****   This function adds a style rule based on the location of an object   ****/
function newPosition(refObj) {

    /************************   Adjust the styles in IE   ************************/
    if (document.all) {
        var positionTop = Math.floor(refObj + 12) + "px";
        } else {

    /**********************   Adjust the styles in FireFox   *********************/
        var positionTop = Math.floor(refObj + 15) + "px";
        }

    addRule('.logo', "top", positionTop);
    }

/************   Adjust various attributes and values in certain tags   ***********/
function adjustTags() {
    /******************   Check Browser Version and Compatibility   ******************/
    //is_fx = $.browser.mozilla;
    //is_ie = $.browser.msie;

    if (!document.getElementsByTagName) {
        return null;
        }
    /**************   Set "external" links to load in a new window   *************/
    var anchors = document.getElementsByTagName("a");

    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];

        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
            anchor.setAttribute("target", "_blank");
            }
/*
        if (anchor.getAttribute("href") && anchor.href.indexOf("Common") > -1) {
            var commonPlace = anchor.href.indexOf("Common") + 7;
            var tmp = anchor.href.substring(commonPlace, anchor.href.length);
            anchor.href = commonFolder + tmp;
            }
*/
        }

    /****************   Set the Common directory for each course   ***************/
    var linkTags = document.getElementsByTagName('LINK');
    for (i = 0; i < linkTags.length; i++) {
        if (linkTags[i].getAttribute('rel') == "home") {
            homeDir = linkTags[i].getAttribute('href');

            if (homeDir != "./") {
                commonFolder = homeDir + "Common/";
                /*****   Double check that the Common directory is referenced properly   *****/
                var replCommons = document.getElementsByTagName("img");

                for (var i = 0; i < replCommons.length; i++) {
                    var replCommon = replCommons[i];

                    if (replCommon.getAttribute("src") && replCommon.src.indexOf("Common") > -1) {
                        var commonPlace = replCommon.src.indexOf("Common") + 7;
                        var tmp = replCommon.src.substring(commonPlace, replCommon.src.length);
                        replCommon.src = commonFolder + tmp;
                        }
                    }
                }
            }
        }

    /***********   Add the name attribute to any map tags in FireFox   ***********/
    var mapNames = document.getElementsByTagName("map");

    for (var i = 0; i < mapNames.length; i++) {
        var mapName = mapNames[i];

        if (!document.all && mapName.getAttribute("id") && !mapName.getAttribute("name")) {
            var idVal = mapName.getAttribute("id");
            mapName.setAttribute("name", idVal);
            }
        }
        windowParms()
    }


/********   Standard function to adjust styles in external style sheets   ********/

function adjustExternalStyles(selectr, property, valu) {
    if (!document.styleSheets || adjustExternalStyles.arguments.length < 3) {
        return;
        }

    var firstSheet=(document.styleSheets[0].imports) ? document.styleSheets[0].imports[0] : document.styleSheets[0];  
    var theRules=(firstSheet.cssRules) ? firstSheet.cssRules: firstSheet.rules;

    /************************   Adjust the styles in FireFox   ***********************/
    if (document.styleSheets[0].insertRule) {
        selectrTxt = selectr + " {" + property + ": " + valu + ";}";    
        firstSheet.insertRule(selectrTxt, theRules.length); //add new rule to end of stylesheet        
        document.styleSheets[0].insertRule(selectrTxt, theRules.length); //add new rule to end of stylesheet
        }

        /**************************   Adjust the styles in IE   **************************/
        if (document.styleSheets[0].imports) {

            for (i = 0; i < theRules.length; i++) {
                if (theRules[i].selectorText.toLowerCase() == selectr.toLowerCase()) { 
                    theRules[i].style[property] = valu; //good for IE
                }
            }
        }
    }

/*********************************************************************************/

/***********************   Assemble email address pieces   ***********************/
var emailByJS = emailByJS1 + emailByJS2 + emailByJS3 + emailByJS4;
emailByJS += emailByJS5 + emailByJS6 + emailByJS7 + emailByJS1;
emailByJS += emailByJS8 + emailByJS9;

var emailByJSb = emailByJS2_4 + emailByJS2_1 + emailByJS2_8 + emailByJS2_7;
emailByJSb += emailByJS2_3 + emailByJS2_6 + emailByJS2_2 + emailByJS2_5;
var emailByJSc = emailByJS3_1 + emailByJS3_2 + emailByJS3_3 + emailByJS3_4 + emailByJS3_5;
var emailByJShw = emailByJSc + "Alan Kelsey</a> at " + emailByJS1 + emailByJS3_2b + emailByJS2_7a + emailByJS2_3;
emailByJShw += emailByJS2_6a + emailByJS2_2 + emailByJS2_8b + emailByJS2_7a + emailByJS2_3;
emailByJShw += emailByJS2_6a + emailByJS2_2 + emailByJS2_5;

/*********************************************************************************/

/*****************   Standard functions to create popup windows   ****************/
/**************************   Assemble the parameters   **************************/

function windowParms() {
    winStats = "";

    for (i = 0; i < windowStats.length; i++) {
        winStats += windowStats[i];
        }
    }

/*********************************************************************************/
/*********************   Declare the individual parameters   *********************/

windowStats[0] = "directories=no,"; //  directories=[yes|no]
/****   Specifies whether to create the standard browser directory buttons.   ****/
/***   In some browsers the directory buttons can be customized by the user.    **/

windowStats[1] = "height=800px,width=500px,";
/**********   Specifies the height and width of the window in pixels.   **********/
/*********************   The minimum value should be 100.    *********************/

windowStats[2] = "location=no,"; //	location=[yes|no]
/**************   Specifies whether to display the Location field,   *************/
/********   the input field for entering URLs directly into the browser.   *******/

windowStats[3] = "menubar=no,"; //	menubar=[yes|no]
/*******   Specifies whether to create the menu at the top of the window.   ******/
/***********   In Internet Explorer, this feature is yes by default.   ***********/
/*******   A menu normally consists of a "File" option, an "Edit" option,   ******/
/********************   and other browser-specific options.   ********************/

windowStats[4] = "resizable,"; //	resizable=[yes|no]
/*   Specifies whether to display resize handles at the corners of the window,   */
/*****   which enable the user to resize the window. If this feature is not   ****/
/********   turned on explicitly, the user cannot resize the new window.   *******/

windowStats[5] = "scrollbars,"; //	scrollbars=[yes|no]
/*****   Specifies whether to display horizontal and vertical scroll bars,   *****/
/***********   when the content exceeds the dimensions of the window.   **********/
/**********************   This feature is yes by default.   **********************/

windowStats[6] = "status=yes,"; //	status=[yes|no]
/***   Specifies whether to create a status bar at the bottom of the window.   ***/
/***********   In Internet Explorer, this feature is yes by default.   ***********/

windowStats[7] += "toolbar=no"; //	toolbar=[yes|no]
/*************   Specifies whether to display the browser toolbar,   *************/
/*******************   with buttons such as Back and Forward.   ******************/
var winStats = "";

for (i = 0; i < windowStats.length; i++) {
    winStats += windowStats[i];
    }
/*********************************************************************************/
/**********************   WinStats for a full sized window   *********************/
var winStatsFull = "toolbar=no,";
winStatsFull += "location=false,";
winStatsFull += "directories=no,";
winStatsFull += "menubar=no,";
winStatsFull += "scrollbars,";
winStatsFull += "resizable,";

winStatsFull += "height=" + (parseInt(screen.availHeight) - 60) + "px,";
winStatsFull += "width=" + (parseInt(screen.availWidth) - 60) + "px";

if (navigator.appName.indexOf("Microsoft") >= 0) {
    winStats += ",left=10,top=25";
    }

else {
    winStats += ",screenX=10,screenY=25";
    }

var newWindCodTitle = "<html><head><title>Definitions</title>";
var newWindCodHead;
var newWindCodEnd = "</body></html>"; // last code for new window

var newWindow;

function makeNewWindow(wStats, newWinTitle) {
    if (makeNewWindow.arguments.length < 2) {
        newWinTitle = newWindCodTitle;
        };

    newWindCodHead = newWinTitle + "<style type='text/css'>@import \"" + commonFolder + "css_js/tutorial.css\";";
    newWindCodHead += "body {background-image: none; margin:30px;}</style></head>";

    wStats = (wStats == null || wStats == "") ? winStats : wStats;

    newWindow = window.open("", "", wStats);

    if (!newWindow || newWindow == "undefined") {
        alert("You must disable your popup window blocker to see all of the information on this site.");
        }
    }

/********************   Make a new window and load in a file   *******************/

function popUp(newURL, newName, wStats, orgName) {
    wStats = (wStats == null || wStats == "") ? winStats : wStats;
    var remote = open(newURL, newName, wStats);

    if (remote.opener == null) {
        remote.opener = window;
        }

    if (window.focus) {
        remote.focus();
        }

    remote.opener.name = orgName;
    return remote;
    }

function staticWin(winUrl, wStats, mainTitle) {
    //Make a new window if it isn't already open

    if (!newWindow || newWindow == "undefined") {
        makeNewWindow(wStats, mainTitle);
        }

    if (newWindow.closed) {
        makeNewWindow();
        }

    newWindow.location = winUrl;
    }

/*******************   Make a new window with dynamic content   ******************/
function dynamicWin(winContent) {
    //Make a new window if it isn't already open
    if (newWindow) {
        newWindow.close();
        }

    if (!newWindow) {
        makeNewWindow();
        }

    if (newWindow.closed) {
        makeNewWindow();
        }

    // write html to new window document
    winContent = newWindCodHead + winContent + newWindCodEnd;
    newWindow.document.write(winContent);
    newWindow.document.close(); // close layout stream
    }

/**********************************************************************************
* 			Sliding Menu Bar Script- © Dynamic Drive (www.dynamicdrive.com)
* 			Visit http://www.dynamicdrive.com/ for full source code
* 			This notice must stay intact for use
**********************************************************************************/

var slidemenu_width = '260px';  //		specify width of menu (in pixels)
var slidemenu_reveal = '115px'; //		specify amount that menu should protrude initially
var slidemenu_top = '200px';    //		specify vertical offset of menu on page

var rightboundary = 0;
var slideLeft = (parseInt(slidemenu_width) - parseInt(slidemenu_reveal)) * -1;

function slidePosition(ref)
    {
    var hiddenMenu = new Array();
    var hiddenMenuHTML = "<div id=\"slidemenubar2\" onmouseover=\"pull()\" onmouseout=\"draw()\">";

    /*******************************   Edit below   ******************************/
    /***************   The form for each element of the Array is   ***************/
    /****   hiddenMenu[x]=["Item Text", "Optional URL associated with text"]   ***/
    x = 0;
    hiddenMenu[x++]=["More Places",""];
    hiddenMenu[x++]=["Tutorials Main","http://TutorialsOnline.info/index.html"];
    hiddenMenu[x++]=["Discussion Forums","http://TutorialsOnline.info/cgi-bin/yabb2/YaBB.pl\" target=\"_blank"];

    if (MasterInstr[cNum].length > 3) {
        hiddenMenu[x++] = ["Change Instructors","javascript:changeInstr(" + cNum + ")"];
        }

    if (MasterInstr[cNum].length == 3) {
        iNumExMenu = (iNum == 1) ? 2 : 1;
        hiddenMenu[x++] = ["Change Instructors","javascript:wrapUp(" + cNum + ", " + iNumExMenu + ")"];
        }

    rndSearch = "<div id=\"roundedSearch\"><form id=\"search\">";
    rndSearch += "<span id=\"searchIcon\" class=\"searchStart\"></span>";
    rndSearch += "<input id=\"searchText\" class=\"searchField\" type=\"search\" value=\"Search\"/>";
    rndSearch += "<span class=\"searchEnd\"></span><br />";
    rndSearch += "<span id=\"searchPopup\"> Click&nbsp;to&nbsp;submit your search!</span></form></div>";
   // hiddenMenu[x++] =[rndSearch,""];

    hiddenMenu[x++]=["Search Page","./search/search.php\" target=\"_blank"];

    hiddenMenu[x++] =["",""];

    if (nowDay > evalDate){
        hiddenMenu[x++] =["","javascript:void(0)"];
        //hiddenMenu[x++] = ["Course evaluation","http://TutorialsOnline.info/courseEval.html"]
        }

    //If you want the links to load in another frame/window, specify name of target (ie: target="_new")
    var targetPlace = "";

    /*******************************   Edit above   ******************************/

    hiddenMenuHTML += "<div class=\"emphMaroonBold one50\">\n";
    hiddenMenuHTML += hiddenMenu[0][0];
    hiddenMenuHTML += "</div>\n<div class=\"padTopBot\">\n";

    for (i = 1; i < hiddenMenu.length; i++) {
        if (hiddenMenu[i][1]) {
            hiddenMenuHTML += "<a href=\"" + hiddenMenu[i][1] + "\"";
            if (targetPlace.length > 0) {
                hiddenMenuHTML += " target=\"" + targetPlace + "\"";
                }
            hiddenMenuHTML += ">";
            }
        hiddenMenuHTML += hiddenMenu[i][0];
        if (hiddenMenu[i][1]) {
            hiddenMenuHTML += "</a>";
            }
        hiddenMenuHTML += "<br />\n";
        }

    hiddenMenuHTML += "</div>\n</div>"
    document.write(hiddenMenuHTML);

    /************************   Adjust the styles in IE   ************************/
    if (document.all) {
        slidemenu_top = ref + 12;
        } else {
        slidemenu_top = ref + 15;
        }

    $("#slidemenubar2").css("left", slideLeft);
    $("#slidemenubar2").css("top", slidemenu_top);
    $("#slidemenubar2").css("width", slidemenu_width);

    }
/*   Check if the following function is needed  */
function regenerate2() {
    window.location.reload();
    }

function pull() {
    if (window.drawit) {
        clearInterval(drawit);
        }
    pullit = setInterval("pullengine()", 10);
    }

function draw() {
    clearInterval(pullit);
    drawit = setInterval("drawengine()", 10);
    }

function pullengine() {
    var posn = $("#slidemenubar2").css("left");
    if (parseInt(posn) < rightboundary) {
        $("#slidemenubar2").css("left", parseInt(posn) + 10);
        } else {
        if (window.pullit) {
            $("#slidemenubar2").css("left", 0);
            clearInterval(pullit);
            }
        }
    }

function drawengine() {
    var posn = $("#slidemenubar2").css("left");
    if (parseInt(posn) > slideLeft) {
        $("#slidemenubar2").css("left", slideLeft - 10);
        } else {
        if (window.drawit) {
            $("#slidemenubar2").css("left", slideLeft);
            clearInterval(drawit);
            }
        }
    }
 
/***********************   End of Sliding Menu Bar Script   **********************/
/*  If you are a JavaScript student and reading this, 
    copy the next line and paste it into an email for 5 extra credit points
    
I was reading the TutorialsOnline JavaScript Library

I know 5 points isn't much, but it's five more than you had an hour ago.
Please don't tell anyone else about this.  I'd like to see just how many actually read over this stuff.

*/

/*****************************   Instructor Setup   ******************************/
/*********************************************************************************/
/****************   The variable sc sets the specific course   *******************/
/*********************************************************************************

1 -     HTML
2 -     Advanced HTML
3 -     JavaScript
4 -     Java
5 -     XML
6 -     AJAX
7 -     [extra spot]
8 -     [extra spot]
9 -     admin

**********************************************************************************/
/*********************************************************************************/
/********************   The variable xx sets the instructor   ********************/
/**   Homework & labs can follow either the weeks (yy) or the class notes (zz)   */
/*********************************************************************************/
/*************   The information for each instructor is as follows   *************

MasterInstr[sc][xx] = new makeInstr(
                                "Instructor Name",
                                dayOfClass,
                                dayNames[dayOfClass] + " Morn",
                                "instructor@HTMLTutorialOnline.info",
                                "index.html",
                                dayHwDue
                                [, iTwoTimes (default = false)]
                                [, iShortSem (default = false)]
                                [, blended (default = false)]
                                [, hwemail (different email for HW)];

**********************************************************************************/

/*****************   Make sure the array has at least one value   ****************/
for (x = 0; x < MasterInstr.length; x++) {
    MasterInstr[x][0] = "I don&#39;t know";
    }

/*********************************************************************************/
/***********************************   HTML   ************************************/
/*********************************************************************************/

sc = 1;
dayOfWeek = 0;
CCIS[sc] = new makeInstrBasic("CCIS 1301", "HTML", "HT1301")
courses[sc] = "HTML"
xx = 0;
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Morn",
    "instructor@HTMLTutorialOnline.info", "index.shtml", 5);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 10, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 8, 10, 12, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(4, 6, 9, 11, 13, 14, 0);

/*********************************************************************************/

/* Online class - 16 week session */
/*****************************   Next Instructor   ******************************/

dayOfWeek = 0				//		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " ",
                        "instructor@HTMLTutorialOnline.info",
                        "index.shtml", 5, false, false);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/*********************   Sixteen Week Semester Assignments   *********************/

MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 13, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 9, 11, 13, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 8, 10, 12, 14, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 6, 8, 10, 13, 15, 0);

/*********************************************************************************/


/* Online class - 8 week session */
/*****************************   Next Instructor   ******************************/
/*
dayOfWeek = 0 //		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve.",
    "instructor@HTMLTutorialOnline.info", "index.shtml", 5, false, true, false);
*/
/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/**********************   Eight Week Semester Assignments   **********************/
/*
MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 9, 11, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 7, 9, 11, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 6, 7, 9, 11, 13, 0);
*/
/*********************************************************************************/


/* Online class - 8 week session */
/*****************************   Next Instructor   ******************************
dayOfWeek = 0				//		Day of the week that the class meets
MasterInstr[sc][xx]
    = new makeInstr("Dave Wood", dayOfWeek, dayNames[dayOfWeek]
                        + " Eve.",
                        "instructor@styxsoftware.com",
                        "index.shtml", 5, false, true, false);
*/
/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/**********************   Eight Week Semester Assignments   **********************

MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 9, 11, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 7, 9, 11, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 6, 7, 9, 11, 13, 0);
*/
/*********************************************************************************/

/* Regular Semester */
/******************************   Next Instructor   ******************************
//	dayOfWeek = 0			//		Day of the week that the class meets
MasterInstr[sc][xx]
    = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek]
                        + " Aft.",
                        "instructor@HTMLTutorialOnline.info",
                        "index.shtml", 1);

*********   Make arrays to hold weeks of lab and homework assignments   *********
MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 10, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 8, 10, 12, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 6, 9, 11, 13, 14, 0);
*/

/* Blended  */
/******************************   Next Instructor   ******************************/

dayOfWeek = 2; //		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Aft.",
                        "instructor@HTMLTutorialOnline.info",
                        "index.shtml", 5, false, false, true);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/

MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 13, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 5, 6, 7, 11, 12, 14, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 8, 10, 12, 14, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 5, 10, 12, 14, 16, 0);

/*********************************************************************************/

/* Blended  */
/******************************   Next Instructor   ******************************/
/*
dayOfWeek = 2; //		Day of the week that the class meets

MasterInstr[sc][xx] = new makeInstr("Ernie Feil", dayOfWeek, dayNames[dayOfWeek] + " Eve.",
                        "HTCClasses@Hotmail.com",
                        "index.shtml", 5, false, false, true);
*/
/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/*
MasterInstr[sc][xx].labClass = new Array(1, 2, 4, 5, 7, 9, 11, 13, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 4, 5, 7, 10, 11, 13, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 8, 10, 12, 14, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 6, 8, 11, 12, 14, 0);
*/
/*********************************************************************************/

/*********************************************************************************/
/*******************************   Advanced HTML   *******************************/
/*********************************************************************************/

sc += 1;
dayOfWeek = 2; //		Day of the week that the class meets
CCIS[sc] = new makeInstrBasic("CCIS 1351", "Advanced HTML", "HT1351")
courses[sc] = "Advanced HTML"
xx = 0;
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Morn",
    "instructor@CSSTutorialOnline.info", "index.shtml", 5, false, false, true);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 9, 11, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 11, 13, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 7, 10, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(1, 4, 4, 5, 6, 7, 0);

/* Blended  */
/******************************   Next Instructor   ******************************/

MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve.",
    "instructor@CSSTutorialOnline.info", "index.shtml", 5, false, false, true);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/************************   Blended Semester Assignments   ***********************/

MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 9, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 10, 15, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 8, 10, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(1, 4, 6, 9, 11, 15, 0);

/*********************************************************************************/


/* Online class */
/*****************************   Next Instructor   ******************************/

dayOfWeek = 0				//		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " ",
                        "instructor@HTMLTutorialOnline.info",
                        "index.shtml", 5, false, false);
                        

/*********   Make arrays to hold weeks of lab and homework assignments   *********/

MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 9, 11, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 10, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 8, 10, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(1, 3, 7, 9, 12, 16, 0);

/*********************************************************************************/

/*********************************************************************************/
/*********************************   JavaScript   ********************************/
/*********************************************************************************/

sc += 1;
dayOfWeek = 2; //		Day of the week that the class meets
CCIS[sc] = new makeInstrBasic("CCIS 2591", "JavaScript&#8482;", "JS2591")
xx = 0;
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Eve",
    "instructor@JavaScriptTutorialOnline.info", "index.shtml", 5);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/

MasterInstr[sc][xx].labClass = new Array(2, 3, 5, 8, 10, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(3, 4, 8, 10, 12, 16, 0);

MasterInstr[sc][xx].hwClass = new Array(1, 4, 6, 7, 9, 11, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(1, 4, 6, 7, 9, 11, 13, 0);

/* Blended  */
/******************************   Next Instructor   ******************************/

MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve",
    "instructor@JavaScriptTutorialOnline.info", "index.shtml", 5, false, false, true);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/************************   Blended Semester Assignments   ***********************/

MasterInstr[sc][xx].labClass = new Array(2, 3, 5, 7, 0);
MasterInstr[sc][xx].labWeek = new Array(3, 5, 8, 10, 0);

MasterInstr[sc][xx].hwClass = new Array(1, 4, 6, 8, 9, 11, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 5, 7, 12, 14, 16, 0);

/*********************************************************************************/

/* Online class */
/*****************************   Next Instructor   ******************************/

dayOfWeek = 0				//		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " ",
                        "instructor@HTMLTutorialOnline.info",
                        "index.shtml", 5, false, false);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/************************   Blended Semester Assignments   ***********************/

MasterInstr[sc][xx].labClass = new Array(2, 3, 5, 7, 9, 11, 13, 0);
MasterInstr[sc][xx].labWeek = new Array(3, 4, 8, 10, 12, 14, 0);

MasterInstr[sc][xx].hwClass = new Array(1, 4, 6, 8, 10, 12, 14, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 4, 6, 8, 10, 12, 14, 0);

/*********************************************************************************/

/*********************************************************************************/
/************************************   Java   ***********************************/
/*********************************************************************************/

sc += 1;
dayOfWeek = 3; //		Day of the week that the class meets
CCIS[sc] = new makeInstrBasic("CCIS 2595", "Java I", "Jv2595")
xx = 0
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Morn",
    "instructor@JavaTutorialOnline.info", "index.shtml", 0);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 10, 11, 14, 16, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 4, 5, 7, 11, 12, 14, 0);

/******************************   Next Instructor   ******************************/
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve",
    "instructor@JavaTutorialOnline.info", "index.shtml", 0, false, false, false);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/

MasterInstr[sc][xx].labClass = new Array(1, 3, 6, 8, 9, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 8, 9, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 5, 7, 10, 11, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 4, 5, 8, 12, 13, 15, 0);
/* */
/*
MasterInstr[sc][xx].labClass = new Array(1, 3, 6, 8, 9, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 6, 8, 10, 13, 16, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 5, 7, 10, 11, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 4, 5, 7, 10, 13, 15, 0);
*/
/*********************************************************************************/

/*********************************************************************************/
/************************************   XML   ************************************/
/*********************************************************************************/

sc += 1;
dayOfWeek = 2; //		Day of the week that the class meets
CCIS[sc] = new makeInstrBasic("CCIS 2610", "XML", "XM2610")
xx = 0
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Morn",
    "instructor@TutorialsOnline.info", "index.shtml", 0);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 8, 12, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 5, 8, 12, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 7, 14, 16, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 4, 6, 7, 14, 15, 0);

/******************************   Next Instructor   ******************************/
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve.",
    "instructor@TutorialsOnline.info", "index.shtml", 0, false, false, false);


/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(1, 2, 5, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 2, 5, 0);

MasterInstr[sc][xx].hwClass = new Array(3, 6, 7, 9, 10, 12, 0);
MasterInstr[sc][xx++].hwWeek = new Array(4, 6, 8, 9, 12, 12, 0);

/*********************************************************************************/

/*********************************************************************************/
/************************************   AJAX   ***********************************/
/*********************************************************************************/

sc += 1;
dayOfWeek = 1; //		Day of the week that the class meets
CCIS[sc] = new makeInstrBasic("CCIS 2625", "AJAX", "AJ2625")
xx = 0
MasterInstr[sc][xx] = new makeInstr("I don&#39;t know", dayOfWeek, dayNames[dayOfWeek] + " Aft",
    "instructor@TutorialsOnline.info", "index.shtml", 0);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/

MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 4, 5, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 8, 12, 13, 0);
MasterInstr[sc][xx++].hwWeek = new Array(3, 5, 8, 10, 13, 14, 0);

/******************************   Next Instructor   ******************************/

MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Eve.",
    "instructor@TutorialsOnline.info", "index.shtml", 0, false, false, false);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
/*
MasterInstr[sc][xx].labClass = new Array(1, 3, 4, 6, 8, 11, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 4, 5, 8, 11, 14, 0);
*/

MasterInstr[sc][xx].labClass = new Array();
MasterInstr[sc][xx].labWeek = new Array();

MasterInstr[sc][xx].hwClass = new Array(1, 2, 4, 5, 6, 7, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 7, 10, 12, 14, 16, 0);

/*********************************************************************************/

/*********************************************************************************/
/*******************************   Administrative   ******************************/
/*********************************************************************************/

sc = 9;
dayOfWeek = 0;
CCIS[sc] = new makeInstrBasic("TOad1000", "Administrative", "AD1000");
//courses[sc] = "XHTML"
xx = 0;
MasterInstr[sc][xx] = new makeInstr("195bc66477a1d8fc5f1ccc4123c56f76", dayOfWeek, dayNames[dayOfWeek] + " Morn",
    "instructor@TutorialsOnline.info", "index.shtml", 5);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(1, 3, 5, 9, 0);
MasterInstr[sc][xx].labWeek = new Array(1, 3, 5, 9, 0);

MasterInstr[sc][xx].hwClass = new Array(2, 4, 6, 8, 10, 0);
MasterInstr[sc][xx++].hwWeek = new Array(2, 4, 6, 8, 10, 0);


/******************************   Next Instructor   ******************************/
dayOfWeek = 0 //		Day of the week that the class meets
MasterInstr[sc][xx] = new makeInstr("Alan Kelsey", dayOfWeek, dayNames[dayOfWeek] + " Aft.",
    "instructor@TutorialsOnline.info", "index.shtml", 5, true, true);

/*********   Make arrays to hold weeks of lab and homework assignments   *********/
MasterInstr[sc][xx].labClass = new Array(0, 0, 0, 0, 0, 0, 0);
MasterInstr[sc][xx].labWeek = new Array(0, 0, 0, 0, 0, 0, 0);

MasterInstr[sc][xx].hwClass = new Array(0, 0, 0, 0, 0, 0, 0);
MasterInstr[sc][xx++].hwWeek = new Array(0, 0, 0, 0, 0, 0, 0);

/*********************************************************************************/

/*********************************************************************************/
/*********************************************************************************/

/***************   Get Date Last Modified and Course Number (cNum)   *************/

var metas = document.getElementsByTagName('META');
var cNum = 0;

for (i = 0; i < metas.length; i++) {
    if (metas[i].getAttribute('name') == "DC.Date.X-MetadataLastModified") {
        dlm = metas[i].getAttribute('content');
        dlmYr = dlm.substring(0, 4);
        dlmMo = dlm.substring(5, 7);
        dlmDa = dlm.substring(8, 10);
        dlmMoDaYr = dlmMo + "/" + dlmDa + "/" + dlmYr;
        dlmDate = new Date(dlmMoDaYr);

        /************   Try to get the date from the file itself   ***************/
        fileDLMTmp = document.lastModified;
        fileDLM = new Date(fileDLMTmp);

        if (fileDLM > dlmDate && fileDLM < nowDay) {
            dlmDate = fileDLM;
            }
        dlm = formatDate(dlmDate, "MonFull dd, yyyy");
        }

    if (metas[i].getAttribute('name') == "Course.Number") {
        cNum = parseInt(metas[i].getAttribute('content'));
        }

    /****************   Comment this out before the semester begins   ****************/
    /*
        if (metas[i].getAttribute('name') == "DC.Title") {
            var DCTitle = metas[i].getAttribute('content');
            var docTitle = document.title;
            if (DCTitle != docTitle && titleFlag) {
                alert("Titles don't match.");
                titleFlag = false;
                }
          }
    */
    /************************   Comment out the lines above   ************************/

    }

/*********************************************************************************/
/****************   Special weekly blocks for the Syllabus page   ****************/

var firstSession = "<div class=\"boxLeft\"><h5 class=\"eighty\">First Meeting</h5></div>";
firstSession += "<div class=\"boxMiddle\">Introductions&nbsp; HTML Overview</div>";
firstSession += "<div class=\"boxRight\"><h5 class=\"eighty\">Go to lab after introductions</h5></div>";
firstSession += "<div class=\"space-line\">&nbsp;</div>";

var midSemBreak = "<div class=\"boxLeft\">";

function reviewBreak(sylDates) {
    hmidSemBreak = "Review of everything so far";
    midSemBreak += syllabusDates(yy++, zz, "");
    midSemBreak += "</div>";
    midSemBreak += "<div class=\"boxRight2\"><h5>Review of everything so far</h5></div>";
    midSemBreak += "<div class=\"space-line\">&nbsp;</div>";
    }

var finalDate = "<p>&nbsp;</p>";
var finalTopic = "<p>&nbsp;</p>";

function lastClass() {
    finalDate = "<p>&nbsp;</p>";
    onlineDueDate = new Date(expires.getFullYear(), expires.getMonth(), expires.getDate() - 9);
    classEventDay = new Date(onlineDueDate.getTime());
    onlineDueDate = formatDate(onlineDueDate, "MonFull dd");
    finalTopic = "<h5 class=\"eighty emphRedBold\">All work, including your project, is due by noon on " + onlineDueDate
        + ".<br />Remember, it takes time to correct assignments. If you hand in your last assignment less than one full week before the final due date, you may not get it back before your project is due.</h5>";

    if (!MasterInstr[cNum][iNum].online) {
        hmidSemBreak = "All work is due";
        endHour--;
        finalDate = syllabusDates(yy++, zz++, 0);
        finalTopic
            = "<h5 class=\"eighty\">Projects due one hour before the end of class<br />All work is due.<br />Remember, it takes time to correct assignments. If you hand in your last assignment less than one full week before the final due date, you may not get it back before your project is due.</h5>";
        }
    }

/******************   Create a namespace for utility functions   *****************/

var UTIL = UTIL || {};

UTIL.popup = UTIL.popup || {};

/**
 * Open popup window
 * 
 * Opens a popup window using as little as a URL. An optional params object can 
 * be passed.
 * 
 * @param {Object} href
 * @param {Object} params
 * @return {WindowObjectReference}
 */
 
UTIL.popup.open = function (href, params)
{
    // Defaults (don't leave it to the browser)
    var defaultParams = {
        "width":       "800",   //  Window width
        "height":      "600",   //  Window height 
        "top":         "0",     //  Y offset (in pixels) from top of screen
        "left":        "0",     //  X offset (in pixels) from left side of screen
        "directories": "no",    //  Show directories/Links bar?
        "location":    "no",    //  Show location/address bar?
        "resizeable":  "no",    //  Make the window resizable?
        "menubar":     "no",    //  Show the menu bar?
        "toolbar":     "no",    //  Show the tool (Back button etc.) bar?
        "scrollbars":  "yes",   //  Show scrollbars?
        "status":      "no",    //  Show the status bar?
        "windowName":  ""       //  The name of the window
    };
    
    var windowName = params["windowName"] || "new_window";
    
    var i, useParams = "";
    
    // Override defaults with custom values while we construct the params string
    for (i in defaultParams) {
        useParams += (useParams === "") ? "" : ",";
        useParams += i + "=";
        useParams += params[i] || defaultParams[i];
        }
    
    return window.open(href, windowName, useParams);
};


/*********************************************************************************/
/***************   Run this code when the document's done loading   **************/    
    $(document).ready(function() {
        adjustTags();
        
        $('.ajaxtrigger').click(function(){
            $('#content').load($(this).attr('href'));
            return false;
            });
            
        // Apply this code to each link with class="popup"

        $('a.popup').click(function() {
            var params = $(this).data("popup") || {};   // Grab parameters using jQuery's data() method
            
            // Use the target attribute as the window name
            if ($(this).attr("title")) {
                    params.windowName = $(this).attr("title");
                    document.title = params.windowName;
                    }

            // Pop up the window
            var windowObject = UTIL.popup.open(this.href, params);
    			
            // Save the window object for other code to use
            $(this).data("windowObject", windowObject);
            return false;
            });

/****************************   End of popup window   ****************************/
/*********************************************************************************/
        
    });


/******************************   tutorial.js stop   *****************************/

