<? function pm_mainpage($inbox,$inboxnew,$outbox,$drafts,$archive) { ?>
<table class="innertable" width=100% cellspacing=1><tr>
<td class="tablehead" colspan=2><?=MSG_pm;?></td></tr>
<tr class="basictable"><td width=40%><a href="index.php?m=messages&a=viewbox&box=0"><?=MSG_pm_inbox;?></a>
</td><td> <?=format_word($inbox,MSG_p1,MSG_p2,MSG_p3);?>, 
<?=MSG_pm_ofthem;?> <?=format_word($inboxnew,MSG_pm1,MSG_pm2,MSG_pm3);?></td></tr>
<tr class="basictable"><td><a href="index.php?m=messages&a=viewbox&box=1"><?=MSG_pm_sent;?></a>
</td><td><?=format_word($outbox,MSG_p1,MSG_p2,MSG_p3);?></td></tr>
<tr class="basictable"><td><a href="index.php?m=messages&a=viewbox&box=2"><?=MSG_pm_drafts;?></a>
</td><td><?=format_word($drafts,MSG_p1,MSG_p2,MSG_p3);?></td></tr>
<tr class="basictable"><td><a href="index.php?m=messages&a=viewbox&box=3"><?=MSG_pm_archive;?></a>
</td><td><?=format_word($archive,MSG_p1,MSG_p2,MSG_p3);?></td></tr>
<tr class="basictable"><td colspan=2 align=center><a href="index.php?m=messages&a=newmsg"><?=MSG_pm_newmsg;?></a>
</td></tr></table>
<? } 

function pm_head() { ?>
<table class="innertable" width=100% cellspacing=1><tr>
<td class="tablehead"><?=MSG_pm_yours;?></td></tr>
<tr class="basictable"><td align=center>
<? if (getvar("box")!=0 || (!isset($_GET['box']) && !isset($_POST['box']))) { ?><a href="index.php?m=messages&a=viewbox&box=0"><?=MSG_pm_inbox;?></a> &nbsp; <? }
else { ?><?=MSG_pm_inbox;?> &nbsp; <? }
if (getvar("box")!=1) { ?><a href="index.php?m=messages&a=viewbox&box=1"><?=MSG_pm_sent;?></a> &nbsp; <? }
else { ?><?=MSG_pm_sent;?> &nbsp; <? } 
if (getvar("box")!=2) { ?><a href="index.php?m=messages&a=viewbox&box=2"><?=MSG_pm_drafts;?></a> &nbsp; <? }
else { ?><?=MSG_pm_drafts;?> &nbsp; <? }
if (getvar("box")!=3) { ?><a href="index.php?m=messages&a=viewbox&box=3"><?=MSG_pm_archive;?></a> &nbsp; <? }
else { ?><?=MSG_pm_archive;?> &nbsp;<? }
if ($GLOBALS['action']!="newmsg") { ?><a href="index.php?m=messages&a=newmsg"><?=MSG_pm_newmsg;?></a><? }
else { ?><?=MSG_pm_newmsg;?><? } ?>
</td></tr></table><br>
<? }

function pm_list_start() { ?>
<script><!--
function SetStatus(status) { 
	for (i=0; i<=document.msglist.elements.length; i++) 
  if (document.msglist.elements[i].name.indexOf("delete")>-1) { document.msglist.elements[i].checked=status; } 
}
--></script>
<form action="index.php" method=POST name="msglist">
<table class="innertable" width=100% cellspacing=1><tr>
<td class="tablehead" colspan=5><?=MSG_pm_list;?></td></tr>
<? }

function pm_list_entry($pmdata) { ?>
<tr class="basictable"><td width=15% align=center><?=user_out($pmdata['u__name'],$pmdata['u_id']);?>
<td width=12% align=center><?=short_date_out($pmdata['pm__senddate']);?></td>
<td width=12% align=center><? if ($pmdata['pm__readdate']) echo short_date_out($pmdata['pm__readdate']);
else echo MSG_pm_new; ?></td>
<td><a href="index.php?m=messages&a=viewmsg&msg=<?=$pmdata['pm_id'];?>"><?=$pmdata['pm_subj'];?></a></td>
<td width=5% align=center><input type=checkbox name="delete[<?=$pmdata['pm_id'];?>]" value=1></td></tr>
<? }

function pm_list_noentries() { ?>
<tr class="basictable"><td width=20% colspan=5 align=center><?=MSG_pm_nomsg;?></td></tr>
<? }

function pm_list_end() { ?>
<tr><td class="tablehead" colspan=5><input type=hidden name=m value=messages>
<input type=hidden name=a value=do_delall><input type=submit value="<?=MSG_pm_delete;?>"> &nbsp; 
<input type=button value="<?=MSG_select;?>" onClick="SetStatus(true)"> &nbsp; 
<input type=button value="<?=MSG_unselect;?>" onClick="SetStatus(false)">
</td></tr></table></form>
<? }

function pm_edit($pmdata) { ?>
<form action="index.php" method=POST>
<table class="innertable" width=100% cellspacing=1><tr>
<td class="tablehead" colspan=2><?=MSG_pm_send;?></td></tr>
<tr class="basictable"><td width=50%><?=MSG_pm_subj;?>:
</td><td>
<input type=text name=pm_subj size=30 maxlength=80 value="<?=$pmdata['pm_subj'];?>">
</td></tr><tr class="basictable"><td width=50%>
<?=MSG_pm_receiver;?>: 
</td><td>
<input type=text name=u__name value="<?=$pmdata['u__name'];?>">
</td></tr><tr class="basictable"><td>
<? if (getvar("reply")) { ?>
<?=MSG_pm_text;?>:</td><td>
<?=textout($pmdata['pm_text'],1,$pmdata['pm_bcode'],$pmdata['pm_smiles']);?></td></tr>
<tr class="basictable"><td><? } ?>
<?=MSG_pm_newmsg;?>:</td><td>
<textarea name=pm_text rows=8 cols=40><? if (getvar("msg")) echo $pmdata['pm_text'];?>
</textarea></td></tr>
<tr class="basictable"><td>
<?=MSG_pm_options;?>:
</td><td>
<input type=checkbox name=pm_bcode value=1 checked><?=MSG_bcode;?><br>
<input type=checkbox name=pm_smiles value=1 <? check($GLOBALS['inuser']['u_usesmiles']==1);?>><?=MSG_smiles;?><br>
<input type=checkbox name=pm_signature value=1 <? check($GLOBALS['inuser']['u_usesignature']==1);?>><?=MSG_attachsign;?><br></td></tr>
<tr><td class="tablehead" colspan=2><input type=hidden name=m value=messages><input type=hidden name=a value=do_send>
<input type=submit value="<?=MSG_send;?>"> &nbsp; <input type=submit name=drafts value="<?=MSG_pm_todrafts;?>">
</td></tr></table></form>
<? } 

function pm_message($pmdata) { ?>
<table class="innertable" width=100% cellspacing=1 cellpadding=2><tr>
<td class="tablehead"><?=MSG_pm_pm;?></td></tr>
<tr class="basictable"><td><?=MSG_pm_subj;?>: <?=$pmdata['pm_subj'];?><br>
<? if ($pmdata['pm__box']==0 || $pmdata['pm__box']==3) { ?><?=MSG_pm_sender;?>: <? }
else { ?><?=MSG_pm_receiver;?>: <? } ?>
<?=user_out($pmdata['u__name'],$pmdata['u_id']);?><br>
<? if ($pmdata['pm__box']!=2) { ?>
<?=MSG_pm_sendtime;?>: <?=long_date_out($pmdata['pm__senddate']);?><br>
<?=MSG_pm_recvtime;?>: 
<? if ($pmdata['pm__readdate']) { ?><?=long_date_out($pmdata['pm__readdate']);?><? } 
else { ?><?=MSG_none;?><? }
} ?><br><hr>
<? if ($pmdata['pm__box']==0 || $pmdata['pm__box']==3) { ?>
<a href="index.php?m=messages&a=reply&reply=<?=$pmdata['pm_id'];?>"><?=MSG_pm_answer;?></a> &nbsp; 
<? } ?>
<a href="index.php?m=messages&a=do_delete&msg=<?=$pmdata['pm_id'];?>"><?=MSG_delete;?></a> &nbsp; 
<? if ($pmdata['pm__box']==0) { ?>
<a href="index.php?m=messages&a=do_move&msg=<?=$pmdata['pm_id'];?>"><?=MSG_pm_toarchive;?></a> &nbsp; 
<? }
if ($pmdata['pm__box']==2) { ?>
<a href="index.php?m=messages&a=reply&msg=<?=$pmdata['pm_id'];?>"><?=MSG_pm_editsend;?></a> &nbsp; 
<? } ?>
<tr class="basictable"><td><br><?=textout($pmdata['pm_text'],1,$pmdata['pm_bcode'],$pmdata['pm_smiles']);?><br>
<? 
if ($pmdata['pm__box']==0 || $pmdata['pm__box']==3) {
if ($pmdata['pm_signature'] && $pmdata['u_signature']) { ?>---<br>
<?=textout($pmdata['u_signature'],0,1,1);?>
<? }
}
else {
if ($pmdata['pm_signature'] && $GLOBALS['inuser']['u_signature']) { ?>---<br>
<?=$GLOBALS['inuser']['u_signature'];?>
<? } 
}?>
</td></tr></table></form>
<? }
