<div id="wrapper">
    <div id="header">
        <ul>
            <li><a href="">Homepage</a></li>
            <li><a href="product">Information</a></li>
            <li><a href="page/index/article">Articles</a></li>
            <?php $i = 0; ?>
            <?php foreach (page::get_list_by_path('navigation') as $p) : ?>
                <li><a href="page/view/<?php echo htmlspecialchars($p['path']); ?>"><?php echo htmlspecialchars($p['name']); ?></a></li>
                <?php if ($i++ == 5) : ?>
                    <li><a href="page/index/navigation">More &#62;&#62;</a></li>
                    <?php break; ?>
                <?php endif; ?>
            <?php endforeach; ?>
            <li><a href="contact">Contact Us</a></li>
        </ul>
    </div>
    <div id="body" class="clear">
        <div id="menu">
            <div id="search" class="box">
                <p>Search</p>
                <form method="get" action="search">
                    <div class="clear">
                        <div><input name="search" type="text" class="search" value="" /></div>
                        <div><input type="image" class="submit" src="web/skin/search.gif" /></div>
                    </div>
                </form>
            </div>
            <?php $tree = category::get_tree(); ?>
            <?php if ($tree) : ?>
                <?php
                function tree(array &$tree, $parent = 1, array $attribute = array(), $top = false, $path = '')
                {
                    echo '<ul';
                    
                    foreach ($attribute as $k => $v)
                    {
                        echo ' ', $k, '="', htmlspecialchars($v), '"';
                    }
                    
                    echo '>';
                    
                    foreach ($tree[$parent] as $c)
                    {
                        echo '<li' . (($top) ? ' class="box"' : '') . '>';
                        echo '<a href="product/index/' . htmlspecialchars($path . $c['path']) . '"' . (($top) ? ' class="title"' : '') . '>' . htmlspecialchars($c['name']) . '</a>';
                        
                        if (array_key_exists($c['id'], $tree))
                        {
                            tree($tree, $c['id'], array(), false, ltrim($path . '/' . $c['path'] . '/', '/'));
                        }
                        
                        echo '</li>';
                    }
                    
                    echo '</ul>';
                }
                ?>
                <div id="tree">
                    <?php tree($tree, 1, array('id' => 'navigation'), true); ?>
                </div>
                <script src="extend/widget/treeview/jquery.treeview.js" type="text/javascript"></script>
                <script type="text/javascript">
                    $(document).ready(function(){
                        $("#navigation").treeview({
                            persist:"location",
                            collapsed:true,
                            unique:false
                        });
                    });
                </script>
            <?php endif; ?>
        </div>
        <div id="content">
            <?php echo $content; ?>
        </div>
    </div>
    <div id="footer">
        <ul>
            <?php $i = 0; ?>
            <?php foreach (page::get_list_by_path('footer') as $p) : ?>
                <li><a href="page/view/<?php echo htmlspecialchars($p['path']); ?>"><?php echo htmlspecialchars($p['name']); ?></a></li>
                <?php if ($i++ == 5) : ?>
                    <li><a href="page/index/footer">More &#62;&#62;</a></li>
                    <?php break; ?>
                <?php endif; ?>
            <?php endforeach; ?>
        </ul>
        <p><?php echo partial::get_by_name('copyright'); ?></p>
    </div>
</div>