<?php $option_value = $this->getOptionValue(); ?>
<?php $application = $this->getSession()->getApplication(); ?>
<?php $radio = $option_value->getObject(); ?>
<div class="form_content">
    <div id="list" class="edit_page radios">
        <div class="section form_content">
            <form id="radioForm" name="radioForm" method="post" action="<?php echo $this->getUrl('radio/application/editpost') ?>">
                <h4 class="subtitle">
                    <span class="left area"><?php echo $this->_('Information') ?></span>
                    <hr class="area reverse">
                    <div class="clear"></div>
                </h4>
                <input type="hidden" name="value_id" value="<?php echo $option_value->getId(); ?>" />
                <div class="form_content">
                    <div class="infos">
                        <div id="radio_content">
                            <table class="no-collapse" cellspacing="10">
                                <tr>
                                    <td class="label"><label for="title_radio"><?php echo $this->_('Title') ?></label></td>
                                    <td><input type="text" id="title_radio" name="title" class="input required" value="<?php echo $radio->getTitle() ?>"/></td>
                                </tr>
                                <tr>
                                    <td class="label"><label for="link_radio"><?php echo $this->_('Link') ?></label></td>
                                    <td><input type="text" id="link_radio" name="link" class="input required url" value="<?php echo $radio->getLink() ?>"/></td>
                                </tr>
                            </table>
                        </div>
                    </div>
                    <div class="save right">
                        <button class="default_button btn-block" type="submit">
                            <?php echo $this->_('Save'); ?>
                        </button>
                    </div>
                    <div class="clear"></div>
                </div>
            </form>
        </div>
        <div class="section">
            <?php
                echo $this->getLayout()
                    ->addPartial('background_image', 'Core_View_Default', 'application/customization/features/edit/background_image.phtml')
                    ->setValueId($option_value->getId())
                    ->toHtml()
                ;
            ?>
        </div>
    </div>
</div>
<script type="text/javascript">

    page.setCallback('didappear', function() {

        $('#link_radio').change(function() {
            if(!$(this).val().isEmpty() && !$(this).val().startsWith('http://') && !$(this).val().startsWith('https://')) {
                $(this).val('http://'+$(this).val());
            }
        });
        $('#radioForm').submit(function() {
            if(!$(this).valid()) return false;
            reload(this, this.action, true, function(datas) {
                if(datas.success) {

                }
            });
            return false;
        });

    });

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

</script>