# Non served comment ~msg.js
\
||ifequal||sid||0||\
	||ifndef||multiple_messages||\
		auth_error('||auth_fail_reason||');\
	||endif||\
||else||\
\
# Lets do the display of message info from index and processing of mesage for display
#  upfront so we have everything we want to display available throughout the page
||tcmd_load_msg_info||\
||iftrue(tcmd_error)||\
	dbg('doing nothing, folder not loaded');\
||else||\
\
||tcmd_process_message||\
\
||define||tparam_msg_show_jsencode||true||\
\
||ifndef||multiple_messages||amsg=||endif||\
{\
	fid:'||json_validate_int(fid)||', mid:'||json_validate_int(msg_id)||', ident:'||json_validate_int(ident)||', \
\
  	data:{\
  		from:||show_rcpts_json(h_from)||, to:||show_rcpts_json(h_to)||, cc:||show_rcpts_json(h_cc)||, bcc:||show_rcpts_json(h_bcc)||, \
		reply_to:||show_rcpts_json(h_reply_to)||, replyall:||show_rcpts_json(reply_all)||, \
	  	nrcpts_to:||json_validate_int(rcpt_total)||, attachments:||json_validate_int(attachments)||, mid:'||json_validate_int(msg_id)||', \
	  	related: '||related_content||', send_mode: '||send_mode||', mpr_as:'||mpr_as||', \
	  	date:'||msg_date|| ||msg_time||', subject:'||web_encode_js(h_subject)||', rrcpt:'||h_rrcpt||', encryption:'||msg_encryption||', \
	  	draft:||json_validate_bool(h_draft)||, sender_unknown:||json_validate_bool(sender_unknown)||,\
	  	ref_messageid:||json_validate(h_messageid)|| \
||ifdef||_note_not_yet_||\
	  	, note:||json_validate_bool(h_note)||, thread_id:'' \
||endif||\
	  	},\
\
	html:'\
# Output our formatting
||if(and(istrue(allow_spam),istrue(maybe_spam)))||\
<div class="spam_info">$$st_msg_spam$$ &nbsp;\
				<input type=button class="mnu" onclick="spam_info(\'spam\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_spam_tt$$" value="$$st_msg_spam$$"> \
				<input type=button class="mnu" onclick="spam_info(\'notspam\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_notspam_tt$$" value="$$st_msg_notspam$$"> \
				&nbsp;&nbsp;&nbsp; \
				<input type=button class="mnu" onclick="spam_info(\'once\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_once_tt$$" value="$$st_msg_once$$"> \
  ||iftrue(allow_friends)||\
  				<input type=button class="mnu" onclick="spam_info(\'block\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_block_tt$$" value="$$st_msg_block$$"> \
  ||endif||\
				<a class="spam_help_link" href="||help_url||||iftrue(help_context)||/user.htm||help_extra||#spam_reporting||endif||" target="_help" >$$st_msg_spam_help$$</a></div>\
||endif||\
\
# New calendar section begin
||if(cal_reply)||\
<div class="invite_info">$$st_msg_cal_invite$$ &nbsp;\
				<input type=button class="mnu" onclick="cal_prcc(\'accept\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_accept_tt$$" value="$$st_msg_cal_accept$$"> &nbsp; \
				<input type=button class="mnu" onclick="cal_prcc(\'tentative\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_tentative_tt$$" value="$$st_msg_cal_tentative$$"> &nbsp; \
				<input type=button class="mnu" onclick="cal_prcc(\'decline\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_decline_tt$$" value="$$st_msg_cal_decline$$"> \
||if(cal_add)||\
				&nbsp; $$st_msg_cal_and$$ &nbsp; \
				<input type=button class="mnu" onclick="cal_prcc(\'caladd\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_add_tt$$" value="$$st_msg_cal_add$$"> \
||endif||\
</div>\
||else||\
||if(cal_add)||\
<div class="invite_info">$$st_msg_cal_just_add$$ &nbsp;\
				<input type=button class="mnu" onclick="cal_prcc(\'caladd\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_just_add_tt$$" value="$$st_msg_cal_add$$"> \
</div>\
||endif||\
||endif||\
||if(cal_update)||\
<div class="invite_info">$$st_msg_cal_reply$$ &nbsp;\
				<input type=button class="mnu" onclick="cal_prcc(\'calupdate\',\'||web_encode_js(web_encode_js(fld_id))||\',\'||msg_id||\')" title="$$st_msg_cal_update_tt$$" value="$$st_msg_cal_update$$"> \
</div>\
||endif||\
# New calendar section end
\
||if(istrue(h_deferred))||\
 ||if(istrue(h_returned))||\
<div class="deferred_message">$$st_deferred_return$$</div>\
 ||else||\
<div class="deferred_message">$$st_deferred_until$$ ||date_basic2(msg_xdefer)|| </div>\
 ||endif||\
||endif||\
<div id="msg_headers" class="msg_headers ||if_set(msghdr_nocolor)||msg_headers_nocolor||endif||">\
 <div id="msg_options" style="float:right">\
||iftrue(htags_enable)|| \
#	<div class="htags_outer" onkeydown="stopBubble(event)" onkeyup="stopBubble(event)">\
#		<textarea class="htags_input"> as textarea</textarea>\
#		<div class="htags_plain"> as plain text</div>\
#	</div>\
||endif||\
# _scroll_not_yet_
#    <img src="||www_base||shared/img/1pixel.gif" class="btn_preview" onclick="expand_preview(\'||fid||_||msg_id||\')" title="$$st_cmd_preview_tt$$"> \
    <img src="||www_base||shared/img/1pixel.gif" class="btn_prev" onclick="show_prev(\'||fid||_||msg_id||\')" title="$$st_cmd_prevmsg_tt$$">\
	<img src="||www_base||shared/img/1pixel.gif" class="btn_next" onclick="show_next(\'||fid||_||msg_id||\')" title="$$st_cmd_nextmsg_tt$$"> \
    <img src="||www_base||shared/img/1pixel.gif" class="btn_thread" onclick="show_thread(\'||fid||_||msg_id||\')" title="$$st_cmd_thread_tt$$">\
	<img src="||www_base||shared/img/1pixel.gif" class="btn_history" onclick="show_history(\'||if(or(equal(fld_type,2),equal(fld_type,3)))||||web_encode_js(web_encode_js(h_to_address))||||else||||web_encode_js(web_encode_js(h_from_address))||||endif||\')" title="$$st_cmd_history_tt$$"> \
    <img src="||www_base||shared/img/1pixel.gif" class="popout" onclick="popout_msg(\'||fid||_||msg_id||\')" title="$$st_cmd_popout_tt$$">\
    <img src="||www_base||shared/img/1pixel.gif" class="popin" onclick="popin_msg(\'||fid||_||msg_id||\')" title="$$st_cmd_popin_tt$$">\
 </div>\
 <div id="message_labels" class="labels" style="float:right;" oncontextmenu="labels_cx(event)">%%the_labels%%</div>\
\
||if_set(msghdr_format2)||\
 <div class="msg_subject msg_subject_format2"><span id="msg_subject">||web_encode_js(web_encode(h_subject))||</span></div>\
 <div class="msg_date msg_date_format2"><span id="msg_date">||msg_date|| ||msg_time||</span></div>\
||endif||\
 <div class="msg_from"><b>$$st_hdr_from$$</b> <span id="msg_from" ||iftrue(sender_unknown)||class="sender_unknown_address"||endif||>||show_rcpts_3(h_from)|| ||iftrue(sender_unknown)||<a href="#" onclick="unknown_alert(\'||web_encode_js(web_encode_js(web_encode(h_from)))||\')" class="sender_unknown_warning">Sender Unknown</a>||endif||</span>\
||iftrue(h_reply_to_unsafe)||\
 &nbsp;&nbsp;&nbsp;($$st_hdr_reply_to$$ <span id="msg_reply_to">||show_rcpts_3(h_reply_to_address)||)</span>\
||endif||\
 </div>\
||iftrue(h_return_path_unsafe)||\
 <div class="msg_rpath"><b>$$st_hdr_rpath$$</b> <span id="msg_rpath">||show_rcpts_3(h_return_path)||</span>\
 ||if(and(istrue(allow_spam),istrue(show_reverse)))||\
  ||if(istrue(h_lookup_both))||\
 &nbsp;&nbsp;&nbsp;($$st_hdr_reverse$$ <span id="msg_reverse">||web_encode_js(h_lookup_both)||)</span>\
  ||endif||\
 ||endif|| &nbsp;&nbsp; <span class="allow_rpath"><a href="#" onclick="allow_rpath()">$$st_hdr_rpath_allow$$</a></span>\
 </div>\
||else||\
 ||if(and(istrue(allow_spam),istrue(show_reverse)))||\
  ||if(and(istrue(h_lookup_both),istrue(maybe_spam)))||\
 <div class="msg_reverse"><b>$$st_hdr_reverse2$$</b> <span id="msg_reverse">||web_encode_js(h_lookup_both)||</span></div>\
  ||endif||\
 ||endif||\
||endif||\
||if_not(msghdr_format2)||\
 <div class="msg_subject">$$st_hdr_subject$$ <span id="msg_subject">||web_encode_js(web_encode(h_subject))||</span></div>\
||endif||\
 <div class="msg_to ||iftrue(h_to_justme)||hidden_in_preview||endif||"><b>$$st_hdr_to$$</b> <span id="msg_to">||macro((addr1),h_to)||</span></div>\
 <div class="msg_cc ||ifndef||h_cc||hidden||endif||" ><b>$$st_hdr_cc$$</b> <span id="msg_cc" >||macro((addr1),h_cc)||</span></div>\
 ||ifdef||h_bcc||<div class="msg_bcc" ><b>$$st_hdr_bcc$$</b> <span id="msg_bcc" >||macro((addr1),h_bcc)||</span></div>||endif||\
\
||if_not(msghdr_format2)||\
  <span class="msg_date"><b>$$st_hdr_date$$</b> <span id="msg_date">||msg_date|| ||msg_time||</span></span><br>\
||endif||\
||ifdef||extra_headers||\
   ||define||foreach||extra_headers||\
   ||begin_list_foreach||\
	||define((name),lookup(concat((extra_header_name_),item)))||\
	||define((value),lookup(concat((extra_header_value_),item)))||\
	||if(equal(name,(Resent-From)))||\
 	 <div><b>||name||:</b> ||macro((addr1),value))||</div>\
 	||else||\
 	 <div><b>||name||:</b> ||web_encode(value))||</div>\
 	||endif||\
   ||end_list_foreach||\
||endif||\
\
||ifdef||attachments||\
 	<div class="msg_attachments">\
	||if(equal(attachments,1))||\
 	<span class="msg_attach"> $$st_msg_attachments_1$$\
 		||begin_list_attachments||\
 			<a href="||web_encode_js(link)||">||web_encode_js(web_encode(part_name))||</a> <span class="attach_sizing">||bytes_basic(part_size)||</span>\
 		||end_list_attachments||\
 	</span>\
 	||else||\
 	<span class="msg_attach"> ||$((st_msg_attachments_n),attachments)|| \
 			<a href="||web_encode_js(link_all)||">$$st_msg_attachments_dl$$</a> | \
		||if(not(istrue(all_attach)))|| ||define||list_max||4|| ||endif||\
 		||begin_list_attachments||\
 			<a href="||web_encode_js(link)||">||web_encode_js(web_encode(part_name))||</a> <span class="attach_sizing">||bytes_basic(part_size)||</span>||ifdef||more||,||endif|| ||ifdef||max_hit||... <a href="#" onclick="show_all(\'attach\')"><i>show all</i></a>||endif||\
 		||end_list_attachments||\
 	</span>\
 	||endif||\
 	</div>\
||endif||\
\
 <div class="raw_links" ><b>$$st_txt_parts_show$$</b> \
 		<a href="#" onclick="show_raw(||json_validate_int(ident)||,\'||fid||_||msg_id||\')">$$st_cmd_parts_raw$$</a> \
||ifdef||text_part||\
		<a href="#" onclick="show_text(||json_validate_int(ident)||,\'||fid||_||msg_id||\',\'||text_part||\')" >$$st_cmd_parts_text$$</a> \
||endif||\
||ifdef||html_part||\
 		<a href="#" onclick="show_html(||json_validate_int(ident)||,\'||fid||_||msg_id||\',\'||html_part||\',\'||allow_images||\')" >$$st_cmd_parts_html$$</a> \
||endif||\
 	</div>\
\
</div>\
\
||define||need_line||true||\
||if(greater_than(attachments_email,(0)))||\
    <div class="attach_info" >\
      ||if(equal(attachments_email,(1)))||\
    	$$st_msg_email_att1$$ \
      ||else||\
    	||$((st_msg_email_att2),attachments_email)|| \
      ||endif||\
 	  ||if(not(istrue(show_attach_inline)))||<a href="#" onclick="attached_messages(\'inline\',[\'||show_attach_inline||\',\'||saved_attach_folder||\'])">$$st_msg_email_att_show$$</a>||elseif||\
 	  ||else||<a href="#" onclick="attached_messages(\'no_inline\',[\'||show_attach_inline||\',\'||saved_attach_folder||\'])">$$st_msg_email_att_hide$$</a>||endif||\
 	  ||if(not(istrue(saved_attach_folder)))||, <a href="#" onclick="attached_messages(\'save\',[\'||show_attach_inline||\',\'||saved_attach_folder||\'])">$$st_msg_email_att_store$$</a>||endif||</div>\
	||define||need_line||false||\
||endif||\
||ifdef||images_disabled||\
 <div id="images_disabled" >$$st_msg_img_disable1$$ <a href="#" onclick="allow_images(\'once\')">$$st_msg_img_disable2$$</a>, <a href="#" onclick="allow_images(\'always\')">$$st_msg_img_disable3$$</a></div>\
	||define||need_line||false||\
||endif||\
||if_set(msghdr_nocolor)||\
 ||iftrue(need_line)||\
<div class="msg_line"><div></div></div>\
 ||endif||\
||endif||\
<div class="msg_body">\
# QQQ: attempt at different scrolling 
# <div id="msg_foobar" class="sw_message ||if(not(istrue(pref_no_replycolor)))||reply_colors||endif||" style="overflow-x:auto;overflow-y:none;">\
 <div id="msg_foobar" class="sw_message ||if(not(istrue(pref_no_replycolor)))||reply_colors||endif||" >\
#  ||msg_show||\
	%%the_msg%%\
 </div>\
 ||undef||done_some||\
 ||begin_list_msg_extra||\
 ||ifndef||done_some||\
 <div class="spacer"></div>\
 <div class="message_attachments"> ||n_attached_images|| ||if(greater_than(n_attached_images,(1)))|| $$st_msg_img_attach_n$$ ||else|| $$st_msg_img_attach$$ ||endif|| : <span style="font-size:12px;"><a href="#" class="link_blue" onclick="slide_show(||json_validate_int(ident)||,\'||web_encode_js(web_encode_js(msg_fld))||\',\'||fid||_||msg_id||\'||if(equal(mpr_as,(attach)))||,true||endif||)">$$st_msg_img_slideshow$$</a></span></div>\
 ||endif||\
 ||define||done_some||true||\
 <div class="an_attachment"><table><tr><td><img src="||web_encode_js(src)||" onclick="show_img(||json_validate_int(ident)||,\'||fid||_||msg_id||\',\'||part_id||\')"></td><td valign="center"> <b>||web_encode_js(web_encode(part_name))||</b> ||if(istrue(pref_devt_mode))||<span class="dbginfo">[PART=||part_id||]</span>||endif||\
 	<br> ||bytes_basic(part_size)|| \
 		<a href="#" onclick="show_img(||json_validate_int(ident)||,\'||fid||_||msg_id||\',\'||part_id||\')">$$st_msg_img_attach_vw$$</a> \
 		<a href="||web_encode_js(link)||">$$st_msg_img_attach_dl$$</a></td></tr></table></div>\
 ||end_list_msg_extra||\
 ||iftrue(related_content)||\
   ||ifndef||done_some||\
   <div class="spacer"></div>\
   ||endif||\
   <div class="message_attachments"> ||n_related|| ||if(greater_than(n_related,(1)))|| $$st_msg_img_embedded_n$$ ||else|| $$st_msg_img_embedded$$ ||endif|| : \
   	 <span style="font-size:12px;"> \
#   	 Shown to fit window. \
   	 	<a href="#" class="link_blue" onclick="slide_show(||json_validate_int(ident)||,\'||web_encode_js(web_encode_js(fld_id))||\',\'||fid||_||msg_id||\',true)">$$st_msg_img_slideshow$$</a> | \
   	 	<a href="||web_encode_js(link_all)||&mpr_as=attach" class="link_blue" >$$st_msg_attachments_dl$$</a> | \
	  ||if(equal(mpr_as,(attach)))||\
   	 	<a href="#" class="link_blue" onclick="attached_messages()">$$st_msg_mpr_normal$$</a> \
   	  ||else|| \
   	 	<a href="#" class="link_blue" onclick="attached_messages(\'mpr_attach\')">$$st_msg_mpr_embed$$</a> \
   	  ||endif||\
   	 	</span></div>\
 ||endif||
# <span id="result" >\
# </span>\
</div>\
# Add some extra space after messages\
<br><br><br>\
#</td></tr></table>\
',\
\
# Now output the actual message display part and labels
	msg_html:'||msg_show||',\
||iftrue(with_plain)||\
	||define||tparam_show_as||replytext||\
	||iftrue(h_note)|| ||define||tparam_show_as||text|| ||endif||\
	msg_txt:'||msg_show||',\
	||undef||tparam_show_as||\
||endif||\
\
	labels_html:'\
		||begin_list_msg_labels||\
			<div class="aa ar as" label_id="||web_encode_js(label_name)||"><div class="at" style="background-color: ||label_bg||; border-color: ||label_bdr||;"><div class="au" style="border-color:||label_bdr||;"><div class="av" style="color: ||label_col||;">||web_encode_js(label_name)||</div></div></div></div>\
		||end_list_msg_labels||'\
\
}\
\
||endif|| ||endif||\