<?php
    // Josh edit: Check to see what section we're on
    $name = false;

    if(isset( $section )){
        $name = $section['name'];
    }

    if(isset( $page )){
        $name = $page['name'];
    }
?>
<div class="panel">
    <div class="title">
        Edit Meta
        <?php if($name){ echo "<span class='meta-title'>Editing: $name</span>"; } ?>
    </div>
    <div class="content clear">
        <div class="meta-form">
            <?php echo $form->render(array('method' => 'post', 'id' => 'meta_edit_form')); ?>
        </div>
        <div>
        </div>
    </div>
</div>

<?php /* Quick and dirty javascript include. Cant find the place that handles
the javascript files. This is a visual character counter for the meta fields. */ ?>
<script type="text/javascript" src="core/widget/jquery/char_counter.js"></script>
<script type="text/javascript">
    
    $(document).ready(function() {
        
        // cache element
        var meta_form = $('.meta-form');

        // List out all the fields we need and their character limit
        var input_list = [
            {'name':'title',        'limit':64},
            {'name':'description',  'limit':160},
            {'name':'keywords',     'limit':250},
        ];

        // default settings for the character limit plugin
        default_settings = {
            'maxChars': 100,
            'maxCharsWarning': 90,
            'msgFontSize': '12px',
            'msgFontColor': '#000',
            'msgFontFamily': 'Arial',
            'msgTextAlign': 'left',
            'msgWarningColor': '#F00',
            'msgAppendMethod': 'insertAfter'              
        };

        // Attach each character display to each input
        $.each(input_list, function(k, field){

            // Set character limit and warning value
            default_settings.maxChars = field.limit;
            default_settings.maxCharsWarning = field.limit - 10;

            // Find actual field and attach plugin.
            // The field must be "display:block" for this to not look funny.
            meta_form.find('input[name='+ field.name +']')
            .css('display', 'block')
            .jqEasyCounter(default_settings);
        });

    });

</script>