<?
    $GLOBALS
['highlight'] = 'quilts';
    
    require_once(
'include/functions/pages.php');
    require_once(
'include/functions/quilt_information.php');
    require_once(
'include/functions/tile_is_available.php');
    
    
$_page = isset($_GET['p']) ? intval($_GET['p']) : 1;

    include(
'include/parts/header.php');
    
    
$entries mysql_fetch_array(mysql_query("SELECT COUNT(*) AS num FROM quilts WHERE finished = '0'"));
    
$page_count ceil($entries['num'] / 5);
    
$pages '<span class="pages">Page: ' pages('?s=quilts'$_page$page_count) . '</span><br />';
?>

<div class="header">
<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td valign="top">
Quilts<?= $entries['num'] ? '<br />' $pages '' ?>
<?
    
if ($GLOBALS['auth']['create_quilt'])
    {
        echo 
'</td><td align="right" valign="top" style="color: #cccccc; font-weight: normal;">[ <a href="?s=quilt_create">Create Quilt</a> ]';
    }
?>
</td></tr></table>
</div>
<?
    $quilts 
mysql_query("SELECT * FROM quilts WHERE finished = '0' ORDER BY modified_on DESC, id DESC LIMIT " . (($_page 1) * 5) . ", 5");
    if (
mysql_num_rows($quilts))
    {
        while (
$quilts_row mysql_fetch_array($quilts))
        {
            echo 
'<div class="content">' "\r\n";
            echo 
'<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="250" valign="top" nowrap>';
            echo 
'<a href="?s=quilt&i=' $quilts_row['id'] . '"><img src="?g=quilt_thumb&i=' $quilts_row['id'] . '" style="border: 0px;"></a><br />';
            echo 
'</td><td valign="top" style="padding-left: 10px">';
            echo 
'<a href="?s=quilt&i=' $quilts_row['id'] . '" style="font-weight: bold;">' $quilts_row['name'] . '</a><br />' "\r\n";
            
quilt_information($quilts_row['id']);
            echo 
'</td></tr></table>' "\r\n";
            echo 
'</div>' "\r\n";
        }
    }
    else
    {
        echo 
'<div class="content">Sorry there are no quilts on the site.</div>';
    }
    if (
$entries['num'])
    {
        echo 
'<div class="header">' $pages '</div>';
    }

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