<?php

// -----------------------------------------------------------------------
// This file is part of aroundme
// 
// Copyright (C) 2003, 2005 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------

?>


<form action="msg_compose.php" method="post">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="560" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_message'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<?php
			if (isset($display) && $display == "size_allocation_exceeded") {
			?>
			<table cellpadding="4" cellspacing="0" border="0" width="100%">
			    <tr>
					<td>
						<b><?php echo $lang['hdr_size_allocation_exceeded'];?></b><br />
						<?php echo $lang['txt_size_allocation_exceeded'];?></b><br />
					</td>
				</tr>
			</table>

			<?php
			}
			elseif (isset($display) && $display == "compose_allowed" && (!empty($users) || isset($message['message_id']))) {
			?>

			<table cellpadding="4" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<table>
							<tr>
								<td>
									<b><?php echo $lang['txt_to'];?></b>
								</td>
							</tr>
							<tr>
								<td>
								<?php
								if(!isset($to_user_id))
								{
								?>
								<select name="data[to_user_id]" class="formInput" />
								<?php
									foreach ($users as $key => $i) :
								?>
										<option value=<?php echo $i['user_id']?>><?php echo dots(50, $i['profile_nic']);?></option>
								<?
									endforeach;
								?>
								</select>
								<?php
								}
								else {
								?>
									<input type="hidden" name="data[to_user_id]" value="<?php echo $to_user_id?>" />
									<?php echo $to_user['profile_nic']?><br />
								<?
								}
								?>
								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $lang['txt_subject'];?></b><br />
								</td>
							</tr>
							<tr>
								<td>
									<input name="data[message_subject]" type="text" size=50" value="<?php echo $message['message_subject'];?>" class="formInput" /><br />
								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $lang['txt_body'];?></b><br />
								</td>
							</tr>
							<tr>
								<td>
									<textarea name="data[message_body]" cols="80" rows="10" class="formInput" /><?php echo $message['message_body'];?></textarea><br />
								</td>
							</tr>
							<tr>
								<td align="right">
									<input name="preview_message" type="submit" value="<?php echo $lang['sub_preview'];?>" class="button_urgent" />&nbsp;&nbsp;
								<input name="send_message" type="submit" value="<?php echo $lang['sub_send'];?>" class="button_urgent" /><br />
								</td>
							</tr>
						</table>

					</td>
				</tr>
			</table>

			<?php
			}
			elseif (isset($display) && $display == "preview_msg") {
			?>
			<input type="hidden" name="data[to_user_id]" value="<?php echo $to_user_id?>" />
			<input type="hidden" name="data[to_user]" value="<?php echo $to_user?>" />
			<input type="hidden" name="data[message_body]" value="<?php echo $message['message_body'];?>" />
			<input type="hidden" name="data[message_subject]" value="<?php echo $message['message_subject'];?>" />

			<table cellpadding="4" cellspacing="0" border="0" width="100%">
				<tr>
					<td>
						<table>
							<tr>
								<td>
									<b><?php echo $lang['txt_to'];?></b>
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $to_user['profile_nic']?><br />

								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $lang['txt_subject'];?></b><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $message['message_subject'];?><br />
								</td>
							</tr>
							<tr>
								<td>
									<b><?php echo $lang['txt_body'];?></b><br />
								</td>
							</tr>
							<tr>
								<td>
									<?php echo $message['message_body_display'];?>
								</td>
							</tr>
							<tr>
								<td align="right">
									<input name="edit_message_again" type="submit" value="<?php echo $lang['sub_edit'];?>" class="button_urgent" />&nbsp;&nbsp;
									<input name="send_message" type="submit" value="<?php echo $lang['sub_send'];?>" class="button_urgent" /><br />
								</td>
							</tr>
						</table>

					</td>
				</tr>
			</table>
			<?php
			}
			elseif (empty($users))  {
			?>
			<table cellpadding="4" cellspacing="0" border="0" width="100%">
			    <tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_message'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<?php echo $lang['err_no_friends'];?><br />
					</td>
				</tr>
			</table>
			<?php
			}
			else { //we are not allowed to send to this person
			?>
			<table cellpadding="4" cellspacing="0" border="0" width="100%">
			    <tr>
					<td class="txt_title" align="right">
						<?php echo $lang['hdr_im_deny_send'];?><br />
						<hr />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['txt_im_deny_send'];?><br />
					</td>
				</tr>
			</table>
			<?php }?>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>

		</td>

		<td width="20">&nbsp;</td>

		<td width="180" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_friends'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<?php
			if (isset($users)) {
			?>
			<table border="0" width="100%" cellspacing="0" cellpadding="4">
				<tr>
					<td valign="top">
						<?php
							foreach ($users as $key => $i) :
						?>
								<a href="msg_compose.php?to_user_id=<?php echo $i['user_id']?>"><?php echo $i['profile_nic']?></a><br />
						<?php
							endforeach;
						?>
					</td>
				</tr>
			</table>
			<?php }?>
			</div>
			
			<div id="box_bottom">
				<table cellpadding="0" cellspacing="0" border="0" width="100%">
					<tr>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/box_bottom_left.png" width="5" height="18" alt="" border="0" /><br />
						</td>
						<td align="left">
							<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" border="0" /><br />
						</td>
						<td align="right">
							<img src="<?php echo $templatePath;?>img/box_bottom_right.png" width="5" height="18" alt="" border="0" /><br />
						</td>
					</tr>
				</table>
			</div>
		</td>
	</tr>
</table>
</form>
