$currentdate = date('Y-m-d');
    $currenttime = date('H:i:s');
    ?>
            
            <a name="view-<?php 
    echo $nameid;
    ?>
"></a>
            <div id="<?php 
    echo $nameid;
    ?>
" class="branch">
            
              <div class="controls visible-phone">
                <p class="status"><?php 
    echo displayCurrentStatus($currentdate, $currenttime, $id);
    ?>
</p>
                <p><a class="button green show-locations">&laquo; All Locations</a></p>
              </div>
              
              <a class="return-to-map close-box">Close</a>
              
              <section class="bio">
                
                <header>
                  <h1><a href="<?php 
    echo $url;
    ?>
"><?php 
    echo $name;
        $nextopen = $location->appendChild($nextopen);
        $notext = $doc->createTextNode($next_open_time);
        $notext = $nextopen->appendChild($notext);
    }
    header('Content-Type: text/xml');
    $xml = $doc->saveXML() . "\n";
    echo $xml;
    exit;
}
// data for todays hours for a locations
if ($timeframe == 'today' && !empty($location_login) && !empty($location_id)) {
    $ymd = date("Y-m-d");
    $time = date("H:i");
    $hours_by_date = getHoursByDate($ymd, $location_id, $type_id);
    $location_name = getName($location_login);
    $location_status = displayCurrentStatus($ymd, $time, $location_id);
    $location = $doc->createElement('location');
    $location = $root->appendChild($location);
    $name = $doc->createElement('name');
    $name = $location->appendChild($name);
    $ntext = $doc->createTextNode($location_name);
    $ntext = $name->appendChild($ntext);
    $date = $doc->createElement('date');
    $date = $location->appendChild($date);
    $dtext = $doc->createTextNode(date("M j"));
    $dtext = $date->appendChild($dtext);
    $otime = $doc->createElement('open_time');
    $otime = $location->appendChild($otime);
    $ottext = $doc->createTextNode(displayTime($hours_by_date[0]['open_time']));
    $ottext = $otime->appendChild($ottext);
    $ctime = $doc->createElement('close_time');
                    } else {
                        $widget .= displayTime($today[0]['open_time']) . ' - ' . displayTime($today[0]['close_time']) . '</p>';
                    }
                }
                //closes if-elseif-else
                // if no return
            } else {
                $widget .= 'N/A';
            }
            //closes if-else
            $widget .= '
</div>';
        } else {
            if ($display == 'status') {
                // grab status based on date, time and location (library hours only)
                $status = displayCurrentStatus($currentdate, $currenttime, $location1);
                $widget = '
<div class="hours-widget">
  <p><strong>' . $status . '</strong></p>
</div>';
            } else {
                if ($display == 'homepage') {
                    // grab full table display for the homepage
                    $widget = displayLocationsStatusHomepage();
                } else {
                    $widget = '
<div class="hours-widget">
  <p>Sorry, no hours available for this view.</p>
</div>';
                }
            }
function displayLocationsStatusHomepage($branchID = null)
{
    global $dbh;
    if ($branchID == null) {
        $hourlocation = "";
    } else {
        if ($branchID != null && is_int($branchID)) {
            $hourlocation = "AND hour_locations.id = {$branchID}";
        }
    }
    //closes if-else
    $currentdate = date('Y-m-d');
    $currenttime = date('H:i:s');
    $sql = "SELECT hour_locations.id, hour_locations.name, hour_locations.parent_hour_location_id AS parent, hour_locations.login\r\n          FROM hour_locations\r\n          WHERE hour_locations.display = 1\r\n          {$hourlocation}\r\n          ORDER BY hour_locations.display_position";
    $sth = $dbh->prepare($sql);
    $status = $sth->execute();
    $results = $sth->fetchAll();
    $count = count($results);
    // alternating rows start with false (white row first)
    $alt = false;
    // variable to store code string
    $locationstable = '<dl id="locations-table"><span class="headers"><dt>Location</dt><dd>at ' . date('g:i a') . '</dd></span>';
    for ($i = 0; $i < $count; $i++) {
        $id = $results[$i]['login'];
        $url = 'http://hours.library.ubc.ca/#view-' . $results[$i]['login'];
        // start the display with appropriate span tag (inserts alternating rows)
        if ($alt == false && $results[$i]['parent'] == NULL) {
            $locationstable .= '<a href="' . $url . '" title="Click to see this location"><span class="slide-out ' . $id . '">';
            $alt = true;
        } else {
            if ($alt == true && $results[$i]['parent'] == NULL) {
                $locationstable .= '<a href="' . $url . '" title="Click to see this location"><span class="alt slide-out ' . $id . '">';
                $alt = false;
            } else {
                if ($alt == false && $results[$i]['parent'] != NULL) {
                    $locationstable .= '<a href="' . $url . '" title="Click to see this location"><span class="alt slide-out sublevel ' . $id . '">';
                } else {
                    if ($alt == true && $results[$i]['parent'] != NULL) {
                        $locationstable .= '<a href="' . $url . '" title="Click to see this location"><span class="slide-out sublevel ' . $id . '">';
                    }
                }
            }
        }
        //closes if-elseif
        // add image
        $locationstable .= '<dt>';
        // indent "hack" for sublevels (padding/margin breaks display)
        if ($results[$i]['parent'] == NULL) {
            $locationstable .= $results[$i]['name'];
        } else {
            $locationstable .= '&nbsp; &nbsp; ' . $results[$i]['name'];
        }
        //closes if-else
        // add status (uses displayCurrentStatus function to retrieve and calculate status)
        $locationstable .= '</dt><dd>' . displayCurrentStatus($currentdate, $currenttime, $results[$i]['id']) . '</dd></span></a>';
    }
    //closes for
    // close list
    $locationstable .= '</dl>';
    // deal with apostrophe in St. Paul's
    return str_replace("'", "\\'", $locationstable);
}