<?php
//Kill the session and take the user to login page if username is not there
//in the session.
session_start();
if (!array_key_exists('username', $_SESSION))
    header('Location: admin_logout.php');

if ($_SESSION['username'] == null)
    header('Location: admin_logout.php');

//css menus in this file courtesy:
//http://www.shingokko.com/blog-entry/pure-css-hover-menu.html

function PrintTopbar($sectionTitle)
{
    $sectionTitle = $sectionTitle == '' ? 'Welcome!' : $sectionTitle;
    echo "
            <link rel='stylesheet' href='admin_style_topbar.css' type='text/css' />
            <div id='topbar' class='topbar'>
                <div id='sectionTitle' class='sectionTitle'>
                    $sectionTitle
                </div>
                <div id='menu'>
                    <ul class='menuList'>
                        <li class='menuTile'>
                            <a href='admin.php' title='View the welcome message!'>Home</a>
                        </li>
                        <li class='menuTile'>
                            <a href='#' title='Perform functions related to other admin users.'>Admin User Management</a> <span style='color: lightgray; font-size: small;'>▼</span>
                            <ul class='submenu'>
                                <li>
                                    <a href='admin_user_create.php' title='Create a new admin user for this application.'>Create</a>
                                </li>
                                <li>
                                    <span' title='Deactivate an existing admin for this application.'>Deactivate</span>
                                </li>
                            </ul>

                        </li>
                        <li class='menuTile'>
                            <a href='#' title='Manage survey that the Carview application can display.'>Survey Management</a> <span style='color: lightgray; font-size: small;'>▼</span>
                            <ul class='submenu'>
                                <li>
                                    <a href='admin_survey_create.php' title='Create a new survey and add new questions to it'>
                                    Create
                                    </a>
                                </li>
                                <li>
                                    <a href='admin_survey_search.php' title='Update an exiting survey.'>
                                    Update
                                    </a>
                                </li>
                                <li>
                                    <a href='admin_survey_availability.php' title='Make a survey available or unavailable to end users.'>
                                    Hide/Unhide Surveys
                                    </a>
                                </li>
                            </ul>

                        </li>
    <!--
                        <li class='menuTile'>
                            <a href='admin_download_data.php'>
                                Download Data
                            </a>
                        </li>
    -->
                        <li class='menuTile'>
                            <div>
                                <a href='admin_logout.php' title='Sign off from the application and go to the login page.'>Logout</a>
                            </div>
                        </li>
                    </ul>
                </div>
            </div>";
}
?>

