<?php
/**
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 *
 * @category   BL
 * @package    BL_CustomGrid
 * @copyright  Copyright (c) 2012 Benoît Leulliette <benoit.leulliette@gmail.com>
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
?>
<div class="content-header">
    <h3 class="icon-head head-products"><?php echo $this->getHeader() ?></h3>
    <p class="content-buttons form-buttons">
        <?php echo $this->getBackButtonHtml() ?>
        <?php echo $this->getCancelButtonHtml() ?>
        <?php echo $this->getDeleteButtonHtml() ?>
        <?php echo $this->getSaveButtonHtml() ?>
        <?php echo $this->getSaveAndEditButtonHtml() ?>
    </p>
</div>
<form action="<?php echo $this->getSaveUrl() ?>" method="post" id="custom_grid_edit_form" enctype="multipart/form-data">
    <?php echo $this->getBlockHtml('formkey')?>
    <div>
        <input type="hidden" value="<?php echo $this->getCustomGridId() ?>" name="grid_id" />
        <input type="hidden" value="<?php echo $this->getRefererInputValue() ?>" name="<?php echo $this->getRefererInputName() ?>" id="blcg_grid_edit_form_referer_input" />
    </div>
    <div style="display: none;"></div>
</form>
<script type="text/javascript">
//<![CDATA[
    var customGridTemplateSyntax = /(^|.|\r|\n)({{(\w+)}})/;
    var customGridForm = new varienForm('custom_grid_edit_form');
    
    function saveAndContinueEdit(urlTemplate)
    {
        var template = new Template(urlTemplate, customGridTemplateSyntax);
        var url = template.evaluate({tab_id: custom_grid_info_tabsJsTabs.activeTab.id});
        $('blcg_grid_edit_form_referer_input').remove();
        customGridForm.submit(url);
    }
    
    function setSettings(urlTemplate, typeElement)
    {
        var template = new Template(urlTemplate, customGridTemplateSyntax);
        setLocation(template.evaluate({type: $F(typeElement)}));
    }
    
    Event.observe(window, 'load', function(){
        var objName = '<?php echo $this->getSelectedTabId() ?>';
        if (objName) {
            obj = $(objName);
            custom_grid_info_tabsJsTabs.setSkipDisplayFirstTab();
            custom_grid_info_tabsJsTabs.showTabContent(obj);
        }
    });
//]]>
</script>