<?php
    session_start();
	if ( empty($_SESSION['login']) ) {
        header( 'Location: login.php' );
        die;
	}

	include 'include/header.php';
?>

    <script type="text/javascript">
        function get_alerts() {
            $.get(
                'hotList.php',
                function(data, status){
                    $('#alerts').html(data);
            });
        }

        function get_offline_systems() {
            $.get(
                "offlineRoomList.php",
                function(data, status){
                    $('#offline').html(data);
            });
        }

        function reset_alert(id) {
            $.post(
                "resetAlert.php",
                { id: id },
                function(data){
                    get_alerts();
                }
            );
        }

        $(function(){
            get_alerts();
            get_offline_systems();

            window.setInterval(function() {
                get_alerts();
                get_offline_systems();
            }, 5000);
        });
    </script>

    <div class="wrap pad-bottom">

        <h1 class="pad">USM - Main Menu</h1>

        <div id="nav">
            <a href="/" class="selected">Home</a>
            <a href="roomList.php">Room View</a>
            <a href="reports.php">Reports</a>
            <a href="admin.php">Administration</a>
            <a href="logout.php">Logout</a>
        </div>

        <hr>

        <h2 class="pad-top">Alerts</h2>
        <div id="alerts" class="center"></div>

        <h2 class="pad-top">Offline Systems</h2>
        <div id="offline" class="center"></div>

    </div>

<?php include('include/footer.php'); ?>