var RebildScheduleOldSubmitFunction;
var RebildScheduleForm;
var filePath;
var ExtraParameter;
var modeTextBoxObj;
var locationListBoxObj;
var courseNumberTextBoxObj;
var scheduledTypeDropDownListObj
var criteriaListBoxObj

function CourseScheduleStartup(formID, newFilePath, newExtraParameter, modeTextBoxId, locationListBoxId, courseNumberTextBoxId, scheduledTypeDropDownListId, criteriaListBoxId)
{
	filePath = newFilePath;
	ExtraParameter = newExtraParameter
	modeTextBoxObj = document.all(modeTextBoxId);
	locationListBoxObj = document.all(locationListBoxId);
	courseNumberTextBoxObj = document.all(courseNumberTextBoxId);
	scheduledTypeDropDownListObj = document.all(scheduledTypeDropDownListId);
	criteriaListBoxObj = document.all(criteriaListBoxId);

	RebildScheduleForm = document.all(formID);
	RebildScheduleOldSubmitFunction = RebildScheduleForm.onsubmit;
	RebildScheduleForm.onsubmit = RebildSchedule_onsubmit;
}

function RebildSchedule_onsubmit()
{
	RebildScheduleForm.action = filePath
							+ '?m=' + modeTextBoxObj.value
							+ GetSelectedValues(criteriaListBoxObj,'c')
							+ GetSelectedValues(locationListBoxObj,'l')
							+ GetScheduledType()
							+ GetCourseNumber('text')
							+ ExtraParameter;
	if (RebildScheduleOldSubmitFunction == null)
		return true;
	else
		return RebildScheduleOldSubmitFunction();
}

function GetSelectedValues(listBoxObj, tagText)
{
	if (listBoxObj == null)
		return '';
	
	var TabMode = modeTextBoxObj.value;
	if (TabMode != 'Complete' && TabMode != 'Locked' && TabMode != 'Search')
	{
		var text = '';
		var options = new Enumerator(listBoxObj.options);
		for (;!options.atEnd();options.moveNext())
		{
			var option = options.item();
			if (option.selected)
			{
				text += '&' + tagText + '=' + escape(option.value);
			}
		}
		return text;
	}
	else
		return '';
}

function GetScheduledType()
{
	if (scheduledTypeDropDownListObj == null)
		return '';

	var TabMode = modeTextBoxObj.value;
	if (TabMode != 'Complete' && TabMode != 'Locked' && TabMode != 'Search')
		return '&s=' + escape(scheduledTypeDropDownListObj.options[scheduledTypeDropDownListObj.selectedIndex].value);
	else
		return '';
}

function GetCourseNumber(tagText)
{
	if (courseNumberTextBoxObj == null)
		return '';

	return '&' + tagText + '=' + escape(courseNumberTextBoxObj.value);
}

function NewScheduleMode(newTabMode)
{
	modeTextBoxObj.value = newTabMode;
	RebildScheduleForm.action = filePath
							+ '?m=' + modeTextBoxObj.value
							+ GetSelectedValues(locationListBoxObj,'l')
							+ GetScheduledType()
							+ ExtraParameter;
	RebildScheduleForm.submit();
}
