<?
	if ( !isset($_GET['article']) ) {
		echo '<h3>Táto sekcia je venovaná poznámkam rôznych predmetov.</h3>';
		if ( !isset($_GET['add']) ) {
			if ( $main->is_logged($_SESSION['id_user']) ) {
				echo '<h4>&raquo;&nbsp;<a href="?id=' . $_GET['id'] . '&amp;add=1" title="Pridajte vlastné poznámky">Pridajte vlastné poznámky</a></h4>';
			}
			$main->return_subjects($_GET['id']);
			echo '<div class="txt_panel">';
				$main->return_article_list('poznámok');
			echo '</div>';
		} else {
			if ( $main->is_logged($_SESSION['id_user']) ) {
				echo '<h4>&raquo;&nbsp;<a href="' . str_replace('&add=1', '', $_SERVER['REQUEST_URI']) . '" title="Spat">Spat</a></h4>';
				echo '<iframe src="rs/" style="width: 100%; height: 960px; border: 0px solid #000000;"></iframe>';
			}
		}
	} else {
        $rate_val = array(1,2,3,4,5); //hodnoty akceptovane pri hlasovani

        if ( isset($_GET['history']) ) {
            $sql_article = 'SELECT * FROM articles WHERE id=' . $_GET['article'];  //pokial zobrazujem clanok z historie zobrazim ho
            $back = array('article');
        } else {
           $sql_article = 'SELECT * FROM articles WHERE remake_of=' . $_GET['article'] . ' ORDER BY utime DESC'; //inak zobrazim najnovsi a vsetky ktoremu predchadzali
           $back = array();
        }
        if ( isset($_GET['rate']) ) {
            if ( in_array($_GET['rate'], $rate_val) ) {
                $main->rating_exe($_GET['rated_id'],$_GET['rate']);
            } else {
                echo $main->return_error_text("Daná hodnota nieje platné celé číslo &gt;= 1 a &lt;= 5  ");
            }
        }
		if ( $result_article = mysql_query($sql_article) ) {
			echo '<div class="txt_panel">';
            echo $main->back_button('id', $back);
				$row_article = mysql_fetch_assoc($result_article);
				echo '<h2>' . $row_article['nadpis'] . '</h2>';
				echo '<div class="article_body">' . $row_article['popis'] . '</div>';

            echo '<a id="v_slideout" style="display: none;" href="#">slide out</a>';
    		echo '<a id="v_slidein" style="display: none;" href="#">slide in</a>';
            if ( $main->is_logged($_SESSION['id_user']) ) {
                echo $main->show_hide();
                echo '<div id="vertical_slide" style="margin-top: 10px;">';
                echo '<div style="float: left;">';
                echo '<form action="' . str_replace('&','&amp;',$_SERVER['REQUEST_URI']) . '" method="post">';
                echo    '<div class="submit"><input type="submit" value="Uprav" /></div>';
                echo '</form>';
                echo '</div>';
                echo '<div style="float: left; margin-left: 30px; padding: 5px;"><span style="font-weight: bold; color: #00377E;">Pridal:</span> ' . $main->get_user_name($row_article['add_by']) . '</div>';
                echo '<div style="float: right; margin-left: 30px;">';
                if ( $row_article['rated'] != 0 ) { //tu sa vola vypis hviezdiciek
                    if ( isset($_GET['history']) ) {
                        echo $main->rating_form($_GET['history']);
                    } else {
                        echo $main->rating_form($row_article['id']);
                    }
                    //echo $main->rating_form($row_article['rate']/$row_article['rated']);
                } else {
                    echo $main->rating_form(0); //tu musim doplnit id-cko !!!!!!!!!!!!!!
                }
                echo '</div>';
                echo $main->cleaner;
                echo '</div>';
            }

			echo '</div>';
            if ( !isset($_GET['history']) ) {
                echo '<div class="history_panel">';
                echo '<h3>História úprav daného článku:</h3>';
                echo '<ul>';
                while ( $row_article = mysql_fetch_assoc($result_article) ) {
                    echo '<li><a href="?id=' . $_GET['id'] . '&amp;article=' . $_GET['article'] . '&amp;history=' . $row_article['id'] . '" title="">' . $row_article['nadpis'] . ' <span style="font-size: 10px;"><br />[ ' . $row_article['date'] . ' ]</span>' . '</a>
                            <br /><div style="float: right;">pridal: ' . $main->get_user_name($row_article['add_by']) . '</div>' . $main->cleaner . '</li>';
                }
                echo '</ul>';
                echo '</div>';
            }
            echo $main->cleaner;
		}
	}
?>