
/*---------------------------------------------------------------------------
	Copyright 2004-2005 Thomson Course Technology, a division of
	Thomson Learning, Inc. All rights reserved.
---------------------------------------------------------------------------*/

/**********************************************************************
handle_popup.js

The code on this page manages communication with a dialog box -- including
the dialog boxes through which the student and instructor online Help is
displayed.

**********************************************************************/

// Tracks the current dialog box opened from this page.
var dialogWin = new Object();
// Contains a refererence to the currently-open dialog.
var wnd;

// Tracks the current Help dialog box opened from this page.
var helpDialogWin = new Object();
// Contains a refererence to the currently-open Help dialog.
var helpWnd;

/**********************************************************************
Generates a dialog. Parameters:
    url -- URL of the page/frameset to be loaded into dialog
    width -- pixel width of the dialog
    height -- pixel height of the dialog
    returnFunc -- reference to the function (on this page)
                  that is to act on the data returned from the dialog
**********************************************************************/

function openDialog(url, width, height, returnFunc) {
    if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
           // Initialize the properties of the modal dialog object.
           dialogWin.returnFunc = returnFunc;
           dialogWin.url = url;
           dialogWin.width = width;
           dialogWin.height = height;
           // Keep the name unique so an existing dialog isn't overwritten.
           dialogWin.name = (new Date()).getSeconds().toString();
            // Assemble the window attributes and try to center the dialog.
	   dialogWin.left = (screen.width - dialogWin.width) / 2;
	   dialogWin.top = (screen.height - dialogWin.height) / 2;
	   var attr = "left=" + dialogWin.left + ",top=" +
	      dialogWin.top + ",resizable=no,scrollbars=yes,width=" +
			   dialogWin.width + ",height=" + dialogWin.height;

           // Generate the dialog and make sure it has focus.
           dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr);
	   wnd = dialogWin.win;
           dialogWin.win.focus();
    } else {
           dialogWin.win.focus();
    }
}

/**********************************************************************
Generates a dialog for the Reports. Parameters:
    url -- URL of the page/frameset to be loaded into dialog
    width -- pixel width of the dialog
    height -- pixel height of the dialog
    returnFunc -- reference to the function (on this page)
                  that is to act on the data returned from the dialog
**********************************************************************/

function openReportDialog(url, width, height, returnFunc) {
    if (!dialogWin.win || (dialogWin.win && dialogWin.win.closed)) {
           // Initialize the properties of the modal dialog object.
           dialogWin.returnFunc = returnFunc;
           dialogWin.url = url;
           dialogWin.width = width;
           dialogWin.height = height;
           // Keep the name unique so an existing dialog isn't overwritten.
           dialogWin.name = (new Date()).getSeconds().toString();
            // Assemble the window attributes and try to center the dialog.
	   dialogWin.left = (screen.width - dialogWin.width) / 2;
	   dialogWin.top = (screen.height - dialogWin.height) / 2;
	   var attr = "left=" + dialogWin.left + ",top=" +
	      dialogWin.top + ",resizable=yes,scrollbars=yes,width=" +
			   dialogWin.width + ",height=" + dialogWin.height;

           // Generate the dialog and make sure it has focus.
           dialogWin.win = window.open(dialogWin.url, dialogWin.name, attr);
	   wnd = dialogWin.win;
           dialogWin.win.focus();
    } else {
           dialogWin.win.focus();
    }
}


/**********************************************************************
Generates a dialog for the Help files. Parameters:
    url -- URL of the page/frameset to be loaded into dialog
    width -- pixel width of the dialog
    height -- pixel height of the dialog
    returnFunc -- reference to the function (on this page)
                  that is to act on the data returned from the dialog
**********************************************************************/

function openHelpDialog(url, width, height, returnFunc) {
    if (!helpDialogWin.win || (helpDialogWin.win && helpDialogWin.win.closed)) {
           // Initialize the properties of the modal dialog object.
           helpDialogWin.returnFunc = returnFunc;
           helpDialogWin.url = url;
           helpDialogWin.width = width;
           helpDialogWin.height = height;
            // Keep the name unique so an existing dialog isn't overwritten.
           helpDialogWin.name = (new Date()).getSeconds().toString();
           // Assemble the window attributes and try to center the dialog.
	   helpDialogWin.left = (screen.width - helpDialogWin.width) / 2;
	   helpDialogWin.top = (screen.height - helpDialogWin.height) / 2;
	   var attr = "left=" + helpDialogWin.left + ",top=" +
	      helpDialogWin.top + ",resizable=yes,scrollbars=yes,width=" +
	      helpDialogWin.width + ",height=" + helpDialogWin.height;

           // Generate the dialog and make sure it has focus.
           helpDialogWin.win = window.open(helpDialogWin.url, helpDialogWin.name, attr);
	   helpWnd = helpDialogWin.win;
           helpDialogWin.win.focus();
    } else {
           helpDialogWin.win.focus();
    }
}

//*********************************************************************************
//
// FUNCTION: OpenStudentHelp(String, Integer)
// DESCRIPTION:	This function displays the help dialog window for students.  The
//		'fusebox' variable is passed into the function as 'topic'.  Based
//		on this 'topic', the appropriate file is passed to the openDialog
//		function that actually displays the popup window.
//
// Revision : isiew - 11/2/2005 - passed in hasEbook value to determine academy or office products.
//*********************************************************************************

function OpenStudentHelp(topic, hasEbook)
{

	// This variable holds the directory and file to display
	var helpfile = "";

	if (hasEbook == 1)
		helpfile = "../help/academy/stu/help.htm?node=";
	else
		helpfile = "../help/office/stu/help.htm?node=";

	// Help for ASSIGNMENTS
	if (topic == "assignment_stu")
		helpfile += "11";

	// Help for REPORTS
	else if (topic == "report_stu")
		helpfile += "14";

	// Help for SECTIONS
	else if (topic == "section_stu")
		helpfile += "9";

	// Help for PROFILE
	else if (topic == "profile_stu")
	helpfile += "8";

	// Call the function below to display the actual window
	openHelpDialog(helpfile, 935, 550, null, 1);

}


//*********************************************************************************
//
// FUNCTION: OpenInstructorHelp(String, Integer)
// DESCRIPTION:	This function displays the help dialog window for Administrator and
//		instructors.  The 'fusebox' variable is passed into the function as
//		'topic'.  Based on this 'topic', the appropriate file is passed to
//		the openDialog function that actually displays the popup window.
//
// Revision : isiew - 11/2/2005 - passed in hasEbook value to determine academy or office products.
//*********************************************************************************

function OpenInstructorHelp(topic, hasEbook)
{
	// This variable holds the directory and file to display
		var helpfile = "";

		if (hasEbook == 1)
			helpfile = "../help/academy/adm_ins/help.html?node=";
		else
			helpfile = "../help/office/adm_ins/help.html?node=";

		// Help for SECTION
		if (topic == "section")
			helpfile += "25";

		// Help for PROFILE
		if (topic == "profile")
			helpfile += "12";

		// Help for USER
		else if (topic == "user")
			helpfile += "31";

		// Help for EXAM
		else if (topic == "exam")
			helpfile += "38";

		// Help for EXAM ADD
		else if (topic == "exam_add")
			helpfile += "41";

		// Help for EXAM MODIFY
		else if (topic == "exam_modify")
			helpfile += "46";

		// Help for EBOOK
		else if (topic == "ebook")
			helpfile += "50";

		// Help for TRAINING
		else if (topic == "training")
			helpfile += "52";

		// Help for TRAINING ADD
		else if (topic == "training_add")
			helpfile += "55";

		// Help for TRAINING MODIFY
		else if (topic == "training_modify")
			helpfile += "57";

		// Help for SCHEDULE
		else if (topic == "schedule")
			helpfile += "63";

		// Help for SCHEDULE EXAM ADD
		else if (topic == "schedule_exam_add")
		helpfile += "67";

		// Help for SCHEDULE TRAINING ADD
		else if (topic == "schedule_training_add")
		helpfile += "68";

		// Help for SCHEDULE SAM PATH ADD
		else if (topic == "schedule_sam_path_add")
		helpfile += "69";

		// Help for SCHEDULE EXAM MODIFY
		else if (topic == "schedule_exam_modify")
		helpfile += "70";

		// Help for SCHEDULE TRAINING MODIFY
		else if (topic == "schedule_training_modify")
		helpfile += "70";

		// Help for SCHEDULE SAM PATH MODIFY
		else if (topic == "schedule_sam_path_modify")
		helpfile += "70";

		// Help for SCHEDULE EBOOK ADD
		else if (topic == "schedule_ebook_add")
		helpfile += "70";

		// Help for REPORT
		else if (topic == "report")
			helpfile += "71";

		// Help for GROUP
		else if (topic == "group")
			helpfile += "76";

		// Help for ADMIN
		else if (topic == "admin")
			helpfile += "81";

		// Help for ADMIN MANAGE LOCATIONS
		else if (topic == "admin_manage_locations")
			helpfile += "81";

		// Help for ADMIN MANAGE LOCATIONS
		else if (topic == "admin_manage_database")
			helpfile += "81";

		// Help for ADMIN MANAGE LOCATIONS
		else if (topic == "admin_global_options")
			helpfile += "81";

		// Call the function below to display the actual window
		openHelpDialog(helpfile, 935, 550, null, 1);

}

//*********************************************************************************
//
// FUNCTION: displayNewProduct()
// DESCRIPTION:	This function is executed after a user has successfully added
//		a new product through the "Add Product" dialog.
//
//*********************************************************************************

function displayNewProduct(pDestPage) {
	if (pDestPage != "") {
		destinationPage = pDestPage + ".sam";
		document.location.href = destinationPage;
	}
	else
		document.forms[0].submit();
}


//*********************************************************************************
//
// FUNCTION: reviewExams()
// DESCRIPTION:	This function is executed after a user has successfully clicked
//		the "Review" button to open the client.
//
//*********************************************************************************

function reviewExams(pDestPage) {
	if (pDestPage != "") {
		destinationPage = pDestPage + ".sam";
		document.location.href = destinationPage;
	}
	else
		document.forms[0].submit();
}
