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


<?cs def:print_heading() ?>
<?cs if:printer_friendly ?>
  <div>
  <span class="course_name"><?cs var:course_no ?> <?cs var:course_title ?><br />
   <?cs var:semester ?></span> <i><?cs var:instructor ?> </i>
  </div>
<?cs else ?>
<table border="0" width="100%">
<tr><td>
 <?cs call:print_course_heading(back_url, lang.news_read.back_button_title) ?>
</td></tr>
</table>
 <?cs /if ?>
<?cs /def ?>





<?cs def:print_subheading() ?>
  <div class="center_msg">
  <?cs if:gather_target == "ALL"  ?>
      <span class="alert_color"><?cs var:lang.news_read.gather_subtitle.ALL ?></span>
  <?cs elif: gather_target == "USERNAME" ?>
       <span class="alert_color"><?cs if:gather_target_is_teacher ?><?cs var:lang.news_read.gather_subtitle.TEACHER_USERNAME ?><?cs else ?><?cs var:lang.news_read.gather_subtitle.ASSIGN_USERNAME ?><?cs /if ?></span> <?cs var:gather_target_realname ?>
  <?cs elif:gather_target == "UNREAD" ?>
   <span class="alert_color"><?cs var:lang.news_read.gather_subtitle.UNREAD ?></span>
  <?cs elif:gather_target == "FLAGGED" ?>
   <span class="alert_color"><?cs var:lang.news_read.gather_subtitle.FLAGGED ?></span>
  
  <?cs /if ?>
   
  <br /><span class="alert_color"><?cs if:gather_one_assignment ?><?cs var:lang.news_read.gather_subtitle.ONE_ASSIGNMENT ?></span> <?cs var:topic[0].escaped_topic_subject ?><?cs else ?><?cs var:lang.news_read.gather_subtitle.ALL_ASSIGNMENTS ?></span><?cs /if ?>
  <br /> 
 <?cs if:!printer_friendly ?>
    <a href="assign_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&amp;gather=_last_&amp;print=1&amp;fixed=<?cs var:fixed_font ?>" title="<?cs var:lang.news_read.print_title ?>" onclick="newwin=window.open('assign_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&amp;gather=_last_&amp;print=1&amp;fixed=<?cs var:fixed_font ?>','print','menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=760,height=500'); newwin.focus(); return false"><img src="<?cs var:image_path ?>print_sm.gif" width="135" height="17"  alt="<?cs var:lang.news_read.print_gather_title ?>"  /></a>
     <div class="font_selector" >
       <?cs if:fixed_font ?>
          <a href="assign_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&gather=_last_&amp;fixed=0" title="<?cs var:lang.news_read.print_proportional_title ?>"><?cs var:lang.news_read.print_proportional_label ?></a>/<?cs var:lang.news_read.print_fixed_label ?>
       <?cs else ?>
           <?cs var:lang.news_read.print_proportional_label ?>/<a href="assign_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&amp;gather=_last_&amp;fixed=1" title="<?cs var:lang.news_read.print_fixed_title ?>"><?cs var:lang.news_read.print_fixed_label ?></a>
       <?cs /if ?>   
     </div>
 <?cs /if ?>
  </div>
  <?cs if:printer_friendly ?><p /><?cs /if ?>
<?cs /def ?>






<?cs def:print_msg_warning(warning) ?>
  <td style="width:18em"><table border="0" ><tr><td valign="middle"><img src="<?cs var:image_path ?>warn.gif" alt=" " /></td><td><span style="color:red" ><?cs var:warning ?></span></td></tr></table></td>
<?cs /def ?>


<?cs def:flag_image(m) ?><img src="<?cs var:image_path ?><?cs if:m.flagged ?>flag.gif" alt="<?cs var:lang.news_read.flag_title ?>" width="14" height="14"  /><?cs else ?>noflag.gif" alt="<?cs var:lang.news_read.noflag_title ?>" width="14" height="14" /><?cs /if ?><?cs /def ?>


<?cs def:print_flag(m) ?><a href="<?cs var:m.flag_url ?>" title="<?cs var:lang.news_read.flag_link_title ?>" ><?cs call:flag_image(m) ?></a><?cs /def ?>




<?cs def:print_release_button(msg) ?>
<?cs with:lang=lang.news_read ?>
  <div class="center_msg">
   <div class="error"><?cs var:lang.release_instructions ?></div>
   <form method="post" action="hotpot_exam_release">
    <div>
        <input type="hidden" name="crs" value="<?cs var:crs ?>" />
        <input type="hidden" name="id" value="<?cs var:key ?>" />
        <input type="hidden" name="from" value="assign_gather|crs^<?cs var:crs ?>]id^<?cs var:key ?>]gather=_last_~<?cs var:msg.offset?>" />
        <input type="hidden" name="loc" value="<?cs var:msg.offset ?>" />
        <input type="submit" value="<?cs var:lang.release_button ?>" title="<?cs var:lang.release_button_title ?>" />
    </div>
   </form>
  </div> 
<?cs /with ?>
<?cs /def ?>




<?cs def:print_message_header(msg) ?>
<table border="0" width="100%">
<tr><td class="message_header">
<b><?cs var:lang.news_read.posted_by_label ?></b> <?cs if:user[0].url && !printer_friendly ?><a href="<?cs var:user[0].url ?>" title="<?cs var:lang.news_read.read_bio_title ?>"  onclick="newwin=window.open('<?cs var:user[0].url ?>','bio','menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=760,height=500'); newwin.focus(); return false"><?cs /if ?><?cs var:msg.sender_realname ?><?cs if:user[0].url ?></a><?cs /if ?><br />
<b><?cs var:lang.news_read.posted_date_label ?></b> <?cs var:msg.time_sent ?>  

<?cs if:msg.assign_open_time ?>
<br /><br />
<b><?cs var:lang.news_read.additional_teacher_info_label ?></b><br />
&nbsp;&nbsp;<span style="text-decoration:underline"><?cs var:lang.news_read.assignment_opened_label ?></span> <?cs var:msg.assign_open_time ?><br />
&nbsp;&nbsp;<span style="text-decoration:underline"><?cs var:lang.news_read.unlock_label ?></span> <?cs if:msg.user_unlocked ?><?cs var:lang.news_read.unlock_yes ?><?cs else ?><?cs var:lang.news_read.unlock_no ?><?cs /if ?><br />
&nbsp;&nbsp;<span style="text-decoration:underline"><?cs var:lang.news_read.elapsed_time_label ?></span> <?cs if:msg.open_elapsed_days ?><?cs var:msg.open_elapsed_days ?> <?cs var:lang.news_read.days_label ?> <?cs /if ?><?cs if:msg.open_elapsed_hours ?><?cs var:msg.open_elapsed_hours ?> <?cs var:lang.news_read.hours_label ?> <?cs /if ?><?cs var:msg.open_elapsed_minutes ?> <?cs var:lang.news_read.minutes_label ?><br />
<?cs /if ?>
<br />
<b><?cs var:lang.news_read.assignment_label ?></b> <?cs var:msg.escaped_topic_subject ?> <?cs if:msg.is_topic && !printer_friendly ?><?cs call:print_flag(msg) ?><?cs /if ?><br />
<?cs if:msg.is_topic ?><br /><b><?cs var:lang.news_read.this_is_assignment ?></b><br /><br /><?cs else ?><b><?cs var:lang.news_read.subject_label ?></b> <?cs var:msg.escaped_subject ?> <?cs if:!printer_friendly ?><?cs call:print_flag(msg) ?><?cs /if ?><br /><?cs /if ?>
<?cs if:msg.include_hotpot_release_form ?><?cs call:print_release_button(msg) ?><?cs /if ?>
</td>

<?cs ###
     ### Print warnings if this message is hidden,
     ### marked Student Read-only, or has its
     ### attachments locked
## ?>
<?cs if:msg.teacher_hidden ?>
   <?cs call:print_msg_warning(lang.news_read.teacher_hidden) ?>
<?cs elif:msg.read_only ?>
   <?cs call:print_msg_warning(lang.news_read.read_only) ?>
<?cs /if ?>
<?cs if:msg.protected ?>
      <?cs call:print_msg_warning(lang.news_read.attachments_locked) ?>
<?cs /if ?>

</tr>
</table>
<?cs /def ?>





<?cs def:print_hotpot_exam_form(msg) ?>
<div>
 <form action="">
  <div><input type="button" value="<?cs var:lang.news_read.start_exam_button ?>" <?cs if:!printer_friendly ?>onclick="window.location='<?cs var:msg.hotpot_exam_url ?>'"<?cs /if ?> /></div>
</form>
</div>
<?cs /def ?>





<?cs def:print_msg_body(msg) ?>
<?cs if:fixed_font ?>
<div>
<pre>
<?cs each:row=msg.line ?><?cs var:row.content ?>
<?cs /each ?>
</pre>
</div>
<?cs else ?>
<div style="text-indent:4em; margin-top:2em">
<?cs each:row=msg.line ?><div class="reply_level<?cs if:row.reply_level ?><?cs var:row.reply_level % #6 ?><?cs else ?>0<?cs /if ?>"><?cs var:row.content ?></div>
<?cs /each ?>
</div>
<?cs /if ?>
<?cs /def ?>




<?cs def:print_view_website_form(msg) ?>
  <div>
   <?cs if:printer_friendly ?>
      <form action="">
        <div><input type="button" value="<?cs var:lang.news_read.view_website_button ?>" /></div>
    </form>
 <?cs elif:capture_mode ?>
    <a href="<?cs var:url ?>" ><?cs var:normal_website_url ?><?cs var:lang.news_read.view_website_button ?></a>
 <?cs else ?>
  <form method="post" action="web_page_start">
    <div>
    <input type="hidden" name="crs" value="<?cs var:crs ?>" />
    <input type="hidden" name="id" value="<?cs var:key ?>" />
    <input type="hidden" name="sender" value="<?cs var:msg.sender ?>" />
    <input type="hidden" name="inf" value="<?cs var:msg.info_fname ?>" />
    <input type="hidden" name="grp" value="<?cs var:grp ?>" />
    <input type="hidden" name="read" value="1" />
    <input type="hidden" name="loc" value="<?cs var:msg.offset ?>" />
    <?cs if:student_username ?><input type="hidden" name="student" value="<?cs var:student_username ?>" /><?cs /if ?>
    <input type="hidden" name="from" value="assign_gather" />
    <input type="submit" value="<?cs var:lang.news_read.view_website_button ?>" title="<?cs var:lang.news_read.view_website_button_help ?>" />
    </div>
  </form>
<?cs /if ?>
</div>
<?cs /def ?>



<?cs def:wimpy_button(file_number, wimpy_button_url) ?>
<a href="javascript:window.open('<?cs var:wimpy_button_url ?>','litenewwin','resizable=yes,width=250,height=200,top=50,left=50,scrollbars=yes,toolbar=no'); newwin.focus()" ><img  src="<?cs var:image_path ?>Volume16.gif" /></a>  
<?cs /def ?>






<?cs def:print_file_attachments(msg) ?>
<div style="margin-top:1em">
<table border="0">
<tr>
<td valign="top"><b><?cs var:lang.news_read.attachments_label ?></b></td>
<td><?cs if:msg.attachments ?><?cs loop:i=#0, msg.attachments - #1, #1 ?><?cs if:i ?><?cs if:(i % 4) ?>,&nbsp;&nbsp;&nbsp;<?cs else ?>,<br /><?cs /if ?><?cs /if ?><?cs if:!printer_friendly ?><a href="<?cs var:msg.file[i].url ?>" ><?cs /if ?><?cs var:msg.file[i].orig_fname ?><?cs if:!printer_friendly ?></a><?cs /if ?><?cs if:!printer_friendly && msg.file[i].wimpy_button_url ?><?cs call:wimpy_button(i,msg.file[i].wimpy_button_url) ?><?cs /if ?><?cs /loop ?><?cs /if ?></td>
</tr>
</table>
</div>
<?cs /def ?>










<?cs def:print_msg(msg) ?>
<?cs if:printer_friendly ?><div style="margin-bottom:2em"><?cs else ?><div style="margin-left:<?cs var:msg.indent * 2 ?>em; margin-bottom:2em;"><?cs /if ?>
<a name="<?cs var:msg.offset ?>"></a>
<fieldset>
<?cs if:!printer_friendly ?>
<legend class="fieldset_legend">
<?cs if:can_write && msg.reply_url ?><a href="<?cs var:msg.reply_url ?>" title="<?cs var:lang.news_read.reply_title ?>"><img src="<?cs var:image_path ?>reply_sm.gif"  alt="<?cs var:lang.news_read.reply_title ?>" width="135" height="17" /></a><?cs else ?><img src="<?cs var:image_path ?>gr_reply_sm.gif"  alt="" width="135" height="17" /><?cs /if ?>
<?cs if:msg.info_url ?><a href="<?cs var:msg.info_url ?>" title="<?cs var:lang.news_read.info_title ?>"><img src="<?cs var:image_path ?>info_sm.gif" alt="<?cs var:lang.news_read.info_title ?>" width="135" height="17" /></a><?cs /if ?>
<a href="assign_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?>&amp;print=1&amp;fixed=<?cs var:fixed_font ?>" title="<?cs var:lang.news_read.print_title ?>" onclick="newwin=window.open('news_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?>&amp;print=1&amp;fixed=<?cs var:fixed_font ?>','print','menubar=yes,toolbar=yes,status=yes,scrollbars=yes,resizable=yes,width=760,height=500'); newwin.focus(); return false"><img src="<?cs var:image_path ?>print_sm.gif" width="135" height="17" alt="<?cs var:lang.news_read.print_title ?>" /></a>
</legend>
<?cs /if ?>

<?cs call:print_message_header(msg) ?>
<?cs if:msg.hotpot_exam ?>
   <?cs call:print_hotpot_exam_form(msg) ?>
<?cs elif:msg.website_attached ?>
  <?cs call:print_view_website_form(msg) ?>
<?cs elif:msg.file[0].url ?>
  <?cs call:print_file_attachments(msg) ?>
<?cs /if ?>

<?cs call:print_msg_body(msg) ?>
</fieldset>
</div>
<?cs /def ?>




<?cs def:print_student(s) ?>
   <div class="gather_name_heading"><?cs var:s.msg[0].receiver_realname ?></div>
 <?cs each:m = s.msg ?>
    <?cs call:print_msg(m) ?>
 <?cs /each ?>
<?cs /def ?>



<?cs def:print_topic(t) ?>
<?cs if:t.student[0].msg[0].escaped_subject ||
        ((t.escaped_subject) &&
        (gather_target != "USERNAME" || ((gather_target == "USERNAME") && gather_target_is_teacher))) ?>


<div <?cs if:!printer_friendly ?>class=<?cs if:name(t) % 2 ?>"odd_gather_topic"<?cs else ?>"even_gather_topic"<?cs /if ?><?cs /if ?>>

<?cs if:t.escaped_subject ?>
<?cs if:gather_target != "USERNAME" || ((gather_target == "USERNAME") && gather_target_is_teacher) ?>
   <?cs call:print_msg(t) ?> 
 <?cs elif: t.student[0].msg[0].escaped_subject ?>
   <?cs call:print_msg(t) ?> 
<?cs /if ?>
<?cs /if ?>

<?cs each:s = t.student ?>
    <?cs  call:print_student(s) ?>
<?cs /each ?>
<br /><?cs if:printer_friendly ?><hr size="5" /><?cs /if ?><br />
</div>   
<?cs /if ?>

<?cs /def ?>



<?cs call:html_heading() ?>
   <head>
      <title><?cs var:course_no ?> <?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 call:define_body() ?>

 <?cs call:print_heading() ?>
 <?cs call:print_subheading() ?>
 
 <?cs each:t = topic ?>
   <?cs call:print_topic(t) ?>
 <?cs /each ?>

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