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

<?cs #################################
     # count will be used to count the number of menu items we have placed
     # within a later 'each' loop
     ################################
?>

<?cs set:count = #0 ?>


<?cs ################################
     #  set 'first_col' to the number of menu items we want
     # to place in the first column of our two-column table
     ################################
?> 

<?cs set:first_col = (#button_count / #2) ?>
<?cs if:(#button_count % 2) ?>
   <?cs set:first_col = first_col + #1 ?>
<?cs /if ?>



<?cs ###############################
     # a macro to return the html img src=".." tag for a given module
     ###############################
?>

<?cs def:button_image(module_name, is_unread) ?><img src="<?cs var:image_path ?><?cs if:is_unread ?>red_<?cs /if ?><?cs var:module_name ?>.gif" alt="<?cs var:lang.main_menu[module_name] ?>" width="202" height="27" /><?cs /def ?>



<?cs #############################
     # a macro that returns all the code needed to insert a button into the menu
     #############################
?>
<?cs def:insert_button(module_name, is_unread, url) ?><table><tr><td><a href="<?cs var:url ?>" title="<?cs var:lang.main_menu[module_name] ?>"><?cs call:button_image(module_name,is_unread) ?></a></td></tr></table><?cs /def ?>






<?cs ###########################
     # HTML starts here
     ###########################
?>

<?cs call:html_heading() ?>
<head>
<title><?cs var:course_title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="StyleSheet" href="<?cs var:image_path ?>common.css" type="text/css"  />
</head>
<?cs if:is_template ?>
    <body style="background-image:url(<?cs var:image_path ?>template_spiral.gif)">
<?cs else ?>
   <?cs call:define_body() ?>
<?cs /if ?>


<table width="100%">
<tr><td align="center">
<table border="0">
<tr>
 <?cs if:is_faculty && classroom_locked ?>
  <td width="25%">
     <img src="<?cs var:image_path ?>attach_locked.gif" alt=""/>
  </td>
 <?cs /if ?>
 <td>
   <p class="course_title">
    <?cs var:course_no ?> - <?cs var:semester ?><br />
    <?cs var:course_title ?> - <?cs var:instructor ?>
  </p>
 </td>
 <?cs if:is_faculty && classroom_locked ?>
  <td width="25%">
    <fieldset>
     <?cs var:lang.main_menu.classroom_locked ?>
    </fieldset>
  </td>
 <?cs /if ?>
</tr>
</table>
</td></tr></table>

<table width="100%">
<tr><td align="center">
 
<table border="0">
 <tr>
 <td>

 <?cs each:this = item ?>
     <?cs call:insert_button(this.module, this.is_unread, this.url)  ?>
     <?cs set:count = count + #1 ?>
     <?cs if:count == (#first_col) ?>
         </td><td>
     <?cs /if ?>
 <?cs /each ?>

 </td>
 </tr>




 <tr>
 <?cs if:change_password_url ?>
 <td>
    <a href="<?cs var:change_password_url ?>" title="<?cs var:lang.main_menu.change_password ?>"><img src="<?cs var:image_path ?>passwd.gif" width="202" height="27" alt="<?cs var:lang.main_menu.change_password ?>" /></a>
 <?cs elif:config_url ?>
 <td>
   <a href="<?cs var:config_url ?>" title="<?cs var:lang.main_menu.configuration ?>"><img src="<?cs var:image_path ?>config.gif" width="202" height="27" alt="<?cs var:lang.main_menu.configuration ?>"  /></a>
 </td>
<?cs /if ?>

 <?cs if:config_url ?>
 <td>
 <?cs if:exit_url ?><a href="<?cs var:exit_url ?>" title="Exit this classroom"><?cs /if ?><img src="<?cs var:image_path ?>exit.gif" width="202" height="27" alt="exit" /><?cs if:exit_url ?></a><?cs /if ?>
</td>
<?cs else ?>
 <td colspan="2" align="center">
 <?cs if:exit_url ?><a href="<?cs var:exit_url ?>" title="Exit this classroom"><?cs /if ?><img src="<?cs var:image_path ?>exit.gif" width="202" height="27" alt="exit" /><?cs if:exit_url ?></a><?cs /if ?>
 </td>
<?cs /if ?>
</tr>

<?cs if:config_url && change_password_url ?>
  <tr><td colspan="2" align="center">
   <a href="<?cs var:config_url ?>" title="<?cs var:lang.main_menu.configuration ?>"><img src="<?cs var:image_path ?>config.gif" width="202" height="27" alt="<?cs var:lang.main_menu.configuration ?>"  /></a>
  </td></tr>
<?cs /if ?>
</table>
</td>
</tr>
</table>


</body>
</html>
<?cs call:runtime() ?>
