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

<?cs #############################
     # a macro one slot 
     #############################
?>
<?cs def:one_slot(some_hour) ?>
  <?cs loop:x= #0, #55, #5 ?>
    <tr>
       <?cs if:some_hour.am == "PM" ?>
         <?cs set:real_hour = #some_hour.hour + #12 ?>
       <?cs else ?>
         <?cs set:real_hour = #some_hour.hour ?>
       <?cs /if ?>
       <td class="cellbg" style="width:50px" align="center">
          <span class="small"><?cs var:some_hour.hour ?>:<?cs if:x < #10 ?>0<?cs /if ?><?cs var:x ?> <?cs var:lang.calendar_slot.ampm[some_hour.am] ?></span></td>
         <?cs if:x < #10 ?>
           <?cs set:index = real_hour + ":" + "0" + x + lang.calendar_slot.ampm[some_hour.am] ?>
         <?cs else  ?>
           <?cs set:index = real_hour + ":" + x + lang.calendar_slot.ampm[some_hour.am] ?>
         <?cs /if ?>
         <?cs if:event[index].title ?>
         <td class="cellevent">
          <a class="slot" href="javascript:openBrWindow('<?cs var:event[index].titleurl ?>', '<?cs var:winname ?>')" title="<?cs var:lang.calendar_slot.view_event ?>">
          <?cs var:event[index].title ?>
          </a>
       </td>
       <?cs elif:some_hour.url ?>
         <td class="cellbg">
          <a class="slot" href="javascript:openBrWindow('<?cs var:some_hour.url ?><?cs if:x < #10 ?>0<?cs /if ?><?cs var:x ?>', '<?cs var:winname ?>')" title="<?cs var:lang.calendar_slot.add_new_event ?>" >
          <img src="<?cs var:image_path ?>da.gif" style="width:32px; height:10px;  border:0px" alt="" />
          </a>
          </td>
        <?cs else ?>
          <td class="cellbg">
          <img src="<?cs var:image_path ?>da.gif" style="width:32px; height:10px; border:0px" alt="" />
          </td>
        <?cs /if ?>
   </tr>
  <?cs /loop ?>
<?cs /def ?>



<?cs #############################
     # a macro that prints hour slots 
     #############################
?>
<?cs def:hour() ?>
 <table border="0" cellpadding="0" cellspacing="1" style="background: #CCCCCC" width="220">
  <?cs each:item = slot ?> 
    <?cs call:one_slot(item) ?>
  <?cs /each ?>
 </table>
<?cs /def ?>



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

<?cs call:html_heading() ?>
<head>
<title><?cs var:course_title ?> <?cs var:course_no ?> <?cs var:lang.calendar.title ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="StyleSheet" href="<?cs var:image_path ?>calendar_style.css" type="text/css"  />
<script type="text/javascript">
function openBrWindow(some_url,winname)
{
var new_window = window.open(some_url, winname,'menubar=0,toolbar=0,status=0,scrollbars=yes,resizable=yes,width=500,height=600');
new_window.focus();
}
</script>
</head>
<?cs call:define_body() ?> 
<table border="0" cellpadding="0" cellspacing="0"  width="220">
<tr><td>
   <?cs call:hour() ?>
</td></tr>
</table>
</body>
</html>
<?cs call:runtime() ?>
