<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<script type="text/javascript">
//<![CDATA[
    /**
     * Post form data and process response via AJAX.
     *
     * @return void
     */
    varienForm.prototype.getFilter = function()
    {
        if ($('entity') && $F('entity')) {
            var url = "<?php echo $this->getUrl('*/*/getFilter') ?>";
            url += ((url.slice(-1) != '/') ? '/' : '') + 'entity/' + $F('entity');

            new Ajax.Request(url, {
                method:      'post',
                //parameters:  $(this.formId).serialize(),
                evalScripts: true,
                onComplete:  function(transport) {
                    var responseText = transport.responseText.replace(/>\s+</g, '><');
                    $('export_filter_grid_container').update(responseText);
                    $('export_filter_container').show();
                }
            });
        } else {
            $('export_filter_container').hide();
        }
    };

    /**
     * Continue export process after filter settings.
     *
     * return void
     */
    function getFile()
    {
        if ($('entity') && $('file_format')) {
            var form      = $('export_filter_form');
            var oldAction = form.action;
            form.action   = oldAction + ((oldAction.slice(-1) != '/') ? '/' : '') + 'entity/' + $F('entity') + '/file_format/' + $F('file_format');
            form.submit();
            form.action   = oldAction;
        } else {
            alert('Invalid data');
        }
    }
//]]>
</script>
