<div class="crumb">
    <ul>
        <li><a href="theme/list">themes</a></li>
    </ul>
</div>

<div class="theme">
    <?php foreach ($theme as $t) : ?>
        <div class="item clear" id="theme_<?php echo htmlspecialchars($t); ?>">
            <span class="name"><?php echo htmlspecialchars($t); ?></span>
            <span class="load"><a href="javascript:load_theme('<?php echo htmlspecialchars($t); ?>');"">Load</a>&nbsp;&nbsp;&nbsp;<a href="javascript:delete_theme('<?php echo htmlspecialchars($t); ?>');">Delete</a></span>
        </div>
    <?php endforeach; ?>
</div>


<script type="text/javascript">
    function load_theme(name)
    {
        if (confirm('Are you sure?'))
        {
            $.post('theme/load', { name:name },
                function(data, status) {
                    if (data.error != '')
                    {
                        alert(data.error);
                    }
                    else
                    {
                        window.location = '<?php echo $request->base(); ?>theme';
                    }
                }, 'json');
        }
    }
    
    function delete_theme(name)
    {
        if (confirm('Are you sure?'))
        {
            $.post('theme/delete', { name:name },
                function(data, status) {
                    if (data.error != '')
                    {
                        alert(data.error);
                    }
                    else
                    {
                        $('#theme_' + name).remove();
                        $('.theme .item:odd').css('background-color', '#f2f2f2').css('border', '1px dotted #e4e4e8');
                        $('.theme .item:even').css('background-color', '#ffffff').css('border', '0px');
                    }
                }, 'json');
        }
    }
    
    $(document).ready(function() {
        $('.theme .item:odd').css('background-color', '#f2f2f2').css('border', '1px dotted #e4e4e8');
    });
</script>
