<div class="clear">
    <?php foreach ($category as $c) : ?>
        <div class="icon" id="category_<?php echo htmlspecialchars($c['id']); ?>">
            <div class="content">
                <a href="category/index/<?php echo htmlspecialchars($c['id']); ?>">
                    <img src="<?php echo htmlspecialchars(($c['image']) ? category::DIRECTORY . $c['image'] . '-s.jpg' : 'admin/skin/icon/folder1.png'); ?>?<?php echo time(); ?>" /><br /><?php echo htmlspecialchars((strlen($c['name']) > 20) ? substr($c['name'], 0, 17) . '...' : $c['name']); ?>
                </a>
            </div>
            <div class="action">
                <a href="javascript:unfeature_category(<?php echo htmlspecialchars($c['id']); ?>);">Unfeature</a>
            </div>
        </div>
    <?php endforeach; ?>
</div>
<div class="clear">
    <?php foreach ($product as $p) : ?>
        <div class="icon product" id="product_<?php echo htmlspecialchars($p['id']); ?>">
            <div class="content">
                <a href="product/index/<?php echo htmlspecialchars($p['id']); ?>">
                    <img src="<?php echo htmlspecialchars(($p['image']) ? product::DIRECTORY . $p['image'] . '-s.jpg' : 'admin/skin/icon/file1.png'); ?>?<?php echo time(); ?>" /><br /><?php echo htmlspecialchars((strlen($p['name']) > 20) ? substr($p['name'], 0, 17) . '...' : $p['name']); ?>
                </a>
            </div>
            <div class="action">
                <a href="javascript:unfeature_product(<?php echo htmlspecialchars($p['id']); ?>);">Unfeature</a>
            </div>
        </div>
    <?php endforeach; ?>
</div>

<script type="text/javascript">
    function unfeature_category(id)
    {
        $.post('category/unfeature', { id:id },
            function(data, status) {
                if (data.error != '')
                {
                    alert(data.error);
                }
                else
                {
                    $('#category_' + id).remove();
                }
            }, 'json');
    }
    
    function unfeature_product(id)
    {
        $.post('product/unfeature', { id:id },
            function(data, status) {
                if (data.error != '')
                {
                    alert(data.error);
                }
                else
                {
                    $('#product_' + id).remove();
                }
            }, 'json');
    }
</script>