<?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 if:is_inbox ?>
 <?cs call:print_course_heading(back_url, lang.post_read.inbox_back_button_title) ?>
   <?cs else ?>
 <?cs call:print_course_heading(back_url, lang.post_read.outbox_back_button_title) ?>
  <?cs /if ?>
<?cs /if ?>
<?cs /def ?>





<?cs def:print_subheading() ?>
  <div class="center_msg">
  <?cs if:is_inbox ?>
  <span class="alert_color"><?cs var:lang.post_read.inbox_subtitle[gather_target] ?> <?cs var:gather_target_realname ?></span>
  <?cs else ?>
  <span class="alert_color"><?cs var:lang.post_read.outbox_subtitle[gather_target] ?> <?cs var:gather_target_realname ?></span>
  <?cs /if ?>
   <br /><?cs  var:lang.post_read.msg_count_label ?> <?cs var:msg_count ?> <?cs if:!printer_friendly ?><a href="<?cs if:is_inbox ?>post_inbox_gather<?cs else ?>post_outbox_gather<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;gather=_last_&amp;print=1&amp;fixed=<?cs var:fixed_font ?>" title="<?cs var:lang.post_read.print_gather_title ?>" onclick="newwin=window.open('<?cs if:is_inbox ?>post_inbox_gather<?cs else ?>post_outbox_gather<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&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 ?>" align="top" /></a><?cs /if ?>
  <?cs if:!printer_friendly ?>
   <div class="font_selector" >
    <?cs if:fixed_font ?>
     <a href="<?cs if:is_inbox ?>post_inbox_gather<?cs else ?>post_outbox_gather<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&gather=_last_&amp;fixed=0" title="<?cs var:lang.post_read.print_proportional_title ?>"><?cs var:lang.post_read.print_proportional_label ?></a>/<?cs var:lang.post_read.print_fixed_label ?>
    <?cs else ?>
     <?cs var:lang.post_read.print_proportional_label ?>/<a href="<?cs if:is_inbox ?>post_inbox_gather<?cs else ?>post_outbox_gather<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;gather=_last_&amp;fixed=1" title="<?cs var:lang.post_read.print_fixed_title ?>"><?cs var:lang.post_read.print_fixed_label ?></a>
    <?cs /if ?>   
   </div>
   <?cs /if ?>
   </div>
  <?cs if:printer_friendly ?><p /><?cs /if ?>
<?cs /def ?>




<?cs def:print_recipients(label, count, list) ?>
<tr><td valign="top"><b><?cs var:label ?></b></td>
<td><?cs if:count ?><?cs loop:i=#0, count - #1, #1 ?><?cs if:i ?><?cs if:(i % 4) ?>, <?cs else ?>,<br /><?cs /if ?><?cs /if ?><?cs var:list[i] ?><?cs /loop ?><?cs /if ?></td>
</tr>
<?cs /def ?>



<?cs def:attached_website(the_msg) ?>
<div style="margin-top:1em">
<?cs if:printer_friendly ?>
    <form action="">
        <input type="button" value="<?cs var:lang.view_website_button ?>" />
    </form>
<?cs elif:capture_mode ?>
    <a href="<?cs var:the_msg.website_url ?>" title="<?cs var:lang.view_website_button_title ?>" ><?cs var:lang.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:the_msg.sender ?>" />
    <input type="hidden" name="inf" value="<?cs var:the_msg.info_fname ?>" />
    <input type="hidden" name="loc" value="<?cs var:the_msg.offset ?>" />
    <input type="hidden" name="grp" value="9" />
    <input type="hidden" name="read" value="1" />
    <input type="hidden" name="from" value=<?cs if:is_inbox ?>"post_inbox_gather"<?cs else ?>"post_outbox_gather"<?cs /if ?> />
    <?cs if:is_inbox ?><input type="hidden" name="inbox" value="yes" /><?cs /if ?>
    <input type="submit" value="<?cs var:lang.view_website_button ?>" title="<?cs var:lang.view_website_button_title ?>" />
    </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:file_attachments(the_msg) ?>
<div style="margin-top:1em">
<table border="0">
<tr>
<td valign="top"><b><?cs var:lang.attachments_label ?></b></td>
<td><?cs if:the_msg.attachments ?><?cs loop:i=#0, the_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:the_msg.file[i].url ?>" ><?cs /if ?><?cs var:the_msg.file[i].orig_fname ?><?cs if:!printer_friendly ?></a><?cs /if ?><?cs if:!printer_friendly && the_msg.file[i].wimpy_button_url ?><?cs call:wimpy_button(i,the_msg.file[i].wimpy_button_url) ?><?cs /if ?><?cs /loop ?><?cs /if ?></td>
</tr>
</table>
</div>
<?cs /def ?>


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


<?cs def:print_one_message(one_msg) ?> 
<?cs with:lang=lang.post_read ?>
<div>
<a name="<?cs var:one_msg.offset ?>"></a>
<fieldset>
<?cs if:!printer_friendly ?>
<legend>
<?cs if:is_inbox ?> 
<?cs if:can_write && new_memo_url ?>
 <a href="<?cs var:new_memo_url?>`<?cs var:one_msg.offset ?>&amp;loc=<?cs var:one_msg.offset ?>&amp;grp=0" title="<?cs var:lang.reply_title ?>"><img src="<?cs var:image_path ?>reply_sm.gif" alt="<?cs var:lang.reply_title ?>" /></a> 
<?cs else ?>
 <img src="<?cs var:image_path ?>reply_sm.gif" alt="<?cs var:lang.command_disabled ?>" title="<?cs var:lang.command_disabled ?>" /></a> 
 <?cs /if ?>

<?cs if:can_write && new_memo_url && one_msg.has_multiple_recipients ?>
    <a href="<?cs var:new_memo_url?>`<?cs var:one_msg.offset ?>&amp;loc=<?cs var:one_msg.offset ?>&amp;grp=1" title="<?cs var:lang.group_reply_title ?>"><img src="<?cs var:image_path ?>group_reply_sm.gif" alt="<?cs var:lang.group_reply_title ?>" /></a> 
 <?cs else ?>
    <img src="<?cs var:image_path ?>gr_group_reply_sm.gif" alt=" " /> 
 <?cs /if ?>

<?cs /if ?>

<?cs if:can_write && forward_partial_url ?>
   <a href="<?cs var:forward_partial_url ?>`<?cs var:one_msg.offset ?>&amp;loc=<?cs var:one_msg.offset ?>" title="<?cs var:lang.forward_title ?>"><img src="<?cs var:image_path ?>forward_sm.gif" alt="<?cs var:lang.forward_title ?>" /></a>
<?cs else ?>
    <img src="<?cs var:image_path ?>forward_sm.gif" alt="<?cs var:lang.command_disabled ?>" title="<?cs var:lang.command_disabled ?>" />
<?cs /if ?>
 
<?cs if:info_partial_url ?> 
<a href="<?cs var:info_partial_url ?>`<?cs var:one_msg.offset ?>&amp;loc=<?cs var:one_msg.offset ?>" title=<?cs if:is_inbox ?>"<?cs var:lang.inbox_info_title ?>"<?cs else ?>"<?cs var:lang.outbox_info_title ?>"<?cs /if ?>><img src="<?cs var:image_path ?>info_sm.gif" alt=<?cs if:is_inbox ?>"<?cs var:lang.inbox_info_title ?>"<?cs else ?>"<?cs var:lang.outbox_info_title ?>" <?cs /if ?> /></a>
<?cs /if ?>

<a href="<?cs if:is_inbox ?>post_read_inbox<?cs else ?>post_read_outbox<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:one_msg.offset ?>&amp;print=1&amp;fixed=<?cs var:fixed_font ?>" title="<?cs var:lang.news_read.print_title ?>" onclick="newwin=window.open('<?cs if:is_inbox ?>post_read_inbox<?cs else ?>post_read_outbox<?cs /if ?>?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:one_msg.offset ?>&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 ?>

<b><?cs var:lang.posted_by_label ?></b> <?cs var:one_msg.sender_realname ?><br />
<b><?cs var:lang.posted_date_label ?></b> <?cs var:one_msg.time_sent ?><br />
<b><?cs var:lang.subject_label ?></b> <?cs var:one_msg.escaped_subject ?>
<table border="0" cellspacing="0">
<?cs call:print_recipients(lang.to_label, one_msg.to_count, one_msg.to) ?>
<?cs if:one_msg.cc_count ?><?cs call:print_recipients(lang.cc_label, one_msg.cc_count, one_msg.cc) ?><?cs /if ?>
</table>


<?cs if:one_msg.website_attached ?>
    <?cs call:attached_website(one_msg) ?>
<?cs elif:one_msg.attachments ?>
     <?cs call:file_attachments(one_msg) ?>
<?cs /if ?>

<br />

<?cs call:print_message_body(one_msg) ?>
<br />
<br />
</fieldset>
</div>
<p />
<?cs /with ?>
<?cs /def ?>


<?cs def:print_messages() ?>
<?cs each:item = msg ?>
   <?cs call:print_one_message(item) ?> 
<?cs /each ?>

<?cs /def ?>




<?cs call:html_heading() ?>
<head>
      <title><?cs var:course_no ?> <?cs if:is_inbox ?><?cs var:lang.post_read.inbox_title ?><?cs else ?><?cs var:lang.post_read.outbox_title ?><?cs /if ?></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 call:print_messages() ?>
</body>
</html>
<?cs call:runtime() ?> 
