<?php
	$main->forum_react($_SESSION['id_user']);
	echo '<div style="border-bottom: 1px solid #00377E; margin-bottom: 10px; padding-bottom: 10px;">';
        if ( isset($_GET['del']) && (trim($_GET['del'])!='') ) {
            if ( isset($_GET['id_tema']) && (trim($_GET['id_tema'])!='') ) {
                $main->remove_tema(addslashes(strip_tags($_GET['del'])), $_GET['id_tema']);
            } elseif ( isset($_GET['id_post']) && (trim($_GET['id_post'])!='') ) {
                $main->remove_post($_GET['id_post']);
            }
        }
        if ( !isset($_GET['tema']) ) {
            if ( isset($_POST['add_temu']) && isset($_POST['nazov_temy']) && (trim($_POST['nazov_temy'])!='') ) {
                $main->forum_add_temu(addslashes(strip_tags(trim($_POST['nazov_temy']))), $_SESSION['id_user']);
            }
            echo '<div style="background-color: #EEEEEE; margin-bottom: 15px; padding: 10px;">pridaj temu:';
            echo '
                <form action="' . $main->form_action . '" method="post">
                    <input type="text" name="nazov_temy" value="" />
                    <input type="submit" name="add_temu" value="Pridaj" />
                </form></div>
            ';
            $main->forum_temy();
        } else {
            echo $main->back_button('id', array());
            echo 'info o diskusnej téme:';
            echo '<table border="0" class="forum_temy">';
                echo '<tr>';
                    echo '<td class="first">zalozil</td>';
                    echo '<td class="first">nazov temy</td>';
                    echo '<td class="first">datum zalozenia</td>';
                    echo '<td class="first">pocet prispevkov</td>';
                echo '</tr>';
                $row = mysql_fetch_assoc(mysql_query('SELECT * FROM forum_temy WHERE id=' . $_GET['tema']));
                echo '<tr style="background-color: #EEEEEE;">';
                    echo '<td>' . $row['user_name'] . '</td>';
                    echo '<td>' . $row['nazov'] . '</td>';
                    echo '<td>' . $main->format_date($row['date']) . '</td>';
                    echo '<td>' . $main->pocet_postov($_GET['tema']) . '</td>';
                echo '</tr>';
            echo '</table>';
        }
	echo '</div>';
	
	echo '<div>&nbsp;';
		if ( isset($_GET['tema']) && ($_GET['tema'] != '') ) {
            if ( $main->is_logged($_SESSION['id_user']) ) {
                echo '<h3><a href="?id=' . $_GET['id'] . '&amp;tema=' . $_GET['tema'] . '&amp;addnew=1" title="">Pridať prispevok</a></h3>';
            }
			if ( isset($_GET['addnew']) && ($_GET['addnew']==1) ) {
				$main->forum_add_new($_SESSION['id_user'], $_GET['tema']);
			}
			if ( isset($_POST['prispevok']) && (trim($_POST['prispevok']) != '') ) {
				$main->forum_add_new_execute($_SESSION['id_user'], $_GET['tema']);
			}
		}
		$main->main_forum($_GET['tema']);
	echo '</div>';

	echo '<div style="clear: both;"></div>';
?>