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

<?cs def:attached_website(button, url, is_survey) ?>
<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:msg.sender ?>" />
    <input type="hidden" name="inf" value="<?cs var:msg.info_fname ?>" />
    <input type="hidden" name="loc" value="<?cs var:msg.offset ?>" />
    <?cs if:is_unanswered_required_survey ?> 
    <input type="hidden" name="main" value="main_menu" />
    <?cs /if ?>

    <?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_read" />
    <?cs /if ?>
    <input type="submit" name="submit" value="<?cs var:button ?>" title="<?cs var:button ?>" />
    </div>
    </form>
 <?cs /if ?>
</div>
<?cs /def ?>


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



<?cs def:insert_kill_form() ?>
<form  method="post" action="news_kill" onsubmit="return verify('<?cs if:is_topic_with_replies ?><?cs var:lang.news_read.delete_topic_confirm ?><?cs else ?><?cs var:lang.news_read.delete_msg_confirm ?><?cs /if ?>')" >
<div>
<input type="hidden" name="crs" value="<?cs var:crs ?>" />
<input type="hidden" name="id" value="<?cs var:key ?>" />
<input type="hidden" name="info" value="<?cs var:msg.info_fname ?>" />
<input type="hidden" name="sender" value="<?cs var:msg.sender ?>" />
<input type="hidden" name="grp" value="<?cs var:grp ?>" />
<input type="hidden" name="loc" value="<?cs var:msg.offset ?>" />
<?cs if:is_fac_teamteach ?>
  <input type="hidden" name="team" value="<?cs var:team ?>" />
<?cs /if ?>
  
<input type="submit" value="<?cs if:msg.is_topic ?><?cs var:lang.news_read.delete_topic_button ?><?cs else ?><?cs var:lang.news_read.delete_msg_button ?><?cs /if ?>"/>
<input type="checkbox" name="validate" id="validate" /><span class="small"><?cs var:lang.news_read.i_am_sure ?></span>
</div>
</form>
<?cs /def ?>



<?cs def:insert_clipboard_copy_form() ?>
<form action="">
  <div>
  <input name="newwin" type="button" value="<?cs var:lang.news_read.clipboard_copy_button ?>"
   title="<?cs var:lang.news_read.clipboard_copy_button_title ?>"
   onclick="window.open('clipboard_copy?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?>','newwin','resizable=yes,width=350,height=275,top=50,left=50')" />
  </div>
</form>
<?cs /def ?>


<?cs def:insert_zip_website_form() ?>
 <?cs if:capture_mode ?>
  <a href="<?cs var:website_zip_download_url ?>"><?cs var:lang.news_read.download_website_button ?></a>
 <?cs else ?>
   <form method="post" action="web_page.zip">
   <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="dir" value="<?cs var:website_dirname ?>" />
   <input type="hidden" name="grp" value="<?cs var:grp ?>" />
   <input type="submit" value="<?cs var:lang.news_read.download_website_button ?>" title="<?cs var:lang.news_read.download_website_button_title ?>" />
   </div>
   </form>
 <?cs /if ?>
<?cs /def ?>



<?cs def:insert_unlock_attachments_form() ?>
  <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:website_attached ?>
       <p><?cs var:lang.news_read.website_attached ?></p>
  <?cs else ?>
     <p>
     <?cs each:attachment=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 ?>" title="<?cs var:lang.news_read.unlock_attachments_button_help ?>" 
   <?cs if:!printer_friendly ?>onClick="window.location='<?cs var: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() ?>
<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:msg.time_read ?>
<td></tr>
</table>
</div>
<?cs /def ?>




<?cs def:report_unlock_problem () ?>
<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:msg.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() ?><img src="<?cs var:image_path ?><?cs if: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() ?><a href="<?cs var:flag_url ?>" title="<?cs var:lang.news_read.flag_link_title ?>" ><?cs call:flag_image() ?></a><?cs /def ?>


<?cs ###
     ### HTML STARTS HERE
## ?>

<?cs call:html_heading() ?>
<head>
<title><?cs var:course_title ?> <?cs var:lang.news_read.module[grp] ?></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"  />


<?cs ## If this is a teacher, add a javascript
     ## that gets called when the msg is deleted
## ?>

<?cs if:is_faculty ?>
<script type="text/javascript" >
 function verify(mystring)
  {
    if(document.getElementById('validate').checked)
      {
        if(window.confirm(mystring))
           return true;
        else 
           return false;
      }
   else
     {
       window.alert("<?cs var:lang.news_read.i_am_sure_not_checked ?>");
       return false;
     }
  }
</script>
<?cs /if ?>
</head>
<?cs call:define_body() ?> 
<?cs ### 
     ### If we're doing a printer friendly version, 
     ###   print links to toggle between proportional and fixed fonts
     ### else
     ##    print rows of command buttons along the top
## ?>

<?cs if:!printer_friendly ?>
<table width="100%">
<tr><td align="center">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td rowspan="2" align="center"> <a href="<?cs var:back_button_url ?>" title="<?cs var:lang.news_read.back_button_title ?>"><img src="<?cs var:image_path ?>back_arrow.gif" width="50" height="34" alt="<?cs var:lang.news_read.back_button_title ?>" /></a></td>
<td><a href="<?cs var:main_menu_url ?>" title="<?cs var:lang.news_read.main_menu_title ?>"><img src="<?cs var:image_path ?>main_menu_sm.gif" alt="<?cs var:lang.news_read.main_menu_title ?>" width="135" height="17" /></a></td>
<td><?cs if:prev_msg_url ?><a href="<?cs var:prev_msg_url ?>" title="<?cs var:lang.news_read.prev_msg_title ?>"><img src="<?cs var:image_path ?>previous_sm.gif" width="135" height="17" alt="<?cs var:lang.news_read.prev_msg_title ?>"/></a><?cs else ?><img src="<?cs var:image_path ?>gr_previous_sm.gif" width="135" height="17" alt="" /><?cs /if ?></td>
<td><?cs if:can_write && new_msg_url ?><a href="<?cs var:new_msg_url ?>" title="<?cs if:grp == 6 ?><?cs var:lang.news_read.assign_new_msg_title ?><?cs else ?><?cs var:lang.news_read.new_msg_title ?><?cs /if ?>"><img src="<?cs var:image_path ?>new_msg_sm.gif"  alt="<?cs if:grp == 6 ?><?cs var:lang.news_read.assign_new_msg_title ?><?cs else ?><?cs var:lang.news_read.new_msg_title ?><?cs /if ?>" width="135" height="17" /></a><?cs else ?><img src="<?cs var:image_path ?>gr_new_msg_sm.gif"  alt="" width="135" height="17" /><?cs /if ?></td>
<td><?cs if:prev_topic_url ?><a href="<?cs var:prev_topic_url ?>" title="<?cs if:grp == 6 ?><?cs var:lang.news_read.assign_prev_topic_title ?><?cs else ?><?cs var:lang.news_read.prev_topic_title ?><?cs /if ?>"><img src="<?cs var:image_path ?><?cs if:grp == 6 ?>prev_assign_sm.gif<?cs else ?>prev_topic_sm.gif<?cs /if ?>" width="135" height="17" alt="<?cs if:grp == 6 ?><?cs var:lang.news_read.assign_prev_topic_title ?><?cs else ?><?cs var:lang.news_read.prev_topic_title ?><?cs /if ?>" /></a><?cs else ?><img src="<?cs var:image_path ?><?cs if:grp == 6 ?>gr_prev_assign_sm.gif<?cs else ?>gr_prev_topic_sm.gif<?cs /if ?>" width="135" height="17" alt="" /><?cs /if ?></td>
<td><a href="news_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?>&amp;fixed=<?cs var:fixed_font ?>&amp;print=1<?cs if:grp==7 ?>&amp;team=<?cs var: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:msg.offset ?>&amp;grp=<?cs var:grp ?>&amp;fixed=<?cs var:fixed_font ?>&amp;print=1<?cs if:grp==7 ?>&amp;team=<?cs var: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></td>
</tr>
<tr>
<td><a href="<?cs var: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></td>
<td><?cs if:next_msg_url ?><a href="<?cs var:next_msg_url ?>" title="<?cs var:lang.news_read.next_msg_title ?>"><img src="<?cs var:image_path ?>next_sm.gif" width="135" height="17" alt="<?cs var:lang.news_read.next_msg_title ?>" /></a><?cs else ?><img src="<?cs var:image_path ?>gr_next_sm.gif" width="135" height="17" alt="" /><?cs /if ?></td>
<td><?cs if:can_write && reply_url ?><a href="<?cs var: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 ?></td>
<td><?cs if:next_topic_url ?><a href="<?cs var:next_topic_url ?>" title="<?cs if:grp == 6 ?><?cs var:lang.news_read.assign_next_topic_title ?><?cs else ?><?cs var:lang.news_read.next_topic_title ?><?cs /if ?>"><img src="<?cs var:image_path ?><?cs if:grp == 6 ?>next_assign_sm.gif<?cs else ?>next_topic_sm.gif<?cs /if ?>" width="135" height="17" alt="<?cs if:grp == 6?><?cs var:lang.news_read.assign_next_topic_title ?><?cs else ?><?cs var:lang.assign_news_read.next_topic_title ?><?cs /if ?>" /></a><?cs else ?><img src="<?cs var:image_path ?><?cs if:grp == 6 ?>gr_next_assign_sm.gif<?cs else ?>gr_next_topic_sm.gif<?cs /if ?>" width="135" height="17" alt="" /><?cs /if ?></td>
<td><img src="<?cs var:image_path ?>blank_sm.gif" width="135" height="17" alt="" /></td>
</tr>
</table>
</td></tr>
</table>
<?cs /if ?>

<?cs #### print a box containing info about the msg,
     #### Posted by:, Date: , etc.
## ?>
<fieldset style="width:70%" >
<legend class="fieldset_legend">
 <?cs var:course_no ?> <?cs var:lang.news_read.module[grp] ?>
</legend>
<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 && !printer_friendly?></a><?cs /if ?><br />
<b><?cs var:lang.news_read.posted_date_label ?></b> <?cs var:msg.time_sent ?>  

<?cs if:msg.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:msg.escaped_subject ?> <?cs if:!printer_friendly ?><?cs call:print_flag() ?><?cs /if ?>
  </p>
<?cs else ?>
   <p><b><?cs var:lang.news_read.topic_label ?></b> <?cs var:msg.escaped_topic_subject ?><br />
      <b><?cs var:lang.news_read.subject_label ?></b> <?cs var:msg.escaped_subject ?> <?cs if:!printer_friendly ?><?cs call:print_flag() ?><?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: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 && is_faculty ?>
      <?cs call:print_msg_warning(lang.news_read.attachments_locked) ?>
<?cs /if ?>
</tr>
</table>
</fieldset>

<?cs if:!printer_friendly ?>
 <div class="font_selector" >
  <?cs if:fixed_font ?>
     <a href="news_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?><?cs if:grp==7 ?>&amp;team=<?cs var: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_read?crs=<?cs var:crs ?>&amp;id=<?cs var:key ?>&amp;loc=<?cs var:msg.offset ?>&amp;grp=<?cs var:grp ?>&amp;fixed=1<?cs if:grp==7 ?>&amp;team=<?cs var: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 ?>

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


<?cs if:attachments_locked ?>
  <?cs call:insert_unlock_attachments_form() ?>
<?cs else ?>
 <?cs if:msg.user_unlocked ?>
    <?cs call:user_unlocked_info() ?>
 <?cs elif:msg.protected && !is_faculty && msg.time_read ?>
     <?cs call:report_unlock_problem() ?>
 <?cs /if ?>
<?cs /if ?>

<?cs if:!attachments_locked ?>
 <?cs if:hotpot_exam ?>
   <?cs call:hotpot_exam() ?>
 <?cs elif:website_attached ?>
   <?cs if:survey_url ?>
     <?cs call:attached_website(lang.news_read.take_survey_button, survey_url, #1) ?>
        <?cs if:is_unanswered_required_survey ?>
	  <p><img src="<?cs var:image_path ?>warn.gif" alt=" " /> <span style="color:#f00; font-weight: bold"><?cs var:lang.news_read.course_evaluation ?></span></p>
        <?cs /if ?>	
     <?cs else ?>
     <?cs call:attached_website(lang.news_read.view_website_button, normal_website_url, #0) ?>
   <?cs /if ?>
 <?cs elif:msg.attachments ?>
     <?cs call:file_attachments() ?>
 <?cs /if ?>
<?cs /if ?>

<?cs if:fixed_font ?>
<div>
<pre>
<?cs each:row=line ?><?cs var:row.content ?>
<?cs /each ?>
</pre>
</div>
<?cs else ?>
<div style="text-indent:4em; margin-top:2em">
<?cs each:row=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 if:!printer_friendly ?>
<?cs if:is_faculty  && (!capture_mode || website_attached)?>
<div style="margin-top:3em">
<hr style="width:300px" />
<table width="100%" border="0">
<tr><td align="center">
<table  border="0" cellpadding="20">
<tr>
 <?cs if:insert_kill_form && !capture_mode?>
   <td align="center">
   <?cs call:insert_kill_form() ?>
   </td>
 <?cs /if ?>

 <?cs if:!capture_mode ?>
  <td align="center">
   <?cs call:insert_clipboard_copy_form() ?>
  </td>
 <?cs /if ?>

 <?cs if:website_attached ?>
   <td align="center">
   <?cs call:insert_zip_website_form() ?>
   </td>
 <?cs /if ?>
</tr>
</table>
</td></tr></table>
</div>
<?cs /if ?>
<?cs /if ?>

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