<?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="g_group_edit.php" method="post" name="frm" id="id_frm">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>

		<td width="180" valign="top">
			<?php
			include $templatePath . "g_menu.inc.tpl.php";
			?>
		</td>

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

		<td width="560" valign="top">
			<div class="box_top">
				<?php echo $lang['section_update'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			
			<?php
			if (isset($display) && $display == "edit_group_categories") {
			?>
			<table border="0" cellspacing="0" cellpadding="2" width="100%">
				<tr>
					<td>
						<?php echo $lang['txt_category_intro'];?><br />
					</td>
				</tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
					</td>
				</tr>
				<?php
				if (isset($arr_category)) {
					function getChildren($arr_category, $parent_id, $level_id, $templatePath, $categories) {
						foreach ($arr_category as $key => $i):
							//work out if the checkbox should be checked
							$selected = "";
							foreach ($categories as $cat => $r):
								if ($r['category_id'] == $key) {
								    $selected = "checked=\"checked\"";
									break;
								}
							endforeach;
							
						
						
							if ($i['parent_id'] == $parent_id) {
							?>
							<tr>
								<td valign="top">
									<?php
									if ($parent_id > 0) {
									?>
									<img src="<?php echo $templatePath;?>img/pink_dots_v.png" width="3" height="9" alt="" border="0" />
									<?php }?>
									
								
									<?php 
									$hor_ln = "<img src=\"" . $templatePath . "img/pink_dots_h.png\" height=\"3\" width=\"9\" alt=\"\" border=\"0\" />";
									echo str_repeat($hor_ln,$level_id);?>
									<img src="<?php echo $templatePath;?>img/pink_dot.png" width="3" height="9" alt="" border="0" />
									<?php echo $i['name'];?>
								</td>
								<td valign="top">
									<input type="checkbox" name="group_category[]" value="<?php echo $key;?>" <?php echo $selected;?> /><br/>
								</td>
							</tr>
							<?php
							getChildren($arr_category, $key, $level_id+1, $templatePath, $categories);
						   	}
					   endforeach; 
					}
				getChildren($arr_category, 0,0, $templatePath, $group['categories']);
				}
				?>
				<tr>
					<td align="right" colspan="2">
						<input type="submit" name="update_categories" value="<?php echo $lang['form_submit_update'];?>" class="button_urgent" />&nbsp;&nbsp;
					</td>
				</tr>
			</table>
			<?php
			}
			elseif (isset($display) && $display == "edit_group_rules") {
			?>
			
			<table border="0" cellspacing="0" cellpadding="2" width="10%">
				<tr>
					<td valign="top">
						<label for="id_group_rules"><?php echo $lang['form_body'];?></label>
						<div id="gui_wiki" align="right" valign="bottom">
							<script language="JavaScript" type="text/javascript" src="js/gui_wiki.js"></script>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<textarea id="id_group_rules" name="group_rules" cols="78" rows="10" onchange="textChanged = true;" tabindex="1"><?php if (isset($group['group_rules'])) { echo $group['group_rules'];}?></textarea><br />
						<script language="JavaScript" type="text/javascript">
							var txtarea = document.frm.group_rules;
						</script>
					</td>
				</tr>
				<?php 
				if (isset($allow_spellcheck)) {
				?>
				<tr>
					<td align="right">
						<input type="submit" name="preview_rules" value="<?php echo $lang['form_submit_preview'];?>" class="button_light" />&nbsp;&nbsp;
						<input type="button" value="<?php echo $lang['txt_check_spelling'];?>" onClick="openSpellChecker();" class="button_light" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($group['group_rules_preview'])) {
				?>
				
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['form_label_preview'];?><br />
					</td>
				</tr>
				<tr>
					<td class="picture_light">
						<?php echo $group['group_rules_preview'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
			
			<input type="submit" name="save_rules" class="button_urgent" value="<?php echo $lang['form_submit_save'];?>" />&nbsp;
			<input type="submit" name="save_go_rules" class="button_urgent" value="<?php echo $lang['form_submit_save_go'];?>" /><br />
		
			<?php
			}
			else {
			?>
			
			<p>
			<label for="id_title"><?php echo $lang['txt_title'];?></label>
			<input type="text" id="id_title" name="group_title" size="42" value="<?php echo $group['group_title'];?>"><br />
			</p>
			
			<p>
			<label for="id_synopsis"><?php echo $lang['txt_synopsis'];?></label>
			<textarea name="group_synopsis" id="id_synopsis" rows="2" cols="50"><?php echo $group['group_synopsis'];?></textarea><br />
			</p>
			
			<table border="0" cellspacing="0" cellpadding="2">
				<tr>
					<td valign="top">
						<p>
						<label for="id_group_registration_type"><?php echo $lang['txt_registration_type'];?></label>
						<select name="group_registration_type" id="id_group_registration_type">
						<?php foreach($lang['arr_registration_type'] as $key => $i): 
						?>
						<option value="<?php echo $key;?>" <? if($group['group_registration_type'] == $key) echo "selected=\"selected\"";?>><?php echo $i;?></option>
						<?php endforeach; ?>
						</select><br />
						</p>
					</td>
					<td valign="top">
						<p>
						<label for="id_language_id"><?php echo $lang['txt_language'];?></label>
						<select name="language_id" size="1" id="id_language_id">
							<?php
							foreach($lang['arr_lang_name'] as $key => $i): ?>
							<option value="<?php echo $key;?>" <? if($group['language_id'] == $key) echo "selected";?>><?php echo $i;?></option>
							<?php endforeach; ?>
						</select><br />
						</p>
					</td>
				</tr>
			</table>
			
			<table border="0" cellspacing="0" cellpadding="2">
				<tr>
					<td valign="top">
						<p>
						<label for="id_group_from_age"><?php echo $lang['txt_age_from'];?></label>
						<input type="text" size="5" id="id_group_from_age" name="group_from_age" value="<?php if(isset($group['group_from_age'])) { echo $group['group_from_age']; } else {echo $lang['txt_age_any'];}?>" />&nbsp;
						</p>
					</td>
					<td valign="top">
						<p>
						<label for="id_group_to_age"><?php echo $lang['txt_age_to'];?></label>
						<input type="text" size="5" id="id_group_to_age" name="group_to_age" value="<?php if(isset($group['group_to_age'])) { echo $group['group_to_age']; } else {echo $lang['txt_age_any'];}?>" /><br />
						</p>
					</td>
				</tr>
				<tr>
					<td>
						<p>
						<label style="width:100px" for="id_group_rsp_auto_publish"><?php echo $lang['form_group_rsp_auto_publish'];?></label>
						<input type="checkbox" id="id_group_rsp_auto_publish" name="group_rsp_auto_publish" class="checkbox" value="1" <?php if(isset($group['group_rsp_auto_publish'])) { echo "checked=\"checked\"";}?> /><br />
						</p>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="12" alt="" /><br />
			
			<table border="0" cellspacing="0" cellpadding="2" width="10%">
				<tr>
					<td valign="top">
						<label for="id_group_home_synopsis"><?php echo $lang['form_body'];?></label>
						<div id="gui_wiki" align="right" valign="bottom">
							<script language="JavaScript" type="text/javascript" src="js/gui_wiki.js"></script>
						</div>
					</td>
				</tr>
				<tr>
					<td>
						<textarea id="id_group_home_synopsis" name="group_home_synopsis" cols="78" rows="10" onchange="textChanged = true;" tabindex="1"><?php if (isset($group['group_home_synopsis'])) { echo $group['group_home_synopsis'];}?></textarea><br />
						<script language="JavaScript" type="text/javascript">
							var txtarea = document.frm.group_home_synopsis;
						</script>
					</td>
				</tr>
				<?php 
				if (isset($allow_spellcheck)) {
				?>
				<tr>
					<td align="right">
						<input type="submit" name="preview_overview" value="<?php echo $lang['form_submit_preview'];?>" class="button_light" />&nbsp;&nbsp;
						<input type="button" value="<?php echo $lang['txt_check_spelling'];?>" onClick="openSpellChecker();" class="button_light" /><br />
					</td>
				</tr>
				<?php }?>
				
				<?php
				if (!empty($group['group_home_synopsis_preview'])) {
				?>
				
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php echo $lang['form_label_preview'];?><br />
					</td>
				</tr>
				<tr>
					<td class="picture_light">
						<?php echo $group['group_home_synopsis_preview'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
						
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
			
			<input type="submit" name="save_overview" class="button_urgent" value="<?php echo $lang['form_submit_save'];?>" />&nbsp;
			<input type="submit" name="save_go_overview" class="button_urgent" value="<?php echo $lang['form_submit_save_go'];?>" /><br />
			<?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>