<?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="search.php" method="post">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
	<tr>
		<td width="370" valign="top">
			<div class="box_top">
				<?php echo $lang['hdr_groups'];?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td>
						<?php echo $lang['txt_group_intro'];?><br />
					</td>
				</tr>
			</table>
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			
			<?php
			if (isset($display) && $display != "mygroups" || !isset($display)) {
			?>
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<tr>
					<td>
						<b><?php echo $lang['hdr_categories'];?></b><br />
					</td>
				</tr>
				<tr>
					<td>
						<?php
						$temp_category_parent_id = $category_parent_id;
						while( true ) {
							if (isset($category_parent_id) && $category_parent_id > 0) { // back button
							
								if (!isset($cat_tree)) {
								    $cat_tree = "&nbsp;&#47;&nbsp;" . $arr_category['tree'][$category_parent_id]['name'] . "&nbsp;";
								}
								else {
									$cat_tree = "&nbsp;&#47;&nbsp;<a href=\"g_groups.php?category_parent_id=" . $category_parent_id . "\">" . $arr_category['tree'][$category_parent_id]['name'] . "</a>&nbsp;" . $cat_tree;
								}
								
							$category_parent_id = $arr_category['tree'][$category_parent_id]['parent_id'];
							}
							else {
								break;
							}
						}
						$category_parent_id = $temp_category_parent_id;
						
						if (isset($category_parent_id) && $category_parent_id > 0) {
							$cat_tree = "<a href=\"g_groups.php\">" . $lang['txt_root'] . "</a>&nbsp;" . $cat_tree . "<br /><br />";
							echo $cat_tree;
						}
						
						$total_groups = $category_count;
						if (isset($categories)) {
							foreach($categories as $key => $i):
							?>
							&nbsp;&nbsp;&nbsp;&nbsp;<a href="g_groups.php?category_parent_id=<?php echo $i['category_id'];?>"><?php echo $i['name'];?></a> (<?php echo $i['total'];?>)<br />
							<?php
							$total_groups = $total_groups + $i['total'];
							endforeach;
						}
						?>
					</td>
				</tr>
				<tr>
					<td>
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
						
						<?php echo $lang['txt_total_cat_groups'];?>: 
						<?php
						if (isset($total_groups)) {
							echo $total_groups;
						}
						?>
						<br />
						<?php echo $lang['txt_total_groups'];?>: 
						<?php
						if (isset($group_statistics['total_groups'])) {
						    echo $group_statistics['total_groups'];
						}
						?>
						<br />
					</td>
				</tr>
			</table>
			
			
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<hr />
			<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="10" alt="" /><br />
			<?php }?>
			
			<table cellpadding="2" cellspacing="0" border="0">
				<tr>
					<td>
						<?php echo $lang['txt_search'];?>
					</td>
					<td>
						<input type="text" name="search_text" size="20" value="" /><br />
					</td>
					<td>
						<input type="image" src="<?php echo $templatePath;?>img/search.png" value="search" class="checkbox" /><br />
					</td>
				</tr>
			</table>
			
			</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="370" valign="top">
			<?php
			if (isset($display) && $display == "category") {
				$title = $arr_category['tree'][$category_parent_id]['name'];
			}
			elseif (isset($display) && $display == "mygroups") {
				$title = $lang['hdr_my_groups'];
			}
			else {
				$title = $lang['hdr_latest_groups'];
			}
			?>
			
			
			<div class="box_top">
				<?php echo $title;?><br />
			</div>
			
			<div class="box_mid" style="padding: 9px;">
			<table width="100%" cellpadding="4" cellspacing="0" border="0">
				<?php
				if (isset($groups)) {
				foreach($groups as $key => $i):
				?>
			    <tr>
					<td valign="top">
						<a href="g_group.php?group_id=<?php echo $i['group_id'];?>"><img align="left" src="get_file.php?file=<?php echo $i['image']['file'];?>" class="picture" alt="<?php echo $i['image']['file_title'];?>" /></a>
					</td>
					<td valign="top">
						<a href="g_group.php?group_id=<?php echo $i['group_id'];?>"><?php echo $i['group_title'];?></a><br />
						<?php echo $i['group_synopsis'];?><br />
						<p>
						<?php echo $lang['txt_recommended_age'];?>:
						<?
						if ($i['group_from_age'] && $i['group_to_age']) {
						    echo $i['group_from_age'] . "/" . $i['group_to_age'];
						}
						else if ($i['group_from_age'] && !$i['group_to_age']) {
							echo $lang['txt_age_from'] . " " . $i['group_from_age'];
						}
						else if (!$i['group_from_age'] && $i['group_to_age']) {
							echo $lang['txt_age_upto'] . " " . $i['group_to_age'];
						}
						else {
							echo $lang['txt_age_all'];
						}
						?>
						<br />
						</p>
					</td>
				</tr>
				<tr>
					<td colspan="2">
						<img src="<?php echo $templatePath;?>img/pixel.png" width="1" height="4" alt="" /><br />
					</td>
				</tr>
				<?php
				endforeach;
				} else {
				?>
				<tr>
					<td colspan="2">
						<?php echo $lang['err_no_groups'];?><br />
					</td>
				</tr>
				<?php }?>
			</table>
			</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>
