<?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 ?>
 <?cs call:print_course_heading(back_url, lang.news_read.back_button_title) ?>
 <?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 var:lang.news_read.gather_subtitle.USERNAME ?></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 elif:gather_target == "TOPIC" ?>
   <span class="alert_color"><?cs var:lang.news_read.gather_subtitle.TOPIC ?></span> <?cs var:target_escaped_topic_subject ?>
  <?cs /if ?>
   <br /><?cs  var:lang.news_read.msg_count_label ?> <?cs var:msg_count ?> 
    <?cs if:!printer_friendly ?>
        <a href="news_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 ?><?cs if:is_faculty && grp == 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>" title="<?cs var:lang.news_read.print_title ?>" onclick="newwin=window.open('news_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&amp;gather=_last_&amp;print=1&fixed=<?cs var:fixed_font ?><?cs if:is_faculty && grp == 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>','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 ?>" align="top" /></a>
        <div class="font_selector" >
         <?cs if:fixed_font ?>
           <a href="news_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&gather=_last_&amp;fixed=0<?cs if:is_faculty && grp== 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>" 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="news_gather?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;grp=<?cs var:grp ?>&amp;gather=_last_&amp;fixed=1<?cs if:is_faculty && grp == 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>" 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:attached_website(button, url, is_survey, m) ?>
<div>
 <?cs if:printer_friendly ?>
    <form action="">
        <input type="button" value="<?cs var:button ?>" />
    </form>
 <?cs elif:capture_mode ?>
    <a href="<?cs var:url ?>" ><?cs var:button ?></a>
 <?cs else ?>
    <form action="<?cs if:is_survey ?>survey_take_verify<?cs else ?>web_page_start<?cs /if ?>" method="post">
    <div>
    <?cs if:is_fac_teamteach ?><input type="hidden" name="team" value="<?cs var:team ?>" /><?cs /if ?>
    <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:m.sender ?>" />
    <input type="hidden" name="inf" value="<?cs var:m.info_fname ?>" />
    <input type="hidden" name="loc" value="<?cs var:m.offset ?>" />
    <?cs if:!is_survey ?>
      <input type="hidden" name="grp" value="<?cs var:grp ?>" />
      <input type="hidden" name="read" value="1" />
      <input type="hidden" name="from" value="news_gather" />
    <?cs /if ?>
    <input type="submit" name="submit" value="<?cs var:button ?>" />
    </div>
    </form>
 <?cs /if ?>
</div>
<?cs /def ?>


<?cs def:hotpot_exam(m) ?>
 <form action="">
  <input type="button" value="<?cs var:lang.news_read.start_exam_button ?>" <?cs if:!printer_friendly ?>onclick="window.location='<?cs var:m.hotpot_exam_url ?>'"<?cs /if ?> />
</form>
<?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:file_attachments(m) ?>
<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:m.attachments ?><?cs loop:i=#0, m.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:m.file[i].url ?>" ><?cs /if ?><?cs var:m.file[i].orig_fname ?><?cs if:!printer_friendly ?></a><?cs /if ?><?cs if:!printer_friendly && m.file[i].wimpy_button_url ?><?cs call:wimpy_button(i,m.file[i].wimpy_button_url) ?><?cs /if ?><?cs /loop ?><?cs /if ?></td>
</tr>
</table>
</div>
<?cs /def ?>




<?cs def:insert_unlock_attachments_form(m) ?>
  <table border="0">
  <tr>
  <td valign="middle"><img src="<?cs var:image_path ?>attach_locked.gif" /></td>
  <td><p><?cs var:lang.news_read.the_attachments ?></p>
  <?cs if:m.website_attached ?>
       <p><?cs var:lang.news_read.website_attached ?></p>
  <?cs else ?>
     <p>
     <?cs each:attachment=m.file ?>        
           <u><?cs var:attachment.orig_fname ?></u><br />
      <?cs /each ?>
     </p>
  <?cs /if ?>
  
  <?cs var:lang.news_read.have_been_locked ?>
 <form>
  <input type="button" value="<?cs var:lang.news_read.unlock_attachments_button ?>"
   <?cs if:!printer_friendly ?>onClick="window.location='<?cs var:m.unlock_url ?>'"<?cs /if ?> />
</form>
<?cs var:lang.news_read.unlock_attachments_read_msg_warning ?>
</td>
</tr>
</table>
<hr style="width:300px"/>

<?cs /def ?>




<?cs def:user_unlocked_info(m) ?>
<div>
<table border="5">
<tr><td><?cs var:lang.news_read.originally_locked ?><br />
<img src="<?cs var:image_path ?>unlock.gif" /><?cs var:lang.news_read.you_unlocked_attachments ?> <?cs var:m.time_read ?>
<td></tr>
</table>
</div>
<?cs /def ?>




<?cs def:report_unlock_problem (m) ?>
<br />
<table border="5">
<tr><td>
<dl>
  <dt><b><?cs var:lang.news_read.warning ?></b></dt>
  <dd><p><?cs var:lang.news_read.unlock_problem ?></p>
  <?cs var:lang.news_read.first_accessed_msg ?> <b><?cs var:m.time_read ?></b>
  </dd>
</dl>
</td></tr>
</table>
<?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_msg(m) ?>
<?cs if:printer_friendly ?><div style="margin-bottom:2em"><?cs else ?><div style="margin-left:<?cs var:m.indent * 2 ?>em; margin-bottom:2em;"><?cs /if ?>
<a name="<?cs var:m.offset ?>"></a>
<fieldset>
<?cs if:!printer_friendly ?>
<legend class="fieldset_legend">
<?cs if:can_write && m.reply_url ?><a href="<?cs var:m.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:m.info_url ?><a href="<?cs var:m.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="news_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:m.offset ?>&amp;grp=<?cs var:grp ?>&amp;print=1&amp;fixed=<?cs var:fixed_font ?><?cs if:is_faculty && grp == 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>" 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:m.offset ?>&amp;grp=<?cs var:grp ?>&amp;print=1&amp;fixed=<?cs var:fixed_font ?><?cs if:is_faculty && grp == 7 ?>&amp;team=<?cs var:Query.team ?><?cs /if ?>','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 ?>
<table border="0">
<tr><td class="message_header">
<b><?cs var:lang.news_read.posted_by_label ?></b> <?cs var:m.sender_realname ?><br />
<b><?cs var:lang.news_read.posted_date_label ?></b> <?cs var:m.time_sent ?>  

<?cs if:m.is_topic ?>
   <p><?cs if:group_uses_topic ?>
            <b><?cs var:lang.news_read.new_topic_label ?></b>
      <?cs else ?>
            <b><?cs var:lang.news_read.subject_label ?></b>
       <?cs /if ?>
    <?cs var:m.escaped_subject ?> <?cs if:!printer_friendly ?><?cs call:print_flag(m) ?><?cs /if ?>
  </p>
<?cs else ?>
   <p><b><?cs var:lang.news_read.topic_label ?></b> <?cs var:m.escaped_topic_subject ?><br />
      <b><?cs var:lang.news_read.subject_label ?></b> <?cs var:m.escaped_subject ?> <?cs if:!printer_friendly ?><?cs call:print_flag(m) ?><?cs /if ?>
   </p>
<?cs /if ?>
</td>

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


<?cs if:m.protected && is_faculty ?>
      <?cs call:print_msg_warning(lang.news_read.attachments_locked) ?>
<?cs /if ?>
</tr>
</table>

<?cs ## grp 5 is Internet Resources ### ?>
<?cs if:grp == #5 ?>
   <p><span class="regheading"><?cs var:lang.news_read.inet_resource_label?>  <?cs if:printer_friendly ?><?cs var:m.inet_link ?><?cs else ?><a href="<?cs var:m.inet_url ?>"><?cs var:m.inet_link ?></a><?cs /if ?></span>
  </p>
<?cs /if ?>


<?cs ## grp 5 is Internet Resources ### ?>
<?cs if:m.attachments_locked ?>
  <?cs call:insert_unlock_attachments_form(m) ?>
<?cs else ?>
 <?cs if:m.user_unlocked && grp != #5 ?>
    <?cs call:user_unlocked_info(m) ?>
 <?cs elif:m.protected && !is_faculty && m.time_read ?>
     <?cs call:report_unlock_problem(m) ?>
 <?cs /if ?>
<?cs /if ?>

<?cs if:!m.attachments_locked ?>
 <?cs if:m.hotpot_exam ?>
   <?cs call:hotpot_exam(m) ?>
 <?cs elif:m.website_attached ?>
   <?cs if:m.survey_url ?>
     <?cs call:attached_website(lang.news_read.take_survey_button, m.survey_url, #1, m) ?>
   <?cs else ?>
     <?cs call:attached_website(lang.news_read.view_website_button, m.normal_website_url, #0, m) ?>
   <?cs /if ?>
 <?cs elif:m.attachments ?>
     <?cs call:file_attachments(m) ?>
 <?cs /if ?>
<?cs /if ?>

<?cs if:fixed_font ?>
<div>
<pre>
<?cs each:row=m.line ?><?cs var:row.content ?>
<?cs /each ?>
</pre>
</div>
<?cs else ?>
<div style="text-indent:4em; margin-top:2em">
<?cs each:row=m.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 ?>
</fieldset>
</div>
<?cs /def ?>





<?cs def:print_topic(t) ?>
<div <?cs if:!printer_friendly ?>class=<?cs if:name(t) % 2 ?>"odd_gather_topic"<?cs else ?>"even_gather_topic"<?cs /if ?><?cs /if ?>>
 <?cs each:m = t.msg ?>
   <?cs call:print_msg(m) ?>
  <?cs /each ?>
<br /><?cs if:printer_friendly ?><hr size="5" /><br /><?cs /if ?>
</div>   
<?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() ?> 
