<?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">
        <div>
            <?php echo $form->render(array('method' => 'post', 'id' => 'product_form')); ?>
        </div>
        <div>
            <span class="loading"></span>
            <p>Main image:</p>
            <input id="file" name="file" type="file" />
            <button onclick="return ajaxFileUpload();">Upload</button><br />
            <span id="product_image"><?php if (isset($image)) : ?><img src="<?php echo htmlspecialchars(product::DIRECTORY . $image . '-s.jpg'); ?>" /><?php endif; ?></span><br />
            <?php if ($type == 'Edit') : ?>
                <p>Extra images:</p>
                <input id="file_extra" name="file" type="file" />
                <button onclick="return ajaxFileUploadExtra();">Upload</button><br />
                <span id="product_image_extra">
                    <?php foreach ($image_extra as $i) : ?>
                        <p id="image_<?php echo htmlspecialchars($i['id']); ?>"><img src="<?php echo htmlspecialchars(product::DIRECTORY . $i['image'] . '-s.jpg?' . time()); ?>" /><a href="javascript:delete_image_extra(<?php echo htmlspecialchars($i['id']); ?>);">Delete</a></p>
                    <?php endforeach; ?>
                </span><br />
            <?php endif; ?>
        </div>
    </div>
</div>

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

<script type="text/javascript" src="admin/widget/ckeditor/ckeditor.js"></script>
<script src="admin/widget/ckeditor/_samples/sample.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[

        // This call can be placed at any point after the
        // <textarea>, or inside a <head><script> in a
        // window.onload event handler.

        // Replace the <textarea id="editor"> with an CKEditor
        // instance, using default configurations.
        CKEDITOR.replace( 'editor1' );
        CKEDITOR.replace( 'editor2' );

//]]>
</script>