<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Hospital Bed Finder</title>
    <link rel="stylesheet" href="/css/hospitalfeed.css">
    <link rel="icon" type="image/x-icon" href="/images/logo.png">
</head>
<body>
    <div id="wrapper">
        <header>
            <div class="feedHeader">
                <div class="logo">
                    <div>
                        <img src="/images/logo.png" alt="HBF_LOGO">
                    </div>
                    <h1 class="logoName">
                        <a class="whiteText" href="https://hospitalbedfinder.com">H<span class="nameLower">ospital</span> B<span class="nameLower">ed</span> F<span class="nameLower">inder</span></a>
                    </h1>    
                </div>
                <div class="search whiteText">
                    <div class="searchWrapper">
                        <div>
                            <img src="/images/search.png" alt="Search icon">
                        </div>
                        <input type="search" id="searchBar" placeholder="Search...">
                    </div>
                </div>
                <div class="signUpOptions">
                    <p class="whiteText">Are you a representative of a hospital?</p>
                    <div>
                        <button id="accountButton" class="signUpButton">Sign up >></button>
                    </div>
                </div>
            </div>
            <ul class="legendHeader whiteText">
                <li><img src="/images/legend.png" alt="Legend"> Legend: </li>
                <li><img src="/images/location_white.png" alt="Address"> - Address</li>
                <li><img src="/images/contactNum_white.png" alt="Contact number"> - Contact number</li>
                <li><img src="/images/maxBeds.png" alt="Maximum Beds"> - Maximum Beds</li>
                <li><img src="/images/availableBeds.png" alt="Available Beds"> - Available Beds</li>
            </ul>
            <div class="spacer"></div>
        </header>
        <main>
            <h1 id="noHospitalsText" class="noneIndicator <%= hospitals.length > 0 ? 'hide' : '' %>">No hospitals found</h1>
            <div class="hospitalsContainer" id="hospitalsDiv">
                <% hospitals.forEach(hospital => { %>
                    <% if (hospital.validated) { %>
                        <div class="hospitalBox">
                            <div id="<%= hospital._id %>_image" class="hospitalIdentifier hospitalFont" style="background-image: url('<%= hospital.image%>')">
                                <div class="hospitalName">
                                    <p id="<%= hospital._id %>_name" class="whiteText"><%= hospital.name %></p> 
                                </div>
                            </div>
                            <div class="hospitalDetails">
                                <ul class="detailsList hospitalFont">
                                    <li id="<%= hospital._id %>_location"><img src="/images/location.png" alt="Location">: <%= hospital.location %></li>
                                    <li id="<%= hospital._id %>_contactNum"><img src="/images/contactNum.png" alt="Contact Number">: <%= hospital.contactNum %></li>
                                </ul>
                                <ul class="bedsList">
                                    <li class="maxBedsBar">
                                        <div>
                                            <img src="/images/maxBeds.png" alt="Max Beds">
                                        </div>
                                        <div>
                                            <span id="<%= hospital._id %>_maxBeds"><%= hospital.maxBeds %></span>
                                        </div>
                                    </li>
                                    <li id="<%= hospital._id %>_availableBedsBar" class="availableBedsBar">
                                        <div>
                                            <img src="/images/availableBeds.png" alt="Available Beds">
                                        </div>
                                        <div>
                                            <span id="<%= hospital._id %>_availableBeds"><%= hospital.availableBeds %></span>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    <% } %>
                <% }) %>
            </div>
        </main>
    </div>
</body>
<script>
    let baseUrl = window.location.origin;

    // Account page redirect
    function Account(){
        window.location.href = `${baseUrl}/interface/account`;
        return;
    }
    document.getElementById("accountButton").addEventListener("click", Account);
</script>
<script src="/js/availableBedsBackgroundSet.js"></script>
<script src="/js/homepageSearch.js"></script>
<script src="/js/hospitalUpdate.js"></script>
<script src="/js/noHospitalsFound.js"></script>
</html>