<?cs include:"super_util.cs" ?>

<?cs def:print_check(data, i) ?>
  <td><input type="checkbox" name="c<?cs var:i ?>_orig_id" id="c<?cs var:i ?>_orig_id" value="<?cs var:data.org_id ?>"   /></td> 
<?cs /def ?>




<?cs def:print_cell(value, new_course) ?>
  <td <?cs if:!new_course ?>style="font-weight:bold; font-style:italic"<?cs /if ?>><?cs var:value ?></td>
<?cs /def ?>



<?cs def:print_teacher(crs, new_course) ?>
  <td <?cs if:!new_course ?>style="font-weight:bold; font-style:italic"<?cs /if ?>>
  <?cs set:i = #0 ?>
  <?cs each:one = crs.faculty ?>
  <?cs if:i != #0 ?>
    <br />
  <?cs /if ?>
   <?cs var:one.fname ?> <?cs var:one.lname ?>  
  <?cs set:i = i + #1 ?>
  <?cs /each ?>
 </td>
<?cs /def ?>


<?cs def:print_text(name, one_crs, size, help, max) ?>
  <td>
    <input type="text" name="<?cs var:name ?>" value="<?cs var:one_crs ?>" size="<?cs var:size ?>" maxlength="<?cs var:max ?>" title="<?cs var:help ?>"  />
  </td> 
<?cs /def ?>




<?cs def:print_hidden_text(name, one_crs ) ?>
  <td style="font-weight:bold; font-style:italic">
    <input type="hidden" name="<?cs var:name ?>" value="<?cs var:one_crs ?>"   />
    <?cs var:one_crs ?>
  </td> 
<?cs /def ?>





<?cs def:print_subtext(name, one_crs, size, help, max) ?>
  <td>
    <input type="hidden" name="<?cs var:name ?>_subdir_or" value="<?cs var:one_crs ?>" />
    <input type="text" name="<?cs var:name ?>_subdir" value="<?cs var:one_crs ?>" size="<?cs var:size ?>" maxlength="<?cs var:max ?>" title="<?cs var:help ?>"  />
  </td> 
<?cs /def ?>

<?cs def:print_hidden_subtext(name, one_crs) ?>
  <td style="font-weight:bold; font-style:italic">
    <input type="hidden" name="<?cs var:name ?>_subdir_or" value="<?cs var:one_crs ?>" />
    <input type="hidden" name="<?cs var:name ?>_subdir" value="<?cs var:one_crs ?>"   />
    <?cs var:one_crs ?>
  </td> 
<?cs /def ?>

<?cs def:print_course_opt(name) ?>
 <td>
   <select name="<?cs var:name ?>" title="<?cs var:lang.super_xml_create_courses.help[0] ?>"  >
   <?cs each:this = lang.super_xml_create_courses.type ?>
    <option value="<?cs var:this.msg ?>"><?cs var:this.msg ?></option>
  <?cs /each ?>
  </select>
 </td>
<?cs /def ?>





<?cs def:print_course_type(name, crs) ?>
 <td style="font-weight:bold; font-style:italic">
   <input type="hidden" name="<?cs var:name ?>" value="<?cs var:lang.super_xml_create_courses.type[crs.type].msg ?>" />
    <?cs var:lang.super_xml_create_courses.type[crs.type].msg ?>
 </td>
<?cs /def ?>





<?cs def:print_submit_button(data) ?>
  <td colspan="8" align="center">
   <input type="submit" value="<?cs var:data.msg ?>" title="<?cs var:data.help ?>"  />
  </td>
<?cs /def ?>
 

<?cs def:print_courses() ?>
  <?cs set:num = #1 ?>
  <?cs each:crs = sis_course ?>
   <tr>
      <?cs call:print_check(crs, num) ?>
      <?cs call:print_cell(crs.course_code, crs.new) ?>
      <?cs call:print_cell(crs.course_title, crs.new) ?>
      <?cs call:print_cell(crs.course_semester, crs.new) ?>
      <?cs set:name = "c" + num  ?>
      <?cs if:crs.new == #0 ?>
         <?cs call:print_hidden_subtext(name, crs.subdir) ?>
      <?cs else ?>
         <?cs call:print_subtext(name, crs.subdir, crs.subdir_length, lang.super_xml_create_courses.help[1], max_subdir) ?>
      <?cs /if ?>
 
      <?cs set:name = "c" + num + "_new_id" ?>
      <?cs if:crs.new == #0 ?>
         <?cs call:print_hidden_text(name, crs.id) ?>
      <?cs else ?>
         <?cs call:print_text(name, crs.id, crs.id_length, lang.super_xml_create_courses.help[2], max_id) ?>
      <?cs /if ?> 
      <?cs call:print_teacher(crs, crs.new) ?>
      <?cs set:name = "c" + num + "_type" ?>
      <?cs if:crs.new == #0 ?>
        <?cs call:print_course_type(name, crs) ?>
      <?cs else ?>
        <?cs call:print_course_opt(name) ?>
      <?cs /if ?>
   </tr>
  <?cs set:num = num + #1 ?>
  <?cs /each ?>
<?cs /def ?>

<?cs def:print_content() ?>
<table width="100%">
<tr><td align="center">
   <div><form method="post" action="super_xml_course_create" onsubmit="return course_list()" >
       <div><input type="hidden" name="id" value="<?cs var:Query.id ?>" />
      <input type="hidden" name="roster_path" value="<?cs var:roster_path ?>" />
      <input type="hidden" id="count" name="count" value="<?cs var:total_courses ?>" />
      </div>
   <table border="1" cellspacing="0" cellpadding="4">
     <caption>
      <b><a href="javascript:check_all()" title="<?cs var:lang.super_xml_create_courses.checkall ?>"><?cs var:lang.super_xml_create_courses.checkall ?></a> | <a href="javascript:uncheck_all()" title="<?cs var:lang.super_xml_create_courses.uncheckall ?>"><?cs var:lang.super_xml_create_courses.uncheckall ?></a></b><br /><br />
      <?cs var:lang.super_xml_create_courses.select ?>
     </caption>
     <tr>
      <?cs each:this = lang.super_xml_create_courses.label ?>
      <td class="table_heading"><?cs var:this ?></td>
      <?cs /each ?>
    </tr>
    <?cs call:print_courses() ?>
    <tr>
      <th colspan="8">
       <?cs var:lang.super_xml_create_courses.total ?> <?cs var:total_courses ?>
      </th>
    </tr>
    <tr>
      <?cs if:total_courses > #1 ?>
      <?cs call:print_submit_button(lang.super_xml_create_courses.button_2) ?>
      <?cs else ?>
      <?cs call:print_submit_button(lang.super_xml_create_courses.button_1) ?>
      <?cs /if ?> 
    </tr>
   </table>
  </form>
  <script type="text/javascript"> document.forms[0].c1_orig_id.focus(); </script>
  </div>
</td></tr>
</table>
<?cs /def ?>


<?cs call:html_header() ?>
   <head>
      <title><?cs var:lang.super_xml_create_courses.page_title ?></title>
   <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
   <link rel="StyleSheet" href="<?cs var:image_path ?>super_template.css" type="text/css"  />
   <link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
   <script type="text/javascript" src="<?cs var:image_path ?>xp_progress.js"></script>
   <?cs call:addDoIMenu() ?>
   <script type="text/javascript">
   function check_all()
   {
       var value = "_orig_id";
       var count = document.getElementById('count').value;
       var str;

       for(var i =1; i<= count; i++)
       {
          str = "c"+i + value;
          document.getElementById(str).checked = true;
	       
       }

   }
   function uncheck_all()
   {
       var value = "_orig_id";
       var count = document.getElementById('count').value;
       var str;

       for(var i =1; i<= count; i++)
       {
          str = "c"+i + value;
          document.getElementById(str).checked = false;
       }	       
   }

   function course_list()
   {
       var value = "_orig_id";
       var count = document.getElementById('count').value;
       var check_count = 0;
       var str;
       for(var i =1; i<= count; i++)
       {
          str = "c"+i + value;
          if(document.getElementById(str).checked)
             check_count++; 
       } 
       if(check_count)
       {
          var confirm =  window.confirm('<?cs var:lang.super_xml_create_courses.confirm_create_course_msg ?>');
          if(confirm == true)
          {
              bar1.showBar();
              scroll(0,0);
              return true;
          }
          else 
              return false;
       }
       else
       {
           window.alert('<?cs var:lang.super_xml_create_courses.no_course_selected ?>');
           return false;
       }
   } 
   </script>
  </head>
<?cs call:define_super_onload_onunload_body() ?>

<div id="container">
 <?cs call:top_container() ?>
 <?cs call:doIMenu() ?>
 <div id="content">
 <?cs call:print_content() ?>
 </div>
</div>
<script type="text/javascript">
     var bar1 = createBar( 'white', 1, 'black', 'blue', 85, 7, 3, "");
</script>

</body>
</html>

<?cs call:runtime() ?>
