<? 
$this->title->elem('a');
$this->title->cssClass('new_message');
$this->title->name($this->Language('new_message'));
$this->title->create($this->Language('Messages'));
?>

<form method="post">
<div  class="new_message_box hidden">
<table class="header">

<tr>
	<th><?=$this->Language('name', true);?></th>
	<td><input type="text"    name="name"></td>
</tr>


<tr>
	<th><?=$this->Language('language', true);?></th>
	<td>
	<select name="language">
	<?
	while($row = $this->language_menus->Assoc()){

		$selected = '';
		if($_POST['language'] && $_POST['language'] == $row['language']) $selected = 'selected="selected"';
		if(!$_POST['language'] && $_SESSION['language'] == $row['language']) $selected = 'selected="selected"';

		echo '<option value="'.$row['key'].'" '.$selected.'>'.$row['language'].'</option>';
	}
	?></select></td>
</tr>


<tr>
	<th><?=$this->Language('type', true);?></th>
	<td>
	<select name="type">
	<?
	foreach($this->message_types as $row){

		$selected = '';
		if($_POST['type'] && $_POST['type'] == $row['name']) $selected = 'selected="selected"';

		echo '<option value="'.$row['name'].'" '.$selected.'>'.$row['name'].'</option>';
	}
	?></select></td>
</tr>


<tr>
	<th><?=$this->Language('subject', true);?></th>
	<td><input type="text"    name="subject"></td>
</tr>


<tr>
	<th><?=$this->Language('from_name', true);?></th>
	<td><input type="text"    name="from_name"></td>
</tr>


<tr>
	<th><?=$this->Language('from_email', true);?></th>
	<td><input type="text"    name="from_email"></td>
</tr>



<tr>
	<th><?=$this->Language('from phone', true);?></th>
	<td><input type="text"    name="from_phone"></td>
</tr>


<tr>
	<th><?=$this->Language('is_active', true);?></th>
	<td><input type="checkbox"    name="is_active" value="1"></td>
</tr>

<tr>
	<td></td>
	<td><input type="submit"    name="insert" value="<?=$this->Language('Insert');?>"></td>
</tr>
</table>
</div>


<table class="content">
<tr>

	<th><?=$this->Language('name', true);?></th>


	<th><?=$this->Language('language', true);?></th>




	<th><?=$this->Language('pikkus', true);?></th>


	<th><?=$this->Language('type', true);?></th>


	<th><?=$this->Language('subject', true);?></th>


	<th><?=$this->Language('from_name', true);?></th>


	<th><?=$this->Language('from_email', true);?></th>


	<th><?=$this->Language('from phone', true);?></th>


	<th><?=$this->Language('is_active', true);?></th>

	<th></th>

</tr>
<?PHP
 while($row = $this->templates->Assoc()){
?><tr>

	<td><a href="<?=$this->Link('?page=edit&id='.$row['id']);?>"><?=$row['name']?></a></td>


	<td><?=$row['language']?></td>




	<td><?=$row['content_length']?></td>


	<td><?=$row['type']?></td>


	<td><?=$row['subject']?></td>


	<td><?=$row['from_name']?></td>


	<td><?=$row['from_email']?></td>


	<td><?=$row['from_phone']?></td>


	<td><?=$row['is_active']?></td>


	<td><a href="<?=$this->Link('?action=delete&id='.$row['id']);?>" onclick="return $.confirm();"><?=$this->Language('delete');?></a></td>

</tr>
<? } ?></table>
</form>


<script type="text/javascript">
$('.new_message').click(function(){

	$('.new_message_box').slideBox(500);
	return false;
});
</script>