<?php

// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003 - 2006 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., 51 Franklin St, Fifth Floor, Boston, MA
// 02110-1301, USA.
// -----------------------------------------------------------------------

?>

<script language="JavaScript" src="js/imageHandling.js" type="text/javascript"></script>

<form action="grp_edit.php" method="post" name="frm" id="id_frm">
<input type="hidden" name="group_id" value="<?php echo $group['group_id'];?>" />


<div class="box">
	<div class="box_top">
		<?php echo $lang['hdr_group'];?><br />
	</div>
	
	<div class="box_mid">
		<div class="content">
			<?php
			if (isset($display) && $display == "archive_group") {
			?>
			<p>
				<?php echo $lang['txt_archive_group'];?><br />
			</p>
			
			<p align="right">
				<input type="submit" name="archive_group_confirm" class="button" value="<?php echo $lang['sub_confirm_archive'];?>" /><br />
			</p>
			<?php
			}
			elseif (isset($display) && $display == "edit_group_rules") {
			?>
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td>
						<b>
						<?php echo $lang['hdr_group'];?></b><br />
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="12" alt="" /><br />

					</td>
					<td colspan="2">
						<br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<fieldset>
						<legend><?php echo $lang['txt_header_1'];?></legend>
						<p>
						<?php echo $lang['txt_rules_intro'];?><br />
						</p>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />

						<table border="0" cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td valign="top" width="310">
									<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['sub_preview'];?>" />&nbsp;&nbsp;
												<input type="button" value="<?php echo $lang['sub_check_spelling'];?>" onClick="openSpellChecker();" /><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>
								</td>
							</tr>
						</table>
						</fieldset>
					</td>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="10" height="1" alt="" /><br />
					</td>
					<td valign="top" width="200">
						<fieldset>
						<legend><?php echo $lang['txt_header_4'];?></legend>
						<p>
						<?php echo $lang['txt_save_intro'];?><br />
						</p>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
							<input type="submit" name="save_rules" value="<?php echo $lang['sub_save'];?>" />&nbsp;
							<input type="submit" name="save_go_rules" value="<?php echo $lang['sub_save_go'];?>" /><br />
							
						</fieldset>
					</td>
				</tr>
			</table>
			<?php
			}
			else {
			?>
			<table border="0" cellspacing="0" cellpadding="0" width="100%">
				<tr>
					<td>
						<b>
						<?php echo $lang['hdr_group'];?></b><br />
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="12" alt="" /><br />

					</td>
					<td colspan="2">
						<br />
					</td>
				</tr>
				<tr>
					<td valign="top">
						<fieldset>
						<legend><?php echo $lang['txt_header_1'];?></legend>
						<p>
						<?php echo $lang['txt_overview_intro'];?><br />
						</p>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />

						<table border="0" cellspacing="0" cellpadding="0" width="100%">
							<tr>
								<td valign="top" width="310">
									<p>
										<label for="id_title"><?php echo $lang['txt_title'];?></label>
										<input type="text" id="id_title" name="group_title" size="35" 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="35"><?php echo $group['group_synopsis'];?></textarea><br />
									</p>
									
									
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
					<?php
					
				if (!empty($lang['arr_group']['custom_item'])) {
					foreach ($lang['arr_group']['custom_item'] as $key => $i):
					$field ="";
					if (!empty($group['group_custom_items'])) {
						foreach ($group['group_custom_items'] as $gikey => $gi):
							if ($key == $gi['custom_item_id']) {
								$field = $gi['custom_item_body'];
								unset ($group['group_custom_items'][$gikey]);
								break;
							}
						endforeach;
					}
					?>
					<tr>
						<td>
							<?php echo $i;?><br />
						</td>
						<td>
							<input type="text" class="input" name="group_custom_items[<?php echo $key;?>]" size="26" value="<?php echo $field;?>" /><br />
						</td>
					</tr>
				<?php
				endforeach;
				?>
				
				<tr>
					<td colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
					</td>
				</tr>
				<?php }?>
			</table>
				
									<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>
									
									<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>
									
									<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>
									</table>
								</td>
							</tr>
						</table>
						</fieldset>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_2'];?></legend>
						<p>
						<?php echo $lang['txt_detail_intro'];?><br />
						</p>
									
						<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['sub_preview'];?>" />&nbsp;&nbsp;
									<input type="button" value="<?php echo $lang['sub_check_spelling'];?>" onClick="openSpellChecker();" /><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>
						</fieldset>
					</td>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="10" height="1" alt="" /><br />
					</td>
					<td valign="top" width="200">
						<fieldset>
						<legend><?php echo $lang['txt_header_5'];?></legend>
						<p>
						<?php echo $lang['txt_image_intro'];?><br />
						</p>

						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />

						<?php
						if (isset($images)) {
						?>
						<p>
						<?php echo $lang['form_label_file'];?></label><br />
						</p>

						<div>
						<p>
						<select id="id_file_id" size=4 name="file_id" onChange='javascript:setimg(this)'>
						<option value="0" selected="selected"><?php echo $lang['txt_none'];?></option>
						<?php
						$img_divs = "";
						foreach($images as $key => $i):
						$display_state = "none";
						$selected = "";
						if (isset($group['file_id']) && $group['file_id'] == $i['file_id']) {
						    $selected = "selected=\"selected\"";
							$display_state = "block";
						}
						?>
						<option value="<?php echo $i['file_id'];?>" <?php echo $selected;?>><?php echo $i['file_name'];?></option>
						<?php
						$img_divs .= "<div style=\"display:" . $display_state . ";\" id=img" . $i['file_id'] . "><img src=\"get_file.php?file=" . $i['file'] . "\" border=\"0\" class=\"picture\" /><br />" . $i['file_title'] . "</div>";
						endforeach;
						?>
						</select>
						</p>
						</div>
						<?php echo $img_divs;?>
						<?php }?>
						</fieldset>

						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />

						<fieldset>
						<legend><?php echo $lang['txt_header_3'];?></legend>
						<p>
						<?php echo $lang['txt_publishing_intro'];?><br />
						</p>
						
						<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>
						</fieldset>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="9" alt="" /><br />
						
						<fieldset>
						<legend><?php echo $lang['txt_header_4'];?></legend>
						<p>
						<?php echo $lang['txt_save_intro'];?><br />
						</p>
						
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="6" alt="" /><br />
						
							<input type="submit" name="save_overview" value="<?php echo $lang['sub_save'];?>" />&nbsp;
							<input type="submit" name="save_go_overview" value="<?php echo $lang['sub_save_go'];?>" /><br />
							
						</fieldset>
					</td>
				</tr>
			</table>
			<?php }?>
		</div>
	</div>
</div>

<div class="box_bottom">
	<span class="box_bottom_right"></span>
	<span class="box_bottom_left"></span>
</div>
