<?php $url = str_replace('admin.', '', $request->base()); ?>

<div class="panel">
    <div class="title">
        <?php echo htmlspecialchars($type); ?> Product <?php if ($type == 'Edit') : ?> - <a target="_blank" href="<?php echo htmlspecialchars($url); ?>product/view/<?php echo htmlspecialchars(category::get_path($form->category_id) . $form->path); ?>">View</a><?php endif; ?>
    </div>
    <div class="content clear">
        <?php echo $form->render(array('method' => 'post', 'id' => 'product_form')); ?>
    </div>
</div>

<div id="elfinder"></div>

<div>
    <a href="category/index/<?php echo htmlspecialchars($form->category_id); ?>">Cancel</a>
</div>

<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/smoothness/jquery-ui.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" media="screen" href="admin/widget/elfinder/css/elfinder.min.css">
<link rel="stylesheet" type="text/css" media="screen" href="admin/widget/elfinder/css/theme.css">
<script src="admin/widget/elfinder/js/elfinder.min.js"></script>
<script src="admin/widget/wysiwyg/jquery.rte.js"></script>
<script src="admin/widget/wysiwyg/jquery.rte.tb.js"></script>
<script src="admin/widget/wysiwyg/jquery.ocupload-1.1.4.js"></script>
<script src="admin/widget/ckeditor/ckeditor.js"></script>
<script src="admin/widget/ckeditor/_samples/sample.js"></script>
<script src="core/widget/jquery/autogrow.js"></script>
<script>
    $(document).ready(function() {
        var elf = $('#elfinder').elfinder({
            url: 'admin/widget/elfinder/php/connector.php',
            customData: {
                directory: '<?php echo htmlspecialchars($directory); ?>'
            },
            onlyMimes: ['image/png', 'image/jpeg', 'image/gif']
        }).elfinder('instance');
        
        CKEDITOR.replace('editor1');
        CKEDITOR.replace('editor2');
        
        $('#product_form input[name="name"]').bind('keyup', function() {
            $('#product_form input[name="path"]').val($(this).val().replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]/g, '-').toLowerCase());
        });
        
        $('#product_form  textarea[name="feature"]').autogrow();
    });
</script>
