<?php $option_value = $this->getOptionValue(); ?>
<?php $source_code = $option_value->getObject(); ?>
<div class="edit_page source_code">
    <div class="form_content">
        <div id="edit">
            <h4 class="subtitle">
                <span class="left area"><?php echo $this->_('Source Code'); ?></span>
                <hr class="area reverse">
                <div class="clear"></div>
            </h4>
            <div class="block">
                <form id="sourcecodeCreateForm" action="<?php echo $this->getUrl('sourcecode/application/editpost') ?>" method="post">
                    <div class="buttons">
                        <button type="button" onclick="page.reload()" class="delete left"><i class="icon-arrow-left"></i></button>
                        <button type="submit" class="default_button right">OK</button>
                        <div class="clear"></div>
                    </div>
                    <div>
                        <label for="html_source_code_<?php echo $option_value->getId(); ?>"><?php echo $this->_('Insert your HTML code:'); ?></label>
                        <textarea id="html_source_code_<?php echo $option_value->getId(); ?>" class="html_source_code" name="html_code"><?php echo $source_code->getHtmlCode(); ?></textarea>
                    </div>
                    <input type="hidden" name="option_value_id" value="<?php echo $option_value->getId(); ?>" />
                </form>
            </div>
        </div>

        <script type="text/javascript">

                page.setCallback('didappear', function() {
                    $('#sourcecodeCreateForm').submit(function() {
                        reload(this, this.action, true, function(data) {
                            if(data.success) {
                                page.reload();
                            }
                        });
                        return false;
                    });
                });

                page.setCallback('willdisappear', function() {
                    $('#sourcecodeCreateForm').unbind('submit');
                });

        </script>
        <style>
            .source_code .html_source_code { width: 600px; height: 300px; }
        </style>
    </div>
    <div class="clear"></div>
</div>
