    //////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
   //        JavaScript code for Personal Trainer prototype        \\
  //     Written by Kevin Stanek of Stanek Software Development     \\
 /////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

// find our path
var rootDir = "";
rootDir = rootDir.substring(0, rootDir.lastIndexOf("/") + 1);


// determine the computer platform
var platMac = (navigator.appVersion.indexOf("Mac") != -1);
var platWin = (navigator.appVersion.indexOf("Win") != -1);
var macOSX = ((navigator.userAgent.indexOf("Mac OS X") != -1) || (navigator.userAgent.indexOf("MSIE 5.2") != -1));

// determine the browser in use
var browNet = (navigator.appName.indexOf("Netscape") != -1);
var browMic = (navigator.appName.indexOf("Microsoft") != -1);
var browSaf = (navigator.appVersion.indexOf("Safari") != -1);

//if popups are permitted
var popups = true;

var gotoURL  = "";
var gotoURL2 = "";

var userType = "";

var popUpWarningShown = false;
var dropAcknowledged = false;

var firstCourse = true;
var addActvWin;

var newQuestionNum;

var oldAssnMenuSel;
var oldActvMenuSel;

var scoringPref = "perc";
var equalized, equalizedSaved = 0;

var helpBannerText = "Testing!";
var studentFooterText;

var currActv = "all";
var currAssn = "all";
var currAtmp = "last";
var currCrse = "01";
var currStud = "all";
var currView = "perc";
var currWght = "on";

var currHmwkDate = "2005_09";
var currHmwkPastDue = "off";
var currHmwkPractice = "on";

var editDateTime_Month  = "";
var editDateTime_Date   = "";
var editDateTime_Year   = "";
var editDateTime_Hour   = "";
var editDateTime_Minute = "";
var editDateTime_AM_PM  = "";

var assnCount  = 24;
var actvCounts = new Array(17,31,27,34,29,15,40,36,22,48,
                       46,41,42,31,18,43,41,35,42,47,
                       21,28,31,13);

var assnWeightPerc = new Array(4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,
                           4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,4.0,
                           5.0,5.0,5.0,5.0);
var assnWeightPnts = new Array(200.0,310.0,270.0,340.0,290.0,150.0,400.0,360.0,220.0,480.0,
                           460.0,410.0,420.0,310.0,180.0,430.0,410.0,350.0,420.0,470.0,
                           260.0,350.0,390.0,160.0);

var actvWeightPerc = new Array( 5.0,  -1,10.0,  -1,10.0,10.0,10.0,10.0,10.0,  -1,
                             -1,  -1,10.0,10.0,  -1,  -1,15.0);
var actvWeightPnts = new Array(10.0,  -1,20.0,  -1,20.0,20.0,20.0,20.0,20.0,  -1,
                             -1,  -1,20.0,20.0,  -1,  -1,30.0);

// -----------------------------------------------
// AcctLeftNavSynch
// -----------------------------------------------
function AcctLeftNavSynch(win,leftNavOpt)
{
for (var lnk = 0; lnk < win.parent.left_nav.document.links.length; lnk++)
{
    if (lnk == leftNavOpt - 1)
    {
        win.parent.left_nav.document.links[lnk].style.color = "FFFF00";
    }
    else
    {
        win.parent.left_nav.document.links[lnk].style.color = "FFFFCC";
    }
}
}
function detectPopUps()
{
var w=window.self.open('', '', 'height=100,width=100,top=0,left=0,scrollbars=no');
if(w)
    popups=true;
else
    popups=false;
if(w)
    w.close();
}
// -----------------------------------------------
// AccountManagementTool
// -----------------------------------------------
function AccountManagementTool(win)
{
OpenSecWin(9, rootDir + "acct_mgmt_tool_frame.htm");
}

// -----------------------------------------------
// ActivityEditQuestionList
// -----------------------------------------------
function ActivityEditQuestionList(win)
{
if (win.top.questionsAdded)
{
    ActivityEditSwitchPage(win, 'assn_edit_activity_05.htm')
}
else
{
    ActivityEditSwitchPage(win, 'assn_edit_activity_01.htm');
}
}

// -----------------------------------------------
// ActivityPreview
// -----------------------------------------------
function ActivityPreview(win, actvNum)
{
if (actvNum == 1)
{
    OpenSecWin(12, rootDir + "actv_preview_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// AddNewHint
// -----------------------------------------------
function AddNewHint(win, topic)
{
OpenSecWin(16, rootDir + "assignments/actv_add_hint_frame.htm");
}

// -----------------------------------------------
// Assignments
// -----------------------------------------------
function Assignments(win)
{
win.location.replace(rootDir + 'assignments/assignment_list.htm');
}

// -----------------------------------------------
// AssignmentsAdd
// -----------------------------------------------
function AssignmentsAdd(win)
{
OpenSecWin(11, rootDir + "assignments/assn_add_frame.htm");
}

// -----------------------------------------------
// AssignmentEdit
// -----------------------------------------------
function AssignmentEdit(win, assnNum)
{
OpenSecWin(11, rootDir + "assignments/assn_edit_frame.htm");
}

// -----------------------------------------------
// AssignmentsAddActivityList
// -----------------------------------------------
function AssignmentsAddActivityList(win)
{
if (win.top.activitiesAdded)
{
    AssignmentsAddSwitchPage(win, 'assn_add_04.htm')
}
else
{
    AssignmentsAddSwitchPage(win, 'assn_add_01.htm');
}
}

// -----------------------------------------------
// AssignmentsEditActivityList
// -----------------------------------------------
function AssignmentsEditActivityList(win)
{
if (win.top.activitiesAdded)
{
    AssignmentsAddSwitchPage(win, 'assn_edit_04.htm')
}
else
{
    AssignmentsAddSwitchPage(win, 'assn_edit_01.htm');
}
}

// -----------------------------------------------
// AssignmentsAddClose
// -----------------------------------------------
function AssignmentsAddClose(win)
{
var OK = true;
if (win.top.dataChanged)
{
    OK = win.confirm("You have made unsaved changes that will be lost if you click OK below. Click Cancel to cancel your request so that you can first save your changes.");
}
if (OK)
{
    win.top.close();
}
}

// -----------------------------------------------
// AssignmentsAddEditActvDueDate // No custom activity
// -----------------------------------------------
function AssignmentsAddEditActvDueDate(win, actvNum)
{
if ((actvNum == 1) || (actvNum == 2) || (actvNum == 5))
{
    editDateTime_Month  = "9";
    editDateTime_Date   = "9";
    editDateTime_Year   = "2005";
    editDateTime_Hour   = "08";
    editDateTime_Minute = "00";
    editDateTime_AM_PM  = "A.M.";
    OpenSecWin(26, rootDir + "assignments/actv_edit_due_date_frame.htm");
}
else if (actvNum == 6)
{
    editDateTime_Month  = "9";
    editDateTime_Date   = "19";
    editDateTime_Year   = "2005";
    editDateTime_Hour   = "08";
    editDateTime_Minute = "00";
    editDateTime_AM_PM  = "A.M.";
    OpenSecWin(26, rootDir + "assignments/actv_edit_due_date_frame.htm");
}
else
{
    win.alert("Only the first six activities are supported.");
}
}

// -----------------------------------------------
// AssignmentsAddEditActvAvailDate // No custom activity
// -----------------------------------------------
function AssignmentsAddEditActvAvailDate(win, actvNum)
{
if ((actvNum == 3) || (actvNum == 4))
{
    editDateTime_Month  = "9";
    editDateTime_Date   = "10";
    editDateTime_Year   = "2005";
    editDateTime_Hour   = "08";
    editDateTime_Minute = "00";
    editDateTime_AM_PM  = "A.M.";
    OpenSecWin(26, rootDir + "assignments/actv_edit_avail_date_frame.htm");
}
else if (actvNum == 6)
{
    editDateTime_Month  = "9";
    editDateTime_Date   = "12";
    editDateTime_Year   = "2005";
    editDateTime_Hour   = "08";
    editDateTime_Minute = "00";
    editDateTime_AM_PM  = "A.M.";
    OpenSecWin(26, rootDir + "assignments/actv_edit_avail_date_frame.htm");
}
else
{
    win.alert("Only the first six activities are supported.");
}
}

// -----------------------------------------------
// AssignmentsAddExistingActivity
// -----------------------------------------------
function AssignmentsAddExistingActivity(win)
{
OpenSecWin(14, rootDir + "assignments/assn_add_existing_activity_frame.htm");
}

// -----------------------------------------------
// AssignmentsAddSave
// -----------------------------------------------
function AssignmentsAddSave(win, quietly)
{
if (win.top.dataChanged)
{
    win.top.assnTitle = win.parent.main.document.forms[0].assn_name.value;
    win.top.dataChanged = false;
}
else
{
    if (!quietly)
    {
        win.alert("You have not changed anything, so nothing will be saved.");
    }
}
}

// -----------------------------------------------
// ActivityEditSwitchPage
// -----------------------------------------------
function ActivityEditSwitchPage(win, dest)
{
var OK = true;
if (win.top.dataChanged)
{
    OK = win.confirm("You have made unsaved changes that will be lost if you click OK below. Click Cancel to cancel your request so that you can first save your changes.");
}
if (OK)
{
    win.location.replace(dest);
}
}

// -----------------------------------------------
// AssignmentsAddSwitchPage
// -----------------------------------------------
function AssignmentsAddSwitchPage(win, dest)
{
var OK = true;
if (win.top.dataChanged)
{
    OK = win.confirm("You have made unsaved changes that will be lost if you click OK below. Click Cancel to cancel your request so that you can first save your changes.");
}
if (OK)
{
    win.location.replace(dest);
}
}

// -----------------------------------------------
// AssignmentsEditActivities
// -----------------------------------------------
function AssignmentsEditActivities(win, assnNum)
{
if (assnNum == 1)
{
    win.location.replace(rootDir + "assignments/activity_list_01.htm");
}
else
{
    OnlyAssignment1(win);
}
}

// -----------------------------------------------
// AssignmentsHelp
// -----------------------------------------------
function AssignmentsHelp(win)
{
win.alert("This feature, which will load in a small secondary window, is not yet available.");
}

// -----------------------------------------------
// AssignmentsInactivate
// -----------------------------------------------
function AssignmentsInactivate(win)
{
win.confirm("Are you sure you want to inactivate this assignment? Doing so will remove it from instructor Assignments and Gradebook, and from student Homework and Gradebook.");
}

// -----------------------------------------------
// AssignmentRemove
// -----------------------------------------------
function AssignmentRemove(win, assn)
{
win.confirm("Are you sure you want to remove this assignment from your course? All traces of it will disappear from instructor Assignments, student Homework, and student and instructor Gradebook. Furthermore, if your students have made attempts at any of the activities in this assignment, those attempts will never again be visible to this course.");
}

// -----------------------------------------------
// AssignmentSettings
// -----------------------------------------------
function AssignmentSettings(win, assn)
{
currAssn = assn;
if ((assn <= 3) || (assn == 24))
{
    gotoURL = rootDir + "assignments/assn_settings_standard.htm";
    OpenSecWin(10, rootDir + "assignments/assn_settings_frame.htm");
}
else if (assn == 25)
{
    gotoURL = rootDir + "assignments/assn_settings_custom.htm";
    OpenSecWin(10, rootDir + "assignments/assn_settings_frame.htm");
}
else
{
    win.alert("This is a prototype-only alert.\n\nTo see how this link behaves, click on Chapter 1, Chapter 24, Chapter 2, Chapter 3, or Course Review.");
}
}

// -----------------------------------------------
// ActivityRemove
// -----------------------------------------------
function ActivityRemove(win, actv)
{
win.confirm("Are you sure you want to remove this activity from your course? All traces of it will disappear from instructor Assignments, student Homework, and student and instructor Gradebook. Furthermore, if your students have made attempts at this activity, those attempts will never again be visible to this course.");
}

// -----------------------------------------------
// ActivitySettings
// -----------------------------------------------
function ActivitySettings(win, actv)
{
currActv = actv;
if ((actv == 0) || (actv > 5))
{
    win.alert("This is a prototype-only alert.\n\nTo see how this link behaves, click on the Settings link for Exercise 1-1, Exercise 1-2, Exercise 1-3, Exercise 1-3 Algorithmic, or Exercise 1-4.");
}
else
{
    if (actv == 3)
    {
        gotoURL = rootDir + "assignments/actv_settings_practice.htm";
    }
    else
    {
        gotoURL = rootDir + "assignments/actv_settings_required.htm";
    }
    OpenSecWin(10, rootDir + "assignments/actv_settings_frame.htm");
}
}

// -----------------------------------------------
// ActivityInactivate
// -----------------------------------------------
function ActivityInactivate(win)
{
win.confirm("Are you sure you want to inactivate this activity? Doing so will remove it from instructor Assignments and Gradebook, and from student Homework and Gradebook.");
}

// -----------------------------------------------
// BannerToolsCalc
// -----------------------------------------------
function BannerToolsCalc(win)
{
OpenSecWin(25, rootDir + "banner_tools/calculator_frame.htm");
}

// -----------------------------------------------
// BannerToolsContact
// -----------------------------------------------
function BannerToolsContact(win)
{
OpenSecWin(19, rootDir + "banner_tools/contact_s-w_frame.htm");
}

// -----------------------------------------------
// BannerToolsEmailInstructor
// -----------------------------------------------
function BannerToolsEmailInstructor(win)
{
OpenSecWin(19, rootDir + "banner_tools/email_instructor_frame.htm");
}

// -----------------------------------------------
// BannerToolsEmailStudents
// -----------------------------------------------
function BannerToolsEmailStudents(win)
{
OpenSecWin(19, rootDir + "banner_tools/email_students_frame.htm");
}

// -----------------------------------------------
// BannerToolsHelp
// -----------------------------------------------
function BannerToolsHelp(win)
{
Help(win);
}

// -----------------------------------------------
// BannerToolsHome
// -----------------------------------------------
function BannerToolsHome(win)
{
if (confirm("Do you want to sign out of your account and return to the Personal Trainer Home page?"))
{
    top.main.location.replace(top.rootDir + "enter.htm");
}
}

// -----------------------------------------------
// BannerToolsMyAcct
// -----------------------------------------------
function BannerToolsMyAcct(win)
{
if (userType == "Inst")
{
    gotoURL = rootDir + "banner_tools/my_account_instructor.htm";
}
else
{
    gotoURL = rootDir + "banner_tools/my_account_student.htm";
}
OpenSecWin(19, rootDir + "banner_tools/my_account_frame.htm");
}

// -----------------------------------------------
// CourseChange
// -----------------------------------------------
function CourseChange(win, courseCode)
{
OpenSecWin(22, rootDir + "course_list/change_course_frame.htm");
}

// -----------------------------------------------
// CourseCopy
// -----------------------------------------------
function CourseCopy(win)
{
OpenSecWin(13, rootDir + "course_list/copy_course_frame.htm");
}

// -----------------------------------------------
// CourseCreate
// -----------------------------------------------
function CourseCreate(win, mode)
{
if (mode == 1)
{
    OpenSecWin(13, rootDir + "course_list/create_first_course_frame.htm");
}
else if (mode == 2)
{
    OpenSecWin(13, rootDir + "course_list/create_course_frame.htm");
}
}

// -----------------------------------------------
// CourseDelete
// -----------------------------------------------
function CourseDelete(win)
{
win.confirm("Are you sure you want to remove Introduction to Accounting Fall 2005, Section 105c course from the My Course List page? Doing so will disassociate all students from the course, so that they can no longer access it. The course will also be removed from the My Course List page so that you can no longer access it or use it as a template for creation of new courses.");
}

// -----------------------------------------------
// CourseSettings
// -----------------------------------------------
function CourseSettings(win)
{
OpenSecWin(10, rootDir + "course_list/course_settings_frame.htm");
}

// -----------------------------------------------
// CrumbTrailAssignmentList
// -----------------------------------------------
function CrumbTrailAssignmentList(win)
{
win.location.replace(rootDir + "assignments/assignment_list.htm");
}

// -----------------------------------------------
// CrumbTrailCourseGradebook
// -----------------------------------------------
function CrumbTrailCourseGradebook(win)
{
if (userType == "Inst")
{
    win.location.replace(rootDir + "gradebook_inst/assn_" + currAssn + "_actv_" + currActv + "_" + currView + "_wgt_" + currWght + ".htm");
}
else
{
    currAssn = "all";
    currActv = "all";
    win.location.replace(rootDir + "gradebook_stud/gradebook_assn_" + currAssn + "_actv_" + currActv + "_" + currView + ".htm");
}
}

// -----------------------------------------------
// CrumbTrailCourseGradebookAssignment
// -----------------------------------------------
function CrumbTrailCourseGradebookAssignment(win)
{
currActv = "all";
win.location.replace(rootDir + "gradebook_stud/gradebook_assn_" + currAssn + "_actv_" + currActv + "_" + currView + ".htm");
}

// -----------------------------------------------
// CrumbTrailCourseGradebookStudent
// -----------------------------------------------
function CrumbTrailCourseGradebookStudent(win)
{
currActv = "all";
win.location.replace(rootDir + "gradebook_inst/" + currStud + "/assn_" + currAssn + "_actv_" + currActv + "_" + currView + "_wgt_" + currWght + ".htm");
}

// -----------------------------------------------
// CrumbTrailCourseGradebookStudentAssignment
// -----------------------------------------------
function CrumbTrailCourseGradebookStudentAssignment(win)
{
win.location.replace(rootDir + "gradebook_inst/" + currStud + "/assn_" + "01" + "/actv_" + currActv + "_" + currView + "_wgt_" + currWght + ".htm");
}

// -----------------------------------------------
// CrumbTrailCourseListInstructor
// -----------------------------------------------
function CrumbTrailCourseListInstructor(win)
{
win.location.replace(rootDir + "course_list/course_list_instructor.htm");
}

// -----------------------------------------------
// CrumbTrailCourseListStudent
// -----------------------------------------------
function CrumbTrailCourseListStudent(win)
{
if (dropAcknowledged)
{
    win.location.replace(rootDir + "course_list/course_list_student_02.htm");
}
else
{
    win.location.replace(rootDir + "course_list/course_list_student.htm");
}
}

// -----------------------------------------------
// CrumbTrailDataAnalysis
// -----------------------------------------------
function CrumbTrailDataAnalysis(win)
{
currAssn = "all";
currActv = "all";
win.location.replace(rootDir + 'data_analysis/course_' + currCrse + '_assn_' + currAssn + '_actv_' + currActv + '_attempt_' + currAtmp + '_' + scoringPref + '.htm');
}

// -----------------------------------------------
// CrumbTrailDataAnalysisAssignment
// -----------------------------------------------
function CrumbTrailDataAnalysisAssignment(win)
{
currActv = "all";
win.location.replace(rootDir + 'data_analysis/course_' + currCrse + '_assn_' + currAssn + '_actv_' + currActv + '_attempt_' + currAtmp + '_' + scoringPref + '.htm');
}

// -----------------------------------------------
// CrumbTrailHomeworkList
// -----------------------------------------------
function CrumbTrailHomeworkList(win)
{
win.location.replace(rootDir + 'homework/homework_list_' + currHmwkDate + '_past-due_' + currHmwkPastDue + '_practice_' + currHmwkPractice + '_' + currView + '.htm');
}

// -----------------------------------------------
// CrumbTrailProductList
// -----------------------------------------------
function CrumbTrailProductList(win)
{
win.location.replace(rootDir + "course_list/course_list_student.htm");
}

// -----------------------------------------------
// CustomerComments
// -----------------------------------------------
function CustomerComments(win)
{
OpenSecWin(8, rootDir + "customer_comments_frame.htm");
}

// -----------------------------------------------
// Integration
// -----------------------------------------------
function Integration(win, suffix)
{
OpenSecWin(8, rootDir + "integration_" + suffix + "_frame.htm");
}

function WebCTFAQ(win) 
{
    OpenSecWin(103, 'webct_faq_frame.htm');
}

function BlackboardFAQ(win) 
{
    OpenSecWin(103, 'blackboard_faq_frame.htm');
}

function WebCTDownloadAndInstall(win) 
{
    OpenSecWin(102, 'webct_download_frame.htm');
}

function BlackboardDownloadAndInstall(win) 
{
    OpenSecWin(102, 'blackboard_download_frame.htm');
}

function TechSupport(win) 
{
    OpenSecWin(113, 'http://www.swlearning.com/techsupport.html');
}

function PDFLink(win, URL) 
{
    OpenSecWin(110, URL);
}

function Privacy(win) 
{
    OpenSecWin(112, 'http://thomson.com/corp/privacy.jsp');
}

// -----------------------------------------------
// DataAnalysis
// -----------------------------------------------
function DataAnalysis(win)
{
currCrse = "01";
currAtmp = "last";
currAssn = "all";
currActv = "all";
win.location.replace(rootDir + 'data_analysis/course_' + currCrse + '_assn_' + currAssn + '_actv_' + currActv + '_attempt_' + currAtmp + '_' + scoringPref + '.htm');
}

// -----------------------------------------------
// DataAnalysisActivityDetail
// -----------------------------------------------
function DataAnalysisActivityDetail(win,assn,actv)
{
if (actv == "01")
{
    currActv = actv;
    win.location.replace(win.location.href.split("actv_all").join("actv_" + actv));
}
else
{
    win.alert("This is a prototype-only alert.\n\nOnly Exercise 1-1 is supported in this prototype.");
}
}

// -----------------------------------------------
// DataAnalysisAssignmentDetail
// -----------------------------------------------
function DataAnalysisAssignmentDetail(win,assn)
{
if (assn == "01")
{
    currAssn = assn;
    win.location.replace(win.location.href.split("assn_all").join("assn_" + assn));
}
else
{
    OnlyAssignment1(win);
}
}

// -----------------------------------------------
// DataAnalysisAttemptMenuChanged
// -----------------------------------------------
function DataAnalysisAttemptMenuChanged(win)
{
var m = win.document.forms[0].attempt_menu;
var newAtmp = m.options[m.selectedIndex].value;
win.location.replace(win.location.href.split("attempt_" + currAtmp).join("attempt_" + newAtmp));
currAtmp = newAtmp;
}

// -----------------------------------------------
// DataAnalysisCourseMenuChanged
// -----------------------------------------------
function DataAnalysisCourseMenuChanged(win)
{
var m = win.document.forms[0].course_menu;
var newSel = "";
var newCrse = "";
for (var op = 0; op < m.options.length; op++)
{
    if (m.options[op].selected)
    {
        if (newSel != "")
        {
            newSel += ",";
        }
        newSel += op;
    }
}
if (newSel == "0,3")
{
    newCrse = "mix";
}
else if (newSel == "0")
{
    newCrse = "01";
}
else if (newSel == "3")
{
    newCrse = "past";
}
if (newCrse != "")
{
    win.location.replace(win.location.href.split("course_" + currCrse).join("course_" + newCrse));
    currCrse = newCrse;
}
else
{
    win.alert('This is a prototype-only alert.\n\nOnly "Introduction to Accounting Fall 2005, Section 105c" and "All Past Courses Using This Textbook" are supported in this prototype.');
    for (var op = 0; op < m.options.length; op++)
    {
        m.options[op].selected = (win.oldCrseMenuSel.indexOf(op) != -1);
    }
}
}

// -----------------------------------------------
// DataAnalysisSwitchToPntsView
// -----------------------------------------------
function DataAnalysisSwitchToPntsView(win)
{
win.alert("This is a prototype-only alert.\n\nSwitch to points view will change the view in the Scores column to a points view as is done in the Gradebook. To help reduce the cost of this prototype, this feature is not demonstrated in Data Analysis.");
}

// -----------------------------------------------
// DemoInstructor
// -----------------------------------------------
function DemoInstructor(win)
{
win.alert("This is a prototype-only alert.\n\nThe user should be taken directly into the instructor demo, without requiring submission of user name and password; this submission of these items for validation should be done as part of the click of the Enter Instructor Demo link.\n\nAlso, the Course List for the instructor demo should show only the courses listed on the page where the instructor clicked \"Enter Instructor Demo\".");
}

// -----------------------------------------------
// DemoStudent
// -----------------------------------------------
function DemoStudent(win)
{
win.alert("This is a prototype-only alert.\n\nThe user should be taken directly into the student demo, without requiring submission of user name and password; this submission of these items for validation should be done as part of the click of the Enter Student Demo link.");
}

// -----------------------------------------------
// DroppedStudents
// -----------------------------------------------
function DroppedStudents(win)
{
OpenSecWin(18, rootDir + "student_roster/former_students_frame.htm");
}

// -----------------------------------------------
// CourseJoin
// -----------------------------------------------
function CourseJoin(win, courseCode)
{
OpenSecWin(22, rootDir + "course_list/join_course_frame.htm");
}

// -----------------------------------------------
// Disclaimer
// -----------------------------------------------
function Disclaimer(win)
{
ExtLink("http://www.thomson.com/corp/terms.jsp");
}

// -----------------------------------------------
// ExtLink
// -----------------------------------------------
function ExtLink(url)
{
OpenSecWin(99, url);
}

function footerLink(url)
{
OpenSecWin(31, url);
}

// -----------------------------------------------
// GradebookInstructor
// -----------------------------------------------
function GradebookInstructor(win, courseCode)
{
currActv = "all";
currAssn = "all";
currAtmp = "last";
currView = "perc";
win.location.replace(rootDir + 'gradebook_inst/assn_all_actv_all_' + scoringPref + '_wgt_on.htm');
}

// -----------------------------------------------
// GradebookStudent
// -----------------------------------------------
function GradebookStudent(win, courseCode)
{
if (courseCode != "T_I_3928")
{
    win.alert("This is a prototype-only alert.\n\nOnly the course that accompanies Accounting Concepts & Applications 9e by Albrecht, Stice, Stice is simulated in this prototype.");
}
else
{
    currActv = "all";
    currAssn = "all";
    currView = "perc";
    win.location.replace(rootDir + 'gradebook_stud/gradebook_assn_' + currAssn + '_actv_' + currActv + '_' + currView + '.htm');
}
}

// -----------------------------------------------
// GradebookExportPreview
// -----------------------------------------------
function GradebookExportPreview(win)
{
OpenSecWin(27, rootDir + "gradebook_inst/export_preview_frame.htm");
}

// -----------------------------------------------
// GradebookActivityMenuChanged
// -----------------------------------------------
function GradebookActivityMenuChanged(win)
{
var f = win.document.forms[0];
var actvSel = f.actv_menu.selectedIndex;

if ((actvSel != 0) && (actvSel != 1) && (actvSel != 2) && (actvSel != 5))
{
    win.alert("This is a prototype-only alert.\n\nOnly Exercise 1-1, Custom Activity, and Exercise 1-3 Algorithmic are simulated in this prototype.");
    f.actv_menu.selectedIndex = win.oldActvMenuSel;
}
else
{
    var nowLoc = "actv_" + currActv;
    var newLoc = "actv_" + f.actv_menu.options[actvSel].value;
    var newDest = win.location.href.split(nowLoc).join(newLoc);
    win.oldActvMenuSel = actvSel;
    currActv = f.actv_menu.options[actvSel].value;
    newDest = newDest.split(nowLoc).join(newLoc);
    win.location.replace(newDest);
}
}

// -----------------------------------------------
// GradebookAssignmentMenuChanged
// -----------------------------------------------
function GradebookAssignmentMenuChanged(win)
{
var f = win.document.forms[0];
var assnSel = f.assn_menu.selectedIndex;

if (assnSel > 1)
{
    OnlyAssignment1(win);
    f.assn_menu.selectedIndex = win.oldAssnMenuSel;
}
else
{
    var nowLoc = "assn_" + currAssn;
    var newLoc = "assn_" + f.assn_menu.options[assnSel].value;
    var newDest = win.location.href.split(nowLoc).join(newLoc);
    win.oldAssnMenuSel = assnSel;
    currAssn = f.assn_menu.options[assnSel].value;
    if (currAssn == "all")
    {
        newDest = newDest.split("actv_" + currActv).join("actv_all");
        currActv = "all";
        currAtmp = "all";
    }
    newDest = newDest.split(nowLoc).join(newLoc);
    win.location.replace(newDest);
}
}

// -----------------------------------------------
// GradebookAttemptMenuChanged
// -----------------------------------------------
function GradebookAttemptMenuChanged(win)
{
var f = win.document.forms[0];
var atmpSel = f.atmp_menu.selectedIndex;

if (atmpSel == 1)
{
    win.location.replace(win.location.href.split("attempt_01").join("attempt_02"));
}
else
{
    win.location.replace(win.location.href.split("attempt_02").join("attempt_01"));
}
}

// -----------------------------------------------
// GradebookInstructorOverrideEdit
// -----------------------------------------------
function GradebookInstructorOverrideEdit(win)
{
NA(win);
}

// -----------------------------------------------
// GradebookInstructorOverrideSet
// -----------------------------------------------
function GradebookInstructorOverrideSet(win, assn, actv)
{
gotoURL = rootDir + "gradebook_inst/override_score_01_" + currView + ".htm";
OpenSecWin(2, rootDir + "gradebook_inst/override_frame.htm");
}

// -----------------------------------------------
// GradebookRecordAllScores
// -----------------------------------------------
function GradebookRecordAllScores(win)
{
NA(win);
}

// -----------------------------------------------
// GradebookRecordStudentScores
// -----------------------------------------------
function GradebookRecordStudentScores(win)
{
win.confirm("Click the OK button to record as the current grade this student's most recent submission for each activity in this course.");
}

// -----------------------------------------------
// GradebookExportAll
// -----------------------------------------------
function GradebookExportAll(win)
{
NA(win);
}

// -----------------------------------------------
// GradebookExportCurrent
// -----------------------------------------------
function GradebookExportCurrent(win)
{
NA(win);
}

// -----------------------------------------------
// GradebookStudentActivityDetail
// -----------------------------------------------
function GradebookStudentActivityDetail(win, assn, actv, att)
{
if (actv == "00")
{
    win.alert("This is a prototype-only alert.\n\nTo view the results of these types of links in the prototype, go into the instructor Gradebook and go down to the Attempt level for Kelly Smith.");
}
else if (actv != "01")
{
    win.alert("This is a prototype-only alert.\n\nOnly Activities in Exercise 1-1 are simulated in this prototype.");
}
else
{
    win.location.replace(rootDir + "gradebook_inst/" + currStud + "/assn_" + assn + "/actv_" + actv + "/attempt_" + att + "_answ_off.htm");
}
}

// -----------------------------------------------
// GradebookStudentAssignmentDetail
// -----------------------------------------------
function GradebookStudentAssignmentDetail(win, assn)
{
if (assn != "01")
{
    OnlyAssignment1(win);
}
else
{
    win.location.replace(rootDir + "gradebook_inst/" + currStud + "/assn_" + assn + "/actv_" + currActv + "_" + currView + "_wgt_" + currWght + ".htm");
}
}

// -----------------------------------------------
// GradebookStudentDurationDetail
// -----------------------------------------------
function GradebookStudentDurationDetail(win, assn, actv, att)
{
if (actv == "00")
{
    win.alert("This is a prototype-only alert.\n\nTo view the results of these types of links in the prototype, go into the instructor Gradebook and go down to the Attempt level for Kelly Smith.");
}
else if ((assn != "01") || (actv != "01"))
{
    win.alert("This is a prototype-only alert.\n\nOnly the Exercise 1-1 durations are simulated in this prototype.");
}
else
{
    gotoURL = rootDir + "gradebook_inst/" + currStud + "/assn_" + assn + "/actv_" + actv + "/attempt_" + att + "_duration_detail.htm"
    OpenSecWin(28, rootDir + "gradebook_inst/duration_detail_frame.htm");
}
}

// -----------------------------------------------
// StudentGradebookAssignmentDetail
// -----------------------------------------------
function StudentGradebookAssignmentDetail(win, assn)
{
if (assn != "02")
{
    OnlyAssignment2(win);
}
else
{
    win.location.replace(rootDir + "gradebook_stud/gradebook_assn_" + assn + "_actv_all_" + currView + ".htm");
    currAssn = assn;
}
}

// -----------------------------------------------
// StudentGradebookActivityDetail
// -----------------------------------------------
function StudentGradebookActivityDetail(win, actv)
{
if ((actv == "2-1") || (actv == "2-2") || (actv == "2-7") || (actv == "2-8a"))
{
    win.location.replace(rootDir + "gradebook_stud/gradebook_assn_02_actv_" + actv + ".htm");
    currActv = actv;
}
else
{
    win.alert("This is a prototype-only alert.\n\nIn this prototype, only Exercise 2-1, Exercise 2-2, Exercise 2-7 and Exercise 2-8 Algorithmic are supported.");
}
}

// -----------------------------------------------
// GradebookStudentDetail
// -----------------------------------------------
function GradebookStudentDetail(win, stud)
{
if (stud != "Smith,Kelly")
{
    win.alert("This is a prototype-only alert.\n\nOnly Smith, Kelly is simulated in this prototype.");
}
else
{
    currStud = stud;
    win.location.replace(rootDir + "gradebook_inst/" + currStud + "/assn_" + currAssn + "_actv_" + currActv + "_" + currView + "_wgt_" + currWght + ".htm");
}
}

// -----------------------------------------------
// GradebookSwitchToPercView
// -----------------------------------------------
function GradebookSwitchToPercView(win)
{
win.location.replace(win.location.href.split("_pnts").join("_perc"));
currView = "perc";
}

// -----------------------------------------------
// GradebookSwitchToPntsView
// -----------------------------------------------
function GradebookSwitchToPntsView(win)
{
win.location.replace(win.location.href.split("_perc").join("_pnts"));
currView = "pnts";
}

// -----------------------------------------------
// GradebookToggleCorrectAnswers
// -----------------------------------------------
function GradebookToggleCorrectAnswers(win)
{
if (win.location.href.indexOf("answ_on") != -1)
{
    win.location.replace(win.location.href.split("answ_on").join("answ_off"));
}
else
{
    win.location.replace(win.location.href.split("answ_off").join("answ_on"));
}
}

// -----------------------------------------------
// Help
// -----------------------------------------------
function Help(win, topic, bannerText)
{
if ((typeof(topic) == "undefined") || (typeof(bannerText) == "undefined"))
{
    if ((typeof(win.helpTopic) == "undefined") || (typeof(win.helpBanner) == "undefined"))
    {
        if ((typeof(win.parent.main.helpTopic) == "undefined") || (typeof(win.parent.main.helpBanner) == "undefined"))
        {
            topic = "na";
            bannerText = "No Help for This Page";
        }
        else
        {
            topic = win.parent.main.helpTopic;
            bannerText = win.parent.main.helpBanner;
        }
    }
    else
    {
        topic = win.helpTopic;
        bannerText = win.helpBanner;
    }
}
helpBannerText = bannerText;
gotoURL2 = rootDir + "help/help_content_" + topic + ".htm";
OpenSecWin(21, rootDir + "help/help_frame.htm");
}

// -----------------------------------------------
// HelpIndex
// -----------------------------------------------
function HelpIndex(win)
{
win.parent.banner.location.replace(rootDir + "help_banner_index.htm");
win.parent.main.location = rootDir + "help_content_index.htm";
}

// -----------------------------------------------
// Homework
// -----------------------------------------------
function Homework(win, courseCode)
{
if (courseCode != "T_I_3928")
{
    win.alert("This is a prototype-only alert.\n\nOnly the course that accompanies Accounting Concepts & Applications 9e by Albrecht, Stice, Stice is simulated in this prototype.");
}
else
{
    currView = "perc";
    win.location.replace(rootDir + 'homework/homework_list_' + currHmwkDate + '_past-due_' + currHmwkPastDue + '_practice_' + currHmwkPractice + '_' + currView + '.htm');
}
}

// -----------------------------------------------
// HomeworkHidePastDue
// -----------------------------------------------
function HomeworkHidePastDue(win)
{
currHmwkPastDue = "off";
win.location.replace(win.location.href.split('past-due_on').join('past-due_off'));
}

// -----------------------------------------------
// HomeworkHidePractice
// -----------------------------------------------
function HomeworkHidePractice(win)
{
currHmwkPractice = "off";
win.location.replace(win.location.href.split('practice_on').join('practice_off'));
}

// -----------------------------------------------
// HomeworkOpen
// -----------------------------------------------
function HomeworkOpen(win, actv)
{
if ((actv == "2-1") || (actv == "2-2") || (actv == "2-7") || (actv == "2-8a"))
{
    win.location.replace(rootDir + "homework/homework_detail_" + actv + ".htm");
}
else
{
    win.alert("This is a prototype-only alert.\n\nIn this prototype, only Exercise 2-1, Exercise 2-2, Exercise 2-7 and Exercise 2-8 Algorithmic are supported.");
}
}

// -----------------------------------------------
// HomeworkShowPastDue
// -----------------------------------------------
function HomeworkShowPastDue(win)
{
currHmwkPastDue = "on";
win.location.replace(win.location.href.split('past-due_off').join('past-due_on'));
}

// -----------------------------------------------
// HomeworkShowPractice
// -----------------------------------------------
function HomeworkShowPractice(win)
{
currHmwkPractice = "on";
win.location.replace(win.location.href.split('practice_off').join('practice_on'));
}

// -----------------------------------------------
// Init
// -----------------------------------------------
function Init(win)
{
if (typeof(win.document.forms[0].assn_menu) != "undefined")
{
    if (currAssn == "all")
    {
        win.oldAssnMenuSel = 0;
    }
    else
    {
        win.oldAssnMenuSel = 1;
    }
    win.document.forms[0].assn_menu.selectedIndex = win.oldAssnMenuSel;
}
if (typeof(win.document.forms[0].actv_menu) != "undefined")
{
    if (currActv == "all")
    {
        win.oldActvMenuSel = 0;
    }
    else
    {
        win.oldActvMenuSel = currActv * 1;
    }
    win.document.forms[0].actv_menu.selectedIndex = win.oldActvMenuSel;
}
}

// -----------------------------------------------
// InstructorBenefits
// -----------------------------------------------
function InstructorBenefits(win)
{
OpenSecWin(5, rootDir + "learn_what_is_instructor_benefits_frame.htm");
}

// -----------------------------------------------
// InstructorManual
// -----------------------------------------------
function InstructorManual(win)
{
OpenSecWin(6, "http://www.swlearning.com/swmarketing/personaltrainer/PT4_IM.doc");
}

// -----------------------------------------------
// Interact
// -----------------------------------------------
function Interact(win, topic)
{
NA(win);
}

// -----------------------------------------------
// MinimumSystemRequirements
// -----------------------------------------------
function MinimumSystemRequirements(win)
{
OpenSecWin(7, rootDir + "minimum_system_requirements_frame.htm");
}

// -----------------------------------------------
// NA
// -----------------------------------------------
function NA(win)
{
win.alert("This feature is not yet available.");
}

// -----------------------------------------------
// OpenSecWin
// -----------------------------------------------
function OpenSecWin(winStyle, URL)
{
var winLf, winTp, winHt, winWd;
var openFeatures;
var win,winName;

if (!popups)
{
    top.alert("Please adjust pop-up blocking in your browser.");
}

// get full window size
if (browNet)
{
    if (platMac)
    {
        winHt = 470; winWd = 788;
    }
    else
    {
        winHt = 470; winWd = 788;
    }
}
else
{
    if (platMac)
    {
        winHt = 454; winWd = 772;
    }
    else
    {
        winHt = 451; winWd = 789;
    }
}

if (winStyle == 1)	// Score Weighting
{
    winLf = 0;
    winTp = 0;
    winHt -= 0;
    winWd = 400;
    winName = "ScoreWeighting";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 2)	// Score Override
{
    winLf = top.screenX;
    winTp = top.screenY;
    winHt = 250;
    winWd = 450;
    winName = "ScoreOverride";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 3)	// Available!
{
}
else if (winStyle == 4)	// Instructor Registration
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "InstructorRegistration";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 5)	// Benefits
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "Benefits";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 6)	// Manuals
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "Manual";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 7)	// Minimum System Requirements
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "MinimumSystemRequirements";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 8)	// Customer Comments
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "CustomerComments";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 9)	// Account Management Tool
{
    winLf = 0;
    winTp = 0;
    winHt = 450;
    winWd = 600;
    winName = "AccountManagementTool";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 10)	// Course Settings
{
    winLf = 0;
    winTp = 0;
    winHt = 530;
    winWd = 650;
    winName = "CourseSettings";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 11)	// Add/Edit an Assignment
{
    winLf = 0;
    winTp = 0;
    winHt = 530;
    winWd = 750;
    winName = "AddAssignment";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 12)	// Activity Preview
{
    winLf = 0;
    winTp = 0;
    winHt = 480;
    winWd = 650;
    winName = "ActivityPreview";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 13)	// Create a New Course, Copy Course
{
    winLf = 0;
    winTp = 0;
    winHt = 530;
    winWd = 650;
    winName = "CourseCreate";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 14)	// Edit Activity
{
    winLf = 0;
    winTp = 0;
    winHt = 530;
    winWd = 650;
    winName = "EditActivity";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 15)	// Add Question
{
    winLf = 0;
    winTp = 0;
    winHt = 450;
    winWd = 600;
    winName = "AddQuestion";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 16)	// Add Hint
{
    winLf = 0;
    winTp = 0;
    winHt = 300;
    winWd = 600;
    winName = "AddHint";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 17)	// Past Attempts
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 730;
    winName = "PastAttempts";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 18)	// Former Students
{
    winLf = 0;
    winTp = 0;
    winHt = 325;
    winWd = 600;
    winName = "DroppedStudents";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 19)	// Contact South-Western
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "MinimumSystemRequirements";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 20)	// Data Analysis pop-ups
{
    winLf = 0;
    winTp = 0;
    winHt = 300;
    winWd = 450;
    winName = "DataAnalysis";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 21)	// Help
{
    winLf = Math.min(screen.availWidth, 1280) - 400;
    winTp = 0;
    winHt = 400;
    winWd = 500;
    winName = "Help";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 22)	// Join / Change Course
{
    winLf = 0;
    winTp = 0;
    winHt = 300;
    winWd = 450;
    winName = "CourseChange";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 23)	// Edit Hints
{
    winLf = 0;
    winTp = 0;
    winHt = 450;
    winWd = 600;
    winName = "EditHints";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 24)	// Available!
{
}
else if (winStyle == 25)	// Calculator
{
    winLf = 0;
    winTp = 0;
    winHt = 400;
    winWd = 275;
    winName = "Calculator";
    openFeatures = "toolbar=no,status=no,resizable=no,menubar=no,scrollbars=no";
}
else if (winStyle == 26)	// Edit Assignment Due Date
{
    winLf = 0;
    winTp = 0;
    winHt = 325;
    winWd = 475;
    winName = "EditDueDate";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 27)	// Export Preview
{
    winLf = 0;
    winTp = 0;
    winHt = 500;
    winWd = 600;
    winName = "ExportPreview";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 28)	// Duration Detail
{
    winLf = 0;
    winTp = 0;
    winHt = 250;
    winWd = 400;
    winName = "DurationDetail";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 29)	// Page References List
{
    winLf = 0;
    winTp = 0;
    winHt = 300;
    winWd = 500;
    winName = "PageReferencesList";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 30)	// Page References
{
    winLf = 0;
    winTp = 0;
    winHt = 400;
    winWd = 600;
    winName = "PageReferences";
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 31)	// Footer link
{
    winLf = 0;
    winTp = 0;
    winHt = 450;
    winWd = 600;
    winName = "footer_link"; //note about UI.js footerLink();
    openFeatures = "toolbar=no,status=no,resizable=yes,menubar=no,scrollbars=yes";
}
else if (winStyle == 99) // External Link
{
    winLf = 0;
    winTp = 0;
    winHt = 450;
    winWd = 600;
    winName = "ExtLink";
    openFeatures = "toolbar=no,status=yes,resizable=yes,menubar=yes,scrollbars=yes";
}

// set size and location
openFeatures = openFeatures + ",height=" + winHt;
openFeatures = openFeatures + ",width=" + winWd;
openFeatures = openFeatures + ",left=" + winLf;
openFeatures = openFeatures + ",top=" + winTp;

// open the window
win = self.open(URL, winName, openFeatures, "");

// bring the window to the top
win.focus();
return win;
}

// -----------------------------------------------
// OnlyActivity1
// -----------------------------------------------
function OnlyActivity1(win)
{
win.alert("This is a prototype-only alert.\n\nOnly Exercise 1-1 is simulated in this prototype.");
}

// -----------------------------------------------
// OnlyAssignment1
// -----------------------------------------------
function OnlyAssignment1(win)
{
win.alert("This is a prototype-only alert.\n\nOnly Chapter 1 is simulated in this prototype.");
}

// -----------------------------------------------
// OnlyAssignment2
// -----------------------------------------------
function OnlyAssignment2(win)
{
win.alert("This is a prototype-only alert.\n\nOnly Chapter 2 is simulated in this prototype.");
}

// -----------------------------------------------
// OnlyAssignment24
// -----------------------------------------------
function OnlyAssignment24(win)
{
win.alert("This is a prototype-only alert.\n\nOnly Chapter 24 is simulated in this prototype.");
}

// -----------------------------------------------
// OnlyQuestion1
// -----------------------------------------------
function OnlyQuestion1(win)
{
win.alert("This is a prototype-only alert.\n\nOnly Question 1 is simulated in this prototype.");
}

// -----------------------------------------------
// OverrideScoreCancel
// -----------------------------------------------
function OverrideScoreCancel(win)
{
win.close();
}

// -----------------------------------------------
// OverrideScoreOK
// -----------------------------------------------
function OverrideScoreOK(win)
{
var newScoreStr = win.document.forms[0].new_score.value;
var newScoreVal = newScoreStr * 1;

if (newScoreStr != newScoreVal + "")
{
    win.alert("Please enter a number.");
}
else if ((newScoreVal > 6) || (newScoreVal < 0) || (newScoreVal != Math.round(newScoreVal)))
{
    win.alert("Please enter an integer in the range from 0 to 6.");
}
else
{
    win.close();
}
}

// -----------------------------------------------
// ProductNA
// -----------------------------------------------
function ProductNA(win)
{
//	win.alert("This is a prototype-only alert.\n\nThis link will not be enlivened in this prototype.");
}

// -----------------------------------------------
// PurchaseAccessCode
// -----------------------------------------------
function PurchaseAccessCode(win)
{
OpenSecWin(4, rootDir + "purchase_access_code_frame.htm");
}

// -----------------------------------------------
// QuestionAdd
// -----------------------------------------------
function QuestionAdd(win,quesNum)
{
addActvWin = win.top;
newQuestionNum = quesNum;
OpenSecWin(15, rootDir + "assignments/assn_add_question_frame.htm");
}

// -----------------------------------------------
// QuestionDelete
// -----------------------------------------------
function QuestionDelete(win)
{
win.confirm("Are you sure that you want to delete this question from this activity?");
}

// -----------------------------------------------
// QuestionEdit
// -----------------------------------------------
function QuestionEdit(win, quesNum)
{
if (quesNum == 1)
{
    gotoURL = rootDir + "assignments/assn_edit_question_mc.htm";
}
else if (quesNum == 2)
{
    gotoURL = rootDir + "assignments/assn_edit_question_tf.htm";
}
else if (quesNum == 3)
{
    gotoURL = rootDir + "assignments/assn_edit_question_sa.htm";
}
OpenSecWin(15, rootDir + "assignments/assn_edit_question_frame.htm");
}

// -----------------------------------------------
// QuestionMoveDown
// -----------------------------------------------
function QuestionMoveDown(win)
{
}

// -----------------------------------------------
// QuestionMoveUp
// -----------------------------------------------
function QuestionMoveUp(win)
{
}

// -----------------------------------------------
// QuestionPreview
// -----------------------------------------------
function QuestionPreview(win, quesNum)
{
OpenSecWin(12, rootDir + "assignments/question_preview_frame.htm");
}

// -----------------------------------------------
// RegisterAccessCode
// -----------------------------------------------
function RegisterAccessCode(win)
{
OpenSecWin(4, "https://ecomtools.thomsonlearning.com/olr/register/?template=http://ptrainer30.swlearning.com/ptrainer_olr_template.html");
}

// -----------------------------------------------
// RegistrationInstructor
// -----------------------------------------------
function RegistrationInstructor(win)
{
OpenSecWin(4, rootDir + "registration_instructor_frame.htm");
}

// -----------------------------------------------
// RoundToTwoPlaces
// -----------------------------------------------
function RoundToTwoPlaces(raw)
{
var cooked = Math.round(raw * 100) + "";
if (cooked.length == 1) cooked = "00" + cooked;
if (cooked.length == 2) cooked = "0" + cooked;
return cooked.substr(0,cooked.length-2) + "." + cooked.substr(cooked.length-2);
}

// -----------------------------------------------
// ScoreWeighting
// -----------------------------------------------
function ScoreWeighting(win, whichFooter)
{
equalized = equalizedSaved;
gotoURL  = rootDir + "weighting/assn_all_" + scoringPref + ".htm";
gotoURL2 = rootDir + "main/pop_up_footer_weighting_0" + whichFooter + ".htm";
OpenSecWin(1, rootDir + "weighting/weighting_frame.htm");
}

// -----------------------------------------------
// StudentBenefits
// -----------------------------------------------
function StudentBenefits(win)
{
OpenSecWin(5, rootDir + "learn_what_is_student_benefits_frame.htm");
}

// -----------------------------------------------
// StudentFooterText
// -----------------------------------------------
function StudentFooterText(win)
{
win.document.write(studentFooterText);
}

// -----------------------------------------------
// StudentManual
// -----------------------------------------------
function StudentManual(win)
{
OpenSecWin(6, "http://www.swlearning.com/swmarketing/personaltrainer/PT_student_guide_Updated.pdf");
}

// -----------------------------------------------
// StudentAttemptsHistory
// -----------------------------------------------
function StudentAttemptsHistory(win)
{
OpenSecWin(17, rootDir + "student_roster/attempts_history_frame.htm");
}

// -----------------------------------------------
// StudentAttemptsPendingAcceptance
// -----------------------------------------------
function StudentAttemptsPendingAcceptance(win)
{
OpenSecWin(17, rootDir + "student_roster/attempts_pending_frame.htm");
}

// -----------------------------------------------
// StudentRoster
// -----------------------------------------------
function StudentRoster(win)
{
win.location.replace(rootDir + 'student_roster/student_roster.htm');
}

// -----------------------------------------------
// StudentDrop
// -----------------------------------------------
function StudentDrop(win, studentNum)
{
var studName = "(unknown)";
if (studentNum == 1)
{
    studName = "Pat Jones";
}
else if (studentNum == 2)
{
    studName = "Kelly Smith";
}
win.confirm("Are you sure that you want to drop " + studName + " from this Introduction to Accounting Fall 2005, Section 105c course?");
}

// -----------------------------------------------
// Syllabus
// -----------------------------------------------
function Syllabus(win, courseCode)
{
ExtLink("http://noah.ship.edu/econ/e321/syllabus/");
}

// -----------------------------------------------
// WeightAssignmentDetail
// -----------------------------------------------
function WeightAssignmentDetail(win, assn)
{
var OK = true;
if (win.dataChanged)
{
    OK = win.top.confirm("You changed the settings on this page. Click the OK button to change the display in this window without saving the changes.");
    if (!OK)
    {
        win.document.forms[0].assn_menu.selectedIndex = win.oldAssnMenuSel;
    }
}
if (OK)
{
    if (assn == "01")
    {
        win.location.replace(win.location.href.split("assn_all").join("assn_01"));
    }
    else if (assn == "all")
    {
        win.location.replace(win.location.href.split("assn_01").join("assn_all"));
    }
    else
    {
        win.top.alert("This is a prototype-only alert.\n\nOnly Chapter 1 is simulated in this prototype.");
        win.document.forms[0].assn_menu.selectedIndex = win.oldAssnMenuSel;
    }
}
}

// -----------------------------------------------
// WeightClose
// -----------------------------------------------
function WeightClose(win)
{
var OK = true;
if (win.top.main.dataChanged)
{
    OK = win.top.confirm("You changed the settings on this page. Click the OK button to close this window without saving the changes.");
}
if (OK)
{
    win.top.close();
}
}

// -----------------------------------------------
// WeightDataOK
// -----------------------------------------------
function WeightDataOK(win)
{
var rtnVal = true;
if (scoringPref == "perc")
{
    var f = win.top.main.document.forms[0];
    var total = 0;
    for (var el = 1; el < f.elements.length; el++)
    {
        total += f.elements[el].value * 1;
    }
    total = RoundToTwoPlaces(total) * 1;
    if (total != 100)
    {
        win.top.alert("The total of the values you have provided is " + total + ". Please adjust the values to total 100.");
        rtnVal = false;
    }
}
return rtnVal;
}

// -----------------------------------------------
// WeightEqualizeActvWts
// -----------------------------------------------
function WeightEqualizeActvWts(win,auth)
{
if (equalized == 3)
{
    win.alert("These activity weights are already equalized.");
}
else
{
    if (!auth) auth = win.top.confirm("Click the OK button to set the activity percentages to equal values that add up to 100%. The assignment percentage will not be altered.");
    if (auth)
    {
        if (scoringPref == "perc")
        {
            var newValue = RoundToTwoPlaces(100 / (actvCounts[0] - 2));
            for (var x = 0; x < actvCounts[0]; x++)
            {
                if (win.actvWeightPerc[x] != -1)
                {
                    win.actvWeightPerc[x] = newValue;
                }
            }
            WeightEqualizeSmoothActvWts(win)
        }
        else
        {
            win.assnWeightPnts[0] = 0;
            for (var x = 0; x < actvCounts[0]; x++)
            {
                if (win.actvWeightPnts[x] != -1)
                {
                    win.actvWeightPnts[x] = 10;
                    win.assnWeightPnts[0] += 10;
                }
            }
        }
        win.UpdateValues();
        win.dataChanged = true;
    }
    equalized = 3;
}
}

// -----------------------------------------------
// WeightEqualizeAllActvWts
// -----------------------------------------------
function WeightEqualizeAllActvWts(win,auth)
{
if (equalized == 2)
{
    win.alert("All activity weights are already equalized.");
}
else
{
    if (!auth) auth = win.top.confirm("Click the OK button to set the activity percentages within each assignment to equal values that add up to 100%. The assignment percentages will be adjusted to ensure that all activities across the course have the same weight.");
    if (auth)
    {
        if (scoringPref == "perc")
        {
            var totalActivities = -2;	// 0;
            for (var x = 0; x < assnCount; x++)
            {
                totalActivities += actvCounts[x];
            }
            var newValue = RoundToTwoPlaces(100 / totalActivities);
            for (var x = 0; x < assnCount; x++)
            {
                if (x == 0)
                {
                    win.assnWeightPerc[x] = newValue * (actvCounts[x] - 2);
                }
                else
                {
                    win.assnWeightPerc[x] = newValue * actvCounts[x];
                }
            }
            WeightEqualizeSmoothAssnWts(win);
            WeightEqualizeActvWts(win,true);
        }
        else
        {
            for (var x = 0; x < assnCount; x++)
            {
                if (x == 0)
                {
                    win.assnWeightPnts[x] = 10 * (actvCounts[x] - 2);
                }
                else
                {
                    win.assnWeightPnts[x] = 10 * actvCounts[x];
                }
            }
            WeightEqualizeActvWts(win,true);
        }
    }
    equalized = 2;
}
}

// -----------------------------------------------
// WeightEqualizeAssnWts
// -----------------------------------------------
function WeightEqualizeAssnWts(win,auth)
{
if (equalized == 1)
{
    win.alert("These assignment weights are already equalized.");
}
else
{
    if (!auth) auth = win.top.confirm("Click the OK button to set the assignment percentages to equal values that add up to 100%. The activity percentages within each assignment will not be altered.");
    if (auth)
    {
        if (scoringPref == "perc")
        {
            var newValue = RoundToTwoPlaces(100 / assnCount);
            for (var x = 0; x < assnCount; x++)
            {
                win.assnWeightPerc[x] = newValue;
            }
            WeightEqualizeSmoothAssnWts(win);
        }
        else
        {
            var maxActvCount = 0;
            for (var x = 0; x < assnCount; x++)
            {
                if (actvCounts[x] > maxActvCount)
                {
                    maxActvCount = actvCounts[x];
                }
            }
            for (var x = 0; x < assnCount; x++)
            {
                win.assnWeightPnts[x] = maxActvCount * 10;
            }
            for (var x = 0; x < actvCounts[0]; x++)
            {
                if (win.actvWeightPnts[x] != -1)
                {
                    win.actvWeightPnts[x] = RoundToTwoPlaces(maxActvCount * 10 / (actvCounts[0] - 2));
                }
            }
        }
        win.UpdateValues();
        win.dataChanged = true;
    }
    equalized = 1;
}
}

// -----------------------------------------------
// WeightEqualizeSmoothActvWts
// -----------------------------------------------
function WeightEqualizeSmoothActvWts(win)
{
var total = 0;
var actv;

for (actv = 0; actv < actvCounts[0]; actv++)
{
    if (win.actvWeightPerc[actv] * 1 != -1)
    {
        total += win.actvWeightPerc[actv] * 1;
    }
}
if (total != 100)
{
    if (total < 100)
    {
        correction = 0.01;
    }
    else
    {
        correction = -0.01;
    }
    actv = 0;
    do
    {
        if (win.actvWeightPerc[actv] * 1 != -1)
        {
            win.actvWeightPerc[actv] = RoundToTwoPlaces(win.actvWeightPerc[actv] * 1 + correction);
            total = RoundToTwoPlaces(total * 1 + correction);
        }
        actv++;
        if (actv == actvCounts[0])
        {
            actv = 0;
        }
    }
    while (total != 100)
}
}

// -----------------------------------------------
// WeightEqualizeSmoothAssnWts
// -----------------------------------------------
function WeightEqualizeSmoothAssnWts(win)
{
var total = 0;
var assn;

for (assn = 0; assn < assnCount; assn++)
{
    total += win.assnWeightPerc[assn] * 1;
}
if (total != 100)
{
    if (total < 100)
    {
        correction = 0.01;
    }
    else
    {
        correction = -0.01;
    }
    assn = 0;
    do
    {
        win.assnWeightPerc[assn] = RoundToTwoPlaces(win.assnWeightPerc[assn] * 1 + correction);
        total = RoundToTwoPlaces(total * 1 + correction);
        assn++;
        if (assn == assnCount)
        {
            assn = 0;
        }
    }
    while (total != 100)
}
}

// -----------------------------------------------
// WeightSave
// -----------------------------------------------
function WeightSave(win)
{
if (WeightDataOK(win))
{
    win.top.main.SaveValues();
    equalizedSaved = equalized;
}
}

// -----------------------------------------------
// WeightPreview
// -----------------------------------------------
function WeightPreview(win)
{
if (win.top.main.dataChanged)
{
    if (WeightDataOK(win))
    {
        win.top.main.SaveValues();
        equalizedSaved = equalized;
    }
}
else
{
    win.top.alert("You have not made any changes since the last application of these settings, so nothing will happen to the gradebook when you click the OK button.");
}
}

// -----------------------------------------------
// WeightRevert
// -----------------------------------------------
function WeightRevert(win)
{
if (win.top.main.dataChanged)
{
    if (win.top.confirm("Click the OK button to roll back the changes you made to the settings on this page."))
    {
        win.top.main.LoadValues();
        equalized = equalizedSaved;
    }
}
else
{
    win.top.alert("You have not made any changes since the last save of these settings, so nothing will happen to these settings when you click the OK button.");
}
}

// -----------------------------------------------
// DataAnalysisAnsweredCorrectly
// -----------------------------------------------
function DataAnalysisAnsweredCorrectly(win, course, assignment, activity, question, attempt)
{
if (question == "01")
{
    gotoURL = rootDir + "data_analysis/correct.htm";
    OpenSecWin(20, rootDir + "data_analysis/correct_frame.htm");
}
else
{
    OnlyQuestion1(win);
}
}

// -----------------------------------------------
// DataAnalysisAnsweredCorrectlyBtm
// -----------------------------------------------
function DataAnalysisAnsweredCorrectlyBtm(win, course, assignment, activity, question, attempt)
{
if (question == "01")
{
    gotoURL = rootDir + "data_analysis/correct_btm.htm";
    OpenSecWin(20, rootDir + "data_analysis/correct_btm_frame.htm");
}
else
{
    OnlyQuestion1(win);
}
}

// -----------------------------------------------
// DataAnalysisAnsweredCorrectlyMid
// -----------------------------------------------
function DataAnalysisAnsweredCorrectlyMid(win, course, assignment, activity, question, attempt)
{
if (question == "01")
{
    gotoURL = rootDir + "data_analysis/correct_mid.htm";
    OpenSecWin(20, rootDir + "data_analysis/correct_mid_frame.htm");
}
else
{
    OnlyQuestion1(win);
}
}

// -----------------------------------------------
// DataAnalysisAnsweredCorrectlyTop
// -----------------------------------------------
function DataAnalysisAnsweredCorrectlyTop(win, course, assignment, activity, question, attempt)
{
if (question == "01")
{
    gotoURL = rootDir + "data_analysis/correct_top.htm";
    OpenSecWin(20, rootDir + "data_analysis/correct_top_frame.htm");
}
else
{
    OnlyQuestion1(win);
}
}

// -----------------------------------------------
// DataAnalysisAnsweredIncorrectly
// -----------------------------------------------
function DataAnalysisAnsweredIncorrectly(win, course, assignment, activity, question, attempt)
{
if (question == "01")
{
    gotoURL = rootDir + "data_analysis/incorrect.htm";
    OpenSecWin(20, rootDir + "data_analysis/incorrect_frame.htm");
}
else
{
    OnlyQuestion1(win);
}
}

// -----------------------------------------------
// DataAnalysisAttemptsAvg
// -----------------------------------------------
function DataAnalysisAttemptsAvg(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/attempt_avg_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/attempt_avg_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisAttemptsMax
// -----------------------------------------------
function DataAnalysisAttemptsMax(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/attempt_max_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/attempt_max_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisAttemptsMin
// -----------------------------------------------
function DataAnalysisAttemptsMin(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/attempt_min_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/attempt_min_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisQuestionsBad
// -----------------------------------------------
function DataAnalysisQuestionsBad(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/question_bad_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/question_bad_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisQuestionsGood
// -----------------------------------------------
function DataAnalysisQuestionsGood(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/question_good_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/question_good_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisQuestionsIneff
// -----------------------------------------------
function DataAnalysisQuestionsIneff(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/question_ineff_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/question_ineff_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisScoreAvg
// -----------------------------------------------
function DataAnalysisScoreAvg(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/score_avg_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/score_avg_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisScoreMax
// -----------------------------------------------
function DataAnalysisScoreMax(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/score_max_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/score_max_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// DataAnalysisScoreMin
// -----------------------------------------------
function DataAnalysisScoreMin(win, course, assignment, activity, attempt)
{
if ((activity == "all") || (activity == "01"))
{
    gotoURL = rootDir + "data_analysis/score_min_course_" + course + "_assn_" + assignment + "_actv_" + activity + "_attempt_" + attempt + ".htm";
    OpenSecWin(20, rootDir + "data_analysis/score_min_frame.htm");
}
else
{
    OnlyActivity1(win);
}
}

// -----------------------------------------------
// HomeworkHints
// -----------------------------------------------
function HomeworkHints(win,actvNum,hints)
{
var hintNum = (hints < 10 ? "0" + hints : hints);
gotoURL = rootDir + "homework/hints_" + actvNum + "_" + hintNum + ".htm";
OpenSecWin(29, rootDir + "homework/hints_" + actvNum + "_frame.htm");
}

// -----------------------------------------------
// HomeworkInstNotes
// -----------------------------------------------
function HomeworkInstNotes(win,actvNum)
{
OpenSecWin(29, rootDir + "homework/inst_notes_" + actvNum + "_frame.htm");
}

// -----------------------------------------------
// HomeworkWarmup
// -----------------------------------------------
function HomeworkWarmup(win,actvNum)
{
OpenSecWin(29, rootDir + "homework/warmup_" + actvNum + "_frame.htm");
}

// -----------------------------------------------
// HomeworkPageRefs
// -----------------------------------------------
function HomeworkPageRefs(win,actvNum)
{
OpenSecWin(29, rootDir + "homework/page_ref_actv_" + actvNum + "_frame.htm");
}

// -----------------------------------------------
// HomeworkPageRef
// -----------------------------------------------
function HomeworkPageRef(win,actvNum,pageRef)
{
OpenSecWin(30, rootDir + "pdf/page_ref_actv_" + actvNum + "_page_" + pageRef + ".pdf");
}

// -----------------------------------------------
// HomeworkReset
// -----------------------------------------------
function HomeworkReset(win)
{
win.alert("This is a prototype-only alert.\n\nReset will work as one would expect, including (unlike PT3) clearing any text edit fields into which the user has added data.");
}

// -----------------------------------------------
// HomeworkSpellCheck
// -----------------------------------------------
function HomeworkSpellCheck(win)
{
NA(win);
}

// -----------------------------------------------
// HomeworkSave
// -----------------------------------------------
function HomeworkSave(win)
{
win.alert("Your changes have been saved, but have not been submitted to your instructor. This saved version will never be submitted to the instructor unless you make the submission.");
}

// -----------------------------------------------
// HomeworkSubmit
// -----------------------------------------------
function HomeworkSubmit(win, actvNum)
{
if (actvNum == "2-1")
{
    win.alert("To see a new attempt submission in this prototype, submit the unfinished Attempt 1 of Activity 2-7.");
}
}

// -----------------------------------------------
// HomeworkNext
// -----------------------------------------------
function HomeworkNext(win)
{
win.alert("This is a prototype-only alert.\n\nIn the final product, this link will take the user to the next (in the Activity table on the Homework Home page) non-recorded activity that has not yet been attempted. Like all of the navigate-away links, if there are unsaved changes, the links will prompt with an option to save changes before allowing the user to navigate away.");
}

