"
+ );
+*/
+
+ jQuery.validator.addClassRules("selectRequired", {
+ selectNone: true
+ });
+
+ jQuery.validator.addClassRules("daysRequire", {
+ daysRequired: true
+ });
+
+ jQuery(document).ready(function() {
+ //--------------------------------------------------
+ // Validates the form (pre-submission check)
+ //--------------------------------------------------
+ jQuery('#scheduleForm').validate({
+ debug: false,
+ });
+
+
+ var classNum = 0;
+ var sectionsOfClass = new Array(); // holds number of sections for each class
+
+ //--------------------------------------------------
+ // Returns the common inputs for each new section.
+ //--------------------------------------------------
+ function getCommonInputs(cnum) {
+ var snum = sectionsOfClass[cnum];
+
+ var result = '
\
+
\
+ \
+
\
+
\
+
\
+
\
+
\
+
\
+
';
+
+ return result;
+ }
+
+ //--------------------------------------------------
+ // Adds a new class to the input.
+ //--------------------------------------------------
+ function addRow(){
+ sectionsOfClass[classNum] = 0; // This is class 0, initialize at 0
+ jQuery('#jsrows').append('
' + getCommonInputs(classNum) + '
');
+ classNum++;
+ };
+
+ addRow(); // Add initial row
+
+ //--------------------------------------------------
+ // Adds a new class when the add class button is
+ // clicked.
+ //--------------------------------------------------
+ jQuery('#classage').click(function() {
+ addRow();
+ });
+
+ //--------------------------------------------------
+ // Deletes the selected class from input.
+ //--------------------------------------------------
+ jQuery('.deleteClass').live('click', function() {
+ jQuery('.class'+ jQuery(this).parent().parent().attr("title")).remove();
+ });
+
+ //--------------------------------------------------
+ // Deletes the selected section from the input.
+ //--------------------------------------------------
+ jQuery('.deleteSection').live('click', function() {
+ sectionsOfClass[jQuery(this).parent().parent().attr("title")]--; // TODO: this only decreases the number of classes, so php should loop until this number of classes is found in the array
+ jQuery(this).parent().parent().remove();
+ });
+
+ //--------------------------------------------------
+ // Adds a section to the selected class.
+ //--------------------------------------------------
+ jQuery('.addSection').live('click', function() {
+ sectionsOfClass[jQuery(this).parent().parent().attr("title")]++; // Increases sectionsOfClass[classNum]
+ jQuery(this).parent().parent().after('