<?xml version="1.0" encoding="UTF-8"?>
<modification>
	<id>Additional Product Tabs</id>
	<version>1.0.3</version>
	<vqmver>2.2.1</vqmver>
	<author>Godfrey Livinstone</author>
	<decription><![CDATA[
		/*
			This file is part of the "Extra Product Tabs Opencart Extension"

			The "Extra Product Tabs Opencart Extension" is free software: you can redistribute it and/or modify it under
			the terms of the GNU General Public License as published by the Free Software
			Foundation, either version 3 of the License, or (at your option) any later version.

			The Extra Product Tabs Opencart Extension is distributed in the hope that it will be useful,
			but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
			FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.

			---------------------------------------------------------------------
			Name:		Extra Product Tabs Opencart Extension
			
			Version: 1.0.4

			OpenCart:	Version 1.5.4.1, 1.5.5.1

			Author: 	rebdog (Godfrey Livinsgtone godfrey@satelliteshop.co.nz)

			Copyright 2012, 2013

		*/
		]]>
	</decription>

	<file name="admin/view/template/common/header.tpl" error="log">
		<operation error="log">
			<search position="after"><![CDATA[
				<li><a href="<?php echo $information; ?>"><?php echo $text_information; ?></a></li>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<li><a href="<?php echo $product_tab; ?>"><?php echo $text_product_tab; ?></a></li>
				]]>
			</add>
		</operation>
	</file>

	<file name="admin/controller/common/header.php" error="log">
		<operation error="log">
			<search position="after"><![CDATA[
				$this->data['text_information'] = $this->language->get('text_information');
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->data['text_product_tab'] = $this->language->get('text_product_tab');
				]]>
			</add>
		</operation>
		<operation error="log">
			<search position="after"><![CDATA[
				$this->data['information'] = $this->url->link('catalog/information', 'token=' . $this->session->data['token'], 'SSL');
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->data['product_tab'] = $this->url->link('catalog/tab', 'token=' . $this->session->data['token'], 'SSL');
				]]>
			</add>
		</operation>
	</file>

 	<!-- If you do not have the english language installed change the line below to -->
	<!-- <file name="admin/language/english/english.php" error="skip"> -->
  <file name="admin/language/english/english.php" error="log">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']					= 'Extra Tabs';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Add Product Tab';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- Chinese (Taiwanese Mandarin) -->
  <file name="admin/language/zh-TW/zh-TW.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']					= '額外索引標籤';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = '加入商品索引標籤';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- Czech -->
	<file name="admin/language/czech/czech.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']         = 'Extra záložka';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Přidat záložku produktu';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- Dutch -->
	<file name="admin/language/dutch/dutch.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']         =  'Extra Tabs';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Voeg Product Tab toe';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- German -->
	<file name="admin/language/de_DE/de_DE.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']         = 'Zusätzliche Reiter';
				]]>
			</add>
			</operation>

			<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Zusatzreiter einfügen';
				]]>
			</add>
		</operation>

	</file>

	<!-- Greek -->
 	<file name="admin/language/greek/greek.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']					=   'Επιπλέον Καρτέλες';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  =  'Προσθήκη Καρτέλας Προϊόντος';
				]]>
			</add>
		</operation>

	</file>
  
	<!-- Russian-->
	<file name="admin/language/russian/russian.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']         =  'Вкладка';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Добавить вкладку';
				]]>
			</add>
		</operation>

	</file>

	<!-- Swedish -->
	<file name="admin/language/swedish/swedish.php" error="skip">

		<operation error="log">
			<search position="after"><![CDATA[
				$_['tab_attribute']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['tab_product_tab']         =  'Extraflikar';
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$_['button_add_option']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['button_add_product_tab']  = 'Lägg till produktflik';
				]]>
			</add>
		</operation>

	</file>
	
  <!-- If you do not have the english language installed change the line below to -->
	<!-- <file name="admin/language/english/common/header.php" error="skip"> -->
	<file name="admin/language/english/common/header.php" error="log">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Extra Product Tabs';
				]]>
			</add>
		</operation>

	</file>

	<!-- Chinese (Taiwanese Mandarin) -->
	<file name="admin/language/zh-TW/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = '額外索引標籤';
				]]>
			</add>
		</operation>

	</file>	
	
	<!-- Czech -->
  <file name="admin/language/czech/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Extra záložky produktu';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- Dutch -->
  <file name="admin/language/dutch/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Extra Product Tabs';
				]]>
			</add>
		</operation>

	</file>
	
	<!-- German -->
	<file name="admin/language/de_DE/common/header.php" error="skip">
		<operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Zusätzliche Produktreiter';
				]]>
			</add>
		</operation>

	</file>

	<!-- Greek -->
  <file name="admin/language/greek/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 =  'Επιπλέον Καρτέλες Προϊόντων';
				]]>
			</add>
		</operation>

	</file>

	<!-- Russian -->
	<file name="admin/language/russian/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Доп. вкладки';
				]]>
			</add>
		</operation>

	</file>

	<!-- Swedish -->
  <file name="admin/language/swedish/common/header.php" error="skip">
		
    <operation error="log">
			<search position="after"><![CDATA[
				$_['text_information']
				]]>
			</search>
			<add trim="true"><![CDATA[
				$_['text_product_tab']          			 = 'Extra produktflikar';
				]]>
			</add>
		</operation>

	</file>
		
	<file name="admin/model/localisation/language.php" error="log">

		<!-- Add Extra Tabs to addLanguage function -->
		<operation error="log">
			<search position="after" offset="2"><![CDATA[
				$this->db->query("INSERT INTO " . DB_PREFIX . "product_attribute SET product_id = '" . (int)$product_attribute['product_id'] . "', attribute_id = '" . (int)$product_attribute['attribute_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_attribute['text']) . "'");
				]]>
			</search>
			<add trim="true"><![CDATA[
				// Product Tabs
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_tab WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");

				foreach ($query->rows as $product_tab) {
					$this->db->query("INSERT INTO " . DB_PREFIX . "product_tab SET product_id = '" . (int)$product_tab['product_id'] . "', tab_id = '" . (int)$product_tab['tab_id'] . "', language_id = '" . (int)$language_id . "', text = '" . $this->db->escape($product_tab['text']) . "'");
				}
				]]>
			</add>
		</operation>
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				// Voucher Theme
				]]>
			</search>
			<add trim="true"><![CDATA[
				// Tabs
				$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "tab_description WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");

				foreach ($query->rows as $tab) {
					$this->db->query("INSERT INTO " . DB_PREFIX . "tab_description SET tab_id = '" . (int)$tab['tab_id'] . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($tab['name']) . "'");
				}
				]]>
			</add>
		</operation>

		<!-- Add Extra Tabs to deleteLanguage function -->
		<operation error="log">
			<search position="after"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_description WHERE language_id = '" . (int)$language_id . "'");
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_tab WHERE language_id = '" . (int)$language_id . "'");
				]]>
			</add>
		</operation>
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "voucher_theme_description WHERE language_id = '" . (int)$language_id . "'");
				]]>
			</search>
			<add trim="true"><![CDATA[

				$this->db->query("DELETE FROM " . DB_PREFIX . "tab_description WHERE language_id = '" . (int)$language_id . "'");
				]]>
			</add>
		</operation>

	</file>

	<file name="admin/controller/catalog/product.php" error="log">

		<operation error="log">
			<search position="after"><![CDATA[
				$this->data['tab_attribute'] = $this->language->get('tab_attribute');
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->data['tab_product_tab'] = $this->language->get('tab_product_tab');
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$this->data['button_add_option'] = $this->language->get('button_add_option');
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->data['button_add_product_tab'] = $this->language->get('button_add_product_tab');
				]]>
			</add>
		</operation>

		<!-- Add Extra Tabs to getForm function -->
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				$this->load->model('catalog/option');
				]]>
			</search>
			<add><![CDATA[
				if (isset($this->request->post['product_tab'])) {
					$this->data['product_tabs'] = $this->request->post['product_tab'];
				} elseif (isset($this->request->get['product_id'])) {
					$this->data['product_tabs'] = $this->model_catalog_product->getProductTabs($this->request->get['product_id']);
				} else {
					$this->data['product_tabs'] = array();
				}
				
				]]>
			</add>
		</operation>

	</file>

	<file name="admin/model/catalog/product.php" error="log">

		<!-- Add Extra Tabs to addProduct function -->
		<operation error="log">
			<search position="before" index="1"><![CDATA[
				if (isset($data['product_option'])) {
				]]>
			</search>
			<add trim="true"><![CDATA[
				if (isset($data['product_tab'])) {
					foreach ($data['product_tab'] as $product_tab) {
						if ($product_tab['tab_id']) {
							$this->db->query("DELETE FROM " . DB_PREFIX . "product_tab WHERE product_id = '" . (int)$product_id . "' AND tab_id = '" . (int)$product_tab['tab_id'] . "'");

							foreach ($product_tab['product_tab_description'] as $language_id => $product_tab_description) {
								$this->db->query("INSERT INTO " . DB_PREFIX . "product_tab SET product_id = '" . (int)$product_id . "', tab_id = '" . (int)$product_tab['tab_id'] . "', language_id = '" . (int)$language_id . "', text = '" .  $this->db->escape($product_tab_description['text']) . "'");
							}
						}
					}
				}
				]]>
			</add>
		</operation>

		<!-- Add Extra Tabs to editProduct function -->
    <operation error="log">
			<search position="before" index="1"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_option WHERE product_id = '" . (int)$product_id . "'");
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_tab WHERE product_id = '" . (int)$product_id . "'");

				if (!empty($data['product_tab'])) {
					foreach ($data['product_tab'] as $product_tab) {
						if ($product_tab['tab_id']) {
							$this->db->query("DELETE FROM " . DB_PREFIX . "product_tab WHERE product_id = '" . (int)$product_id . "' AND tab_id = '" . (int)$product_tab['tab_id'] . "'");

							foreach ($product_tab['product_tab_description'] as $language_id => $product_tab_description) {
								$this->db->query("INSERT INTO " . DB_PREFIX . "product_tab SET product_id = '" . (int)$product_id . "', tab_id = '" . (int)$product_tab['tab_id'] . "', language_id = '" . (int)$language_id . "', text = '" .  $this->db->escape($product_tab_description['text']) . "'");
							}
						}
					}
				}
				]]>
			</add>
		</operation>

		<!-- Add Extra Tabs to copyProduct Function -->
    <operation error="log">
			<search position="after"><![CDATA[
				$data = array_merge($data, array('product_attribute' => $this->getProductAttributes($product_id)));
				]]>
			</search>
			<add trim="true"><![CDATA[
				$data = array_merge($data, array('product_tab' => $this->getProductTabs($product_id)));
				]]>
			</add>
		</operation>

		<!-- Add Delete Extra Tab Data to deleteProduct function -->
    <operation error="log">
			<search position="after" offset="1"><![CDATA[
				public function deleteProduct($product_id) {
				]]>
			</search>
			<add trim="true"><![CDATA[
				$this->db->query("DELETE FROM " . DB_PREFIX . "product_tab WHERE product_id = '" . (int)$product_id . "'");
				]]>
			</add>
		</operation>

		<!-- Add Function getProductTabs to get Tab Data -->
		<operation error="log">
			<search position="before"><![CDATA[
				public function getTotalProductsByLayoutId($layout_id) {
				]]>
			</search>
			<add trim="true"><![CDATA[

				public function getProductTabs($product_id) {

					$product_tab_data = array();

					$product_tab_query = $this->db->query("SELECT t.tab_id, td.name FROM " . DB_PREFIX . "product_tab pt LEFT JOIN " . DB_PREFIX . "tab t ON (pt.tab_id = t.tab_id) LEFT JOIN " . DB_PREFIX . "tab_description td ON (t.tab_id = td.tab_id) WHERE pt.product_id = '" . (int)$product_id . "' AND td.language_id = '" . (int)$this->config->get('config_language_id') . "' GROUP BY pt.tab_id");

					foreach ($product_tab_query->rows as $product_tab) {

						$product_tab_description_data = array();

						$product_tab_description_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "product_tab WHERE product_id = '" . (int)$product_id . "' AND tab_id = '" . (int)$product_tab['tab_id'] . "'");

						foreach ($product_tab_description_query->rows as $product_tab_description) {
							$product_tab_description_data[$product_tab_description['language_id']] = array('text' => $product_tab_description['text']);
						}

						$product_tab_data[] = array(
							'tab_id' 									=> $product_tab['tab_id'],
							'name'         						=> $product_tab['name'],
							'product_tab_description' => $product_tab_description_data
						);

					}
					return $product_tab_data;
				}

        ]]>
			</add>
    </operation>

		<!-- Add Function getTotalProductsByExtraTabId -->
		<operation error="log">
			<search position="before"><![CDATA[
				public function getTotalProductsByOptionId($option_id) {
				]]>
			</search>
			<add trim="true"><![CDATA[
				public function getTotalProductsByTabId($tab_id) {
					$query = $this->db->query("SELECT COUNT(DISTINCT product_id) AS total FROM " . DB_PREFIX . "product_tab WHERE tab_id = '" . (int)$tab_id . "'");

					return $query->row['total'];
				}
				]]>
			</add>
		</operation>

	</file>

	<file name="admin/view/template/catalog/product_form.tpl" error="log">

		<!-- Add a 'Row' just in case we end up with two rows of tabs, this make it display better -->
		<operation error="log">
			<search position="before"><![CDATA[
				<form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
				]]>
			</search>
			<add trim="true"><![CDATA[
				<br /><br />
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="replace"><![CDATA[
				<a href="#tab-design"><?php echo $tab_design; ?></a>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<a href="#tab-design"><?php echo $tab_design; ?></a>
				<a href="#tab-product_tab"><?php echo $tab_product_tab; ?></a>
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="before"><![CDATA[
				<div id="tab-reward">
				]]>
			</search>
      <add trim="true"><![CDATA[
				<div id="tab-product_tab">
          <div id="vtab-product_tab" class="vtabs">
            <?php $product_tab_row = 0; ?>
            <?php foreach ($product_tabs as $product_tab) { ?>
            <a href="#tab-product_tab-<?php echo $product_tab_row; ?>" id="product_tab-<?php echo $product_tab_row; ?>"><?php echo $product_tab['name']; ?>&nbsp; <img src="view/image/delete.png" alt="" onclick="$('#tab-product_tab-<?php echo $product_tab_row; ?>').remove(); $('#product_tab-<?php echo $product_tab_row; ?>').remove(); $('#vtab-product_tab a:first').trigger('click'); return false;" /></a>
            <?php $product_tab_row++; ?>
            <?php } ?>
            <span id="product_tab-add">
            <input name="producttab" value="" style="width: 130px;" />
            &nbsp;<img src="view/image/add.png" alt="<?php echo $button_add_product_tab; ?>" title="<?php echo $button_add_product_tab; ?>" /></span>
					</div>
          <?php $product_tab_row = 0; ?>
          <?php foreach ($product_tabs as $product_tab) { ?>
          <div id="tab-product_tab-<?php echo $product_tab_row; ?>" class="vtabs-content">
            <input type="hidden" name="product_tab[<?php echo $product_tab_row; ?>][name]" value="<?php echo $product_tab['name']; ?>" />
            <input type="hidden" name="product_tab[<?php echo $product_tab_row; ?>][tab_id]" value="<?php echo $product_tab['tab_id']; ?>" />
            <table class="form">
              <tr>
                <td>
								  <div id="product_tab-<?php echo $product_tab_row; ?>-languages" class="htabs">
										<?php foreach ($languages as $language) { ?>
											<a href="#product_tab-<?php echo $product_tab_row; ?>-languages-<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>
										<?php } ?>
									</div>
									<?php foreach ($languages as $language) { ?>
										<div id="product_tab-<?php echo $product_tab_row; ?>-languages-<?php echo $language['language_id']; ?>">
											<textarea name="product_tab[<?php echo $product_tab_row; ?>][product_tab_description][<?php echo $language['language_id']; ?>][text]" cols="40" rows="5"><?php echo isset($product_tab['product_tab_description'][$language['language_id']]) ? $product_tab['product_tab_description'][$language['language_id']]['text'] : ''; ?></textarea>
										</div>
									<?php } ?>
								</td>
              </tr>
            </table>
          </div>
          <?php $product_tab_row++; ?>
          <?php } ?>
        </div>
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				$('#languages a').tabs();
				]]>
			</search>
			<add trim="true"><![CDATA[
				$('#vtab-product_tab a').tabs();
				<?php for( $i=0; $i < $product_tab_row; $i++ ) { ?>
					$('#product_tab-<?php echo $i; ?>-languages a').tabs();
				<?php } ?>
				]]>
			</add>
		</operation>

		<operation error="log">
			<search position="after"><![CDATA[
				<script type="text/javascript" src="view/javascript/ckeditor/ckeditor.js"></script>
				]]>
			</search>
			<add trim="true"><![CDATA[
				<script type="text/javascript"><!--
				<?php for($i=0; $i < $product_tab_row; $i++) { ?>
				<?php foreach ($languages as $language) { ?>
					CKEDITOR.replace('product_tab[<?php echo $i; ?>][product_tab_description][<?php echo $language['language_id']; ?>][text]',  {
						filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
						filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
						filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
						filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
						filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
						filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
					});
				<?php } ?>
				<?php } ?>
				//--></script>
				]]>
			</add>
		</operation>

		<!-- Add Function So Can Insert a New Tab -->
		<operation error="log">
			<search position="before" offset="1"><![CDATA[
				var option_row = <?php echo $option_row; ?>;
				]]>
			</search>
			<add trim="true"><![CDATA[
				<script type="text/javascript"><!--
				var product_tab_row = <?php echo $product_tab_row; ?>;

				$('input[name=\'producttab\']').autocomplete({
					delay: 500,
					source: function(request, response) {
						$.ajax({
							url: 'index.php?route=catalog/tab/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request.term),
							dataType: 'json',
							success: function(json) {
								response($.map(json, function(item) {
									return {
										label: item.name,
										value: item.tab_id
									}
								}));
							}
						});
					},
					select: function(event, ui) {
						html  = '<div id="tab-product_tab-' + product_tab_row + '" class="vtabs-content">';
						html += '	<input type="hidden" name="product_tab[' + product_tab_row + '][name]" value="' + ui.item.label + '" />';
						html += '	<input type="hidden" name="product_tab[' + product_tab_row + '][tab_id]" value="' + ui.item.value + '" />';
						html += '	<table class="form">';
						html += '	  <tr>';
						html += '		<td>';
						html += '	<div id="product_tab-' + product_tab_row + '-languages" class="htabs">';
						<?php foreach ($languages as $language) { ?>
							html += '	<a href="#product_tab-' + product_tab_row + '-languages-<?php echo $language['language_id']; ?>"><img src="view/image/flags/<?php echo $language['image']; ?>" title="<?php echo $language['name']; ?>" /> <?php echo $language['name']; ?></a>';
						<?php } ?>
						html += '	</div>';
						<?php foreach ($languages as $language) { ?>
						html += '	<div id="product_tab-' + product_tab_row + '-languages-<?php echo $language['language_id']; ?>">';
						html += '<textarea name="product_tab[' + product_tab_row + '][product_tab_description][<?php echo $language['language_id']; ?>][text]" cols="40" rows="5"></textarea>';
						html += '	</div>';
						<?php } ?>
						html += '	</td>';
						html += ' </tr>';
						html += ' </table>';
						html += '</div>';

						$('#tab-product_tab').append(html);

						$('#product_tab-add').before('<a href="#tab-product_tab-' + product_tab_row + '" id="product_tab-' + product_tab_row + '">' + ui.item.label + '&nbsp; <img src="view/image/delete.png" alt="" onclick="$(\'#tab-product_tab-' + product_tab_row + '\').remove(); $(\'#product_tab-' + product_tab_row + '\').remove(); $(\'#vtab-product_tab a:first\').trigger(\'click\'); return false;" /></a>');

						$('#vtab-product_tab a').tabs();

						$('#product_tab-' + product_tab_row + '-languages a').tabs();

						<?php foreach ($languages as $language) { ?>
						CKEDITOR.replace('product_tab[' + product_tab_row + '][product_tab_description][<?php echo $language['language_id']; ?>][text]',  {
							filebrowserBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
							filebrowserImageBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
							filebrowserFlashBrowseUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
							filebrowserUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
							filebrowserImageUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>',
							filebrowserFlashUploadUrl: 'index.php?route=common/filemanager&token=<?php echo $token; ?>'
						});
						<?php } ?>

						$('#product_tab-' + product_tab_row).trigger('click');

						product_tab_row++;

						$(this).val('');

						return false;
					},
					focus: function(event, ui) {
							return false;
					}
				});

				//--></script>
				]]>
			</add>
		</operation>

	</file>

</modification>