<?php
/**
 * 2007-2015 PrestaShop
 *
 * NOTICE OF LICENSE
 *
 * No redistribute in other sites, or copy.
 *
 * @author    RSI <rsi@rsi>
 * @copyright 2007-2015 RSI
 * @license   http://localhost
 */

if (class_exists('CountdownSpecials') != true)
{
	class CountdownSpecials extends Module
	{
		private $_html = '';
		private $_postErrors = array();
		public $producPropertiesCache = array();
		public $_taxCalculationMethod = PS_TAX_EXC;

		public function __construct()
		{
			$this->name = 'countdownspecials';
			if (_PS_VERSION_ < '1.4.0.0')
				$this->tab = 'Home';
			if (_PS_VERSION_ > '1.4.0.0')
			{
				$this->tab           = 'pricing_promotion';
				$this->author        = 'RSI';
				$this->need_instance = 1;
			}
			$this->version    = '4.1.1';
			$this->module_key = 'c5470490142d139dd24e87c0cb52051b';
			parent::__construct();
			$this->displayName = $this->l('Countdown Specials - Flash sales');
			$this->description = $this->l('Displays specials Products in your site with timer');
			if (_PS_VERSION_ < '1.5')
				require(_PS_MODULE_DIR_.$this->name.'/backward_compatibility/backward.php');
			if (_PS_VERSION_ > '1.6')
				$this->bootstrap = true;
		}

		public function install()
		{
			if (_PS_VERSION_ > '1.6.0.0' && _PS_VERSION_ < '1.6.1.0')

				Tools::copy('../modules/countdownspecials/form.txt', 'themes/default/template/helpers/form/form.tpl');

			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR', 8)
				|| !parent::install() || !$this->registerHook('home')
				|| !$this->registerHook('shoppingCart')
				|| !$this->registerHook('leftcolumn')
				|| !$this->registerHook('header')
				|| !$this->registerHook('extraright')
				|| !$this->registerHook('top')
				|| !$this->registerHook('footer'))
				return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR', 8)
				|| !parent::install()
				|| !$this->registerHook('home')
				|| !$this->registerHook('shoppingCart')
				|| !$this->registerHook('rightcolumn')
				|| !$this->registerHook('header')
				|| !$this->registerHook('extraright')
				|| !$this->registerHook('top')
				|| !$this->registerHook('displayBanner')
				|| !$this->registerHook('footer')
				|| !$this->registerHook('displayHomeTab')
				|| !$this->registerHook('displayTopColumn')
				|| !$this->registerHook('displayHomeTabContent'))
				return false;
			}

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH', '100%'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH2', '970'))
				return false;
				if (_PS_VERSION_ < '1.5.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_RESPO', '0'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_RESPO', '1'))
					return false;
			}
			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', '540px'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', '980'))
					return false;
			}
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3H', '379'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_HOME6', (_PS_VERSION_ > '1.6.0.0' ? 'Tab' : 'Home')))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_PUSH', '1'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WT', '300'))
				return false;
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_CRONT', '1'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WTB', '200'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_WTH', '180'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_SALES', '1'))
				return false;
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_CATW', '400'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'cccccc'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR2', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'000000'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_BS', '1px -2px 28px 9px rgba(39, 0, 0, 0.5)'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_PBS', '-1px 0px 6px 2px rgba(20, 0, 0, 0.5)'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHT', '340'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_HP', 'yes'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_PADDING', '3'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_STYLETIME', '1'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_BUT', '1'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR2', '5'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBR3', '2'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLOR', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'ffffff'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_CF', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'eeeeee'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORBG', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'ffffff'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLOR2', 'yes'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_MARGIN', '2'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_BORDERSL', '1px solid #000'))
				return false;

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_SORT', 'ASC'))
				return false;

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_ALIGN', '1px solid #000'))
				return false;

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_FS', '14'))
				return false;
			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', '980'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', '1169'))
					return false;
			}

			if (_PS_VERSION_ < '1.5.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', '250'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', '298'))
					return false;
			}
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_DELAYCS', 5000))
				return false;
			$imgtyp = CountdownSpecials::getImages('products');
			$imagid = CountdownSpecials::getImagesID($imgtyp[0]['id_image_type']);
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', $imagid[0]['id_image_type']))
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_SLIDERCS', 'hometop'))
					return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORTOP', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'ffffff'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBRTOP', '5'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_CW', '0.1'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_NBRPAGE', '20'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_ENABLEDP', 0))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_DISABLEDP', 0))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION', 'yes'))
				return false;
			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', '3'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', '5'))
					return false;
			}

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION2', 'yes'))
				return false;
			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', '3'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', '4'))
					return false;
			}
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_GRID', 'no'))
				return false;

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_RAD', '0'))
				return false;
			if (_PS_VERSION_ < '1.6.0.0')
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', '200'))
					return false;
			}
			else
			{
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', '200'))
					return false;
			}

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEH', '128'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEC', '128'))
				return false;

			if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', $imgtyp[0]['id_image_type']))
				if (!Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', $imgtyp[0]['id_image_type']))
					return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_COLORP', (_PS_VERSION_ > '1.6.0.0' ? '#' : '').'000000'))
				return false;
			if (!Configuration::updateValue('COUNTDOWNSPECIALS_FSP', 14))
				return false;
			@chmod('../modules/countdownspecials/css/'.((_PS_VERSION_ > '1.5.0.0') ? $this->context->shop->id : '').'jquery.countdown.css', 0777);
			return true;

		}

		private function _displayInfo()
		{
				$this->context->smarty->assign(
			array(
				'countdown_cron' => _PS_BASE_URL_._MODULE_DIR_.'countdownspecials/cron.php?token='.Tools::substr(Tools::encrypt('countdownspecials/cron'), 0, 10).'&id_shop='.$this->context->shop->id,
			)
		);
			return $this->display(__FILE__, 'views/templates/hook/infos.tpl');
		}

		public function _displayAdds()
		{
			$orderBy     = null;
			$orderWay    = null;
			$beginning   = true;
			$ending      = false;
			$current_date = date('Y-m-d H:i:s');
			$output      = '';
			$output .= '<h4>'.$this->l('Active prices drop list').'</h4>
                           
                            <table class="table">
        <tr>
        <th>'.$this->l('ID').'</th>
        <th>'.$this->l('Reference').'</th>
   <th>'.$this->l('Name').'</th>
    <th>'.$this->l('From').'</th>
    <th>'.$this->l('To').'</th>
    <th>'.$this->l('Edit').'</th>
        </tr>';
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql = '
				SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
				pl.`meta_keywords`, pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to
				 AS reduction_to,sp.`id_specific_price`,sp.`id_product`
				FROM `'._DB_PREFIX_.'product` p
				LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang`
				= '.(int)$this->context->language->id.')
				LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
				WHERE sp.from <= sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to >= \''.pSQL($current_date).'\'
                            ';

			}

			if (_PS_VERSION_ > '1.5.0.0')
			{
				$current_date = date('Y-m-d H:i:s');
				$sql         = '
                SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`,
				 pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
                pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS  reduction_from,  sp.`to` AS reduction_to,
				 sp.`id_product`,sp.`id_specific_price`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
				 pl.`id_lang` = '.(int)$this->context->language->id.')
                WHERE sp.from <= sp.to && sp.from <= \''.pSQL($current_date).'\' &&
				 sp.to >= \''.pSQL($current_date).'\' && ps.id_shop = '.(int)$this->context->shop->id.'
 && pl.id_shop = '.(int)$this->context->shop->id.'
                ';
			}

			if (_PS_VERSION_ < '1.4.0.0')
			{

				$sql = '
				SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
				 pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
				 pl.`id_lang` = '.(int)$this->context->language->id.')
                WHERE p.reduction_from < p.reduction_to && p.reduction_from < \''.pSQL($current_date).'\' &&
				 p.reduction_to > \''.pSQL($current_date).'\' GROUP BY p.`id_product`';

			}

			$resultt     = mysql_query($sql);
			$pricesDrop  = Db::getInstance()->ExecuteS($sql);
			$prices_drop = array();
			/*paginate*/

			$rpp       = 10; // results per page
			$adjacents = 2;
			$page      = (int)@Tools::getValue('page');
			if ($page <= 0)
				$page = 1;
			$reload = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
			// count total number of appropriate listings:
			@$tcount = mysql_num_rows(@$resultt);
			// count number of pages:
			$tpages = ($tcount) ? ceil($tcount / $rpp) : 1; // total pages, last page number
			$count  = 0;
			$i      = ($page - 1) * $rpp;
			while (($count < $rpp) && ($i < $tcount))
			{
				mysql_data_seek($resultt, $i);
				$query = mysql_fetch_array($resultt);
				$type  = CountdownSpecials::getImages('products');
				$imo   = new Image;
				$im    = $imo->getCover((int)($query['id_product']));
				$im2o  = new Link;
				$im2   = $im2o->getImageLink($query['link_rewrite'], $query['id_product'].'-'.$im['id_image'], $type[0]['name']);

				// output each row:
				$im2 = str_replace($_SERVER['HTTP_HOST'], '../../', $im2);
				$output .= '
        <tr>
		 <form method="post" action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data" >
		<td>'.$query['id_product'].'</td>
        <td>'.$query['reference'].'</td>
        <td style="text-align:center"><img src="../'.$im2.'" width="55"/><br/>'.$query['name'].'</td>
        <td>'.$query['reduction_from'].'</td>
        <td>'.$query['reduction_to'].'</td>';
				if (_PS_VERSION_ < '1.5.0.0')
					$product_token2 = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id;
				else
					$product_token2 = Tools::getAdminTokenLite('updateproduct'.$query['id_product']);

				if (_PS_VERSION_ < '1.5.0.0')
				{
					$output .= '<td><a href="index.php?tab=AdminCatalog&id_product='.$query['id_product'].'&addproduct&token='.$product_token2.'"
					 target="_blank">
					<img src="themes/default/img/process-icon-edit.png" style="vertical-align:top"/></a>
                <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />';
					if (_PS_VERSION_ > '1.4.0.0')
						$output .= '    <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />';
					$output .= '<input type="image" src="themes/default/img/process-icon-delete.png"
					 name="submitDelete" id="submitDelete" border="0"
style="border:none;cursor: pointer;" />
                ';
				}
				else
				{
					$output .= '<td><a href="index.php?controller=adminproducts&id_product='.$query['id_product'].'&updateproduct&token='.$product_token2.'"
					target="_blank"><img src="themes/default/img/process-icon-edit.png" style="vertical-align:top"/></a>

                <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />
                <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />
                <input type="image" src="themes/default/img/process-icon-delete.png" name="submitDelete" id="submitDelete" border="0"
                style="border:none;cursor: pointer;" />
                ';
				}
				$output .= '</td></form>
        </tr>';
				$i++;
				$count++;
			}
			// call pagination function:
			/*endpaginate*/
			/*    foreach ($pricesDrop AS $priceDrop){
            $output  .= '
                    <tr/><td>'.$priceDrop['id_product'].'</td>
                     <td>'.$priceDrop['reference'].'</td>
            <td>'.$priceDrop['name'].'</td>
            <td>'.$priceDrop['reduction_from'].'</td>
            <td>'.$priceDrop['reduction_to'].'</td>
            <td><a href="index.php?tab=AdminCatalog&id_product='.$priceDrop['id_product'].'&addproduct&token='.$productToken.'"
			target="_blank">'.$this->l('Edit').'</a>
            </td>
            </tr>';

            }*/
			$output .= '</table><br/>';
			$output .= CountdownSpecials::paginate_two($reload, $page, $tpages, $adjacents);
			$output .= '<br/><h4>'.$this->l('Expired prices drop list').'</h4>
  
                            <table class="table">
        <tr>
        <th>'.$this->l('ID').'</th>
        <th>'.$this->l('Reference').'</th>
    <th>'.$this->l('Name').'</th>
    <th>'.$this->l('From').'</th>
    <th>'.$this->l('To').'</th>
    <th>'.$this->l('Edit').'</th>
        </tr>';

			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql2 = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`,
                            pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to AS reduction_to, sp.id_specific_price
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang`
                             = '.(int)$this->context->language->id.')
                            LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                            WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to < \''.pSQL($current_date).'\'
                            GROUP BY p.`id_product`
                            ';

			}

			if (_PS_VERSION_ > '1.5.0.0')
			{
				$current_date = date('Y-m-d H:i:s');
				$current_date = date('Y-m-d H:i:s');
				$sql2        = '
                SELECT p.*,ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                 pl.`meta_keywords`, pl.`meta_title`,
                pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
                 ,sp.`id_specific_price`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang`
                 = '.(int)$this->context->language->id.')
                WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to < \''.pSQL($current_date).'\'
                 && ps.id_shop = '.(int)$this->context->shop->id.'
 && pl.id_shop = '.(int)$this->context->shop->id.'
                ';

			}

			if (_PS_VERSION_ < '1.4.0.0')
			{
				$sql2 = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang`
                             = '.(int)$this->context->language->id.')
                            WHERE p.reduction_from < p.reduction_to && p.reduction_to < \''.pSQL($current_date).'\' GROUP BY p.`id_product`';
			}

			$pricesDrop2  = Db::getInstance()->ExecuteS($sql2);
			$resulttt     = mysql_query($sql2);
			$prices_drop2 = array();
			@$tcount2 = mysql_num_rows(@$resulttt);
			// count number of pages:
			$tpages = ($tcount2) ? ceil($tcount2 / $rpp) : 1; // total pages, last page number

			$count = 0;

			$i = ($page - 1) * $rpp;

			while (($count < $rpp) && ($i < $tcount2))
			{
				mysql_data_seek($resulttt, $i);
				$query = mysql_fetch_array($resulttt);
				$type  = CountdownSpecials::getImages('products');
				$imo   = new Image;
				$im    = $imo->getCover((int)($query['id_product']));
				$im2o  = new Link;
				$im2   = $im2o->getImageLink($query['link_rewrite'], $query['id_product'].'-'.$im['id_image'], $type[0]['name']);

				// output each row:
				$im2 = str_replace($_SERVER['HTTP_HOST'], '../../', $im2);
				$output .= '
        <tr>
		  <form method="post" action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data" >
		<td>'.$query['id_product'].'</td>
        <td>'.$query['reference'].'</td>
        <td style="text-align:center"><img src="../'.$im2.'" width="55"/><br/>'.$query['name'].'</td>
        <td>'.$query['reduction_from'].'</td>
        <td>'.$query['reduction_to'].'</td>';

				if (_PS_VERSION_ < '1.5.0.0')
					$product_token3 = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog').
					(int)$this->context->employee->id);
				else
					$product_token3 = Tools::getAdminTokenLite('AdminProducts'.$query['id_product']);
				if (_PS_VERSION_ < '1.5.0.0')
				{
					$output .= '<td><a href="index.php?tab=AdminCatalog&id_product='.$query['id_product'].'&addproduct&token='.$product_token3.'" 
					target="_blank">
					<img src="themes/default/img/process-icon-edit.png" style="vertical-align:top"/></a>
                    <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />';
					if (_PS_VERSION_ > '1.4.0.0')
					$output .= '    <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />';
					$output .= '<input type="image" src="themes/default/img/process-icon-delete.png" 
					name="submitDelete" id="submitDelete" border="0"
style="border:none;cursor: pointer;" />';
				}
				else
				{
					$output .= '<td><a href="index.php?controller=adminproducts&id_product='.$query['id_product'].'&updateproduct&token='.$product_token3.'" 
					target="_blank">
					<img src="themes/default/img/process-icon-edit.png" style="vertical-align:top" /></a>
                    <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />
                <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />
                <input type="image" src="themes/default/img/process-icon-delete.png" name="submitDelete" id="submitDelete" border="0"
                style="border:none;cursor: pointer;" />';
				}
				$output .= '
        </td></form>
        </tr>';
				$i++;
				$count++;

			}
			$output .= '</table><br/>';

			$output .= CountdownSpecials::paginate_two($reload, $page, $tpages, $adjacents);
			$output .= '</div>
                            </fieldset>
                            </form>
							</br>

							';
			$this->context->smarty->assign(array(
				'output'   => $output,
				'tcount'   => $tcount,
				'currentt' => $this->l('Current time: ').date('Y-m-d H:i:s')
			));
			return $this->display(__FILE__, 'views/templates/hook/adds.tpl');
		}

		public function renderForm()
		{
			$this->postProcess();
			$i      = 0;
			$var    = '';
			$imgtyp = CountdownSpecials::getImages('products');
			$count  = count($imgtyp);
			$count;
			$options7 = array();
			for ($i = 0; $i < $count; $i++)
			{
				$idimage    = $imgtyp[$i]['name'];
				$idimaget   = $imgtyp[$i]['id_image_type'];
				$options7[] = array(
					'id_option' => $imgtyp[$i]['id_image_type'],
					'name'      => $imgtyp[$i]['name'],
					'val'       => '1'
				);

			}
			$options1    = array(
				array(
					'id_option' => 'ASC',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('Expiring first')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => 'DESC',
					'name'      => $this->l('Last expiring')
				),

			);
			$options2    = array(
				array(
					'id_option' => '1',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('With words')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => '2',
					'name'      => $this->l('With :')
				),

			);
			$options9    = array(
				array(
					'id_option' => 'Tab',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('Tab')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => 'Normal',
					'name'      => $this->l('Normal')
				),

			);
			$options3    = array(
				array(
					'id_option' => '1',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('Style 1')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => '2',
					'name'      => $this->l('Style 2')
				),
				array(
					'id_option' => '3',
					'name'      => $this->l('Style 3')
				),
				array(
					'id_option' => '4',
					'name'      => $this->l('Style 4')
				),
				array(
					'id_option' => '5',
					'name'      => $this->l('Style 5')
				),
				array(
					'id_option' => '6',
					'name'      => $this->l('Style 6')
				),
				array(
					'id_option' => '7',
					'name'      => $this->l('Style 7')
				),
				array(
					'id_option' => '8',
					'name'      => $this->l('Style 8')
				),
				array(
					'id_option' => '9',
					'name'      => $this->l('Style 9')
				),
				array(
					'id_option' => '10',
					'name'      => $this->l('Flip')
				),
				array(
					'id_option' => '11',
					'name'      => $this->l('Circles')
				),

			);
			$options4    = array(
				array(
					'id_option' => 'hometop',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('only in home, top of pages')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => 'topcs',
					'name'      => $this->l('all pages, in top of pages')
				),
				array(
					'id_option' => 'homecs',
					'name'      => $this->l('homepage')
				),

			);
			$options5    = array(
				array(
					'id_option' => 'yes',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('yes')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => 'no',
					'name'      => $this->l('no')
				),

			);
			$options6    = array(
				array(
					'id_option' => 'no',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('grid')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => 'yes',
					'name'      => $this->l('list')
				),

			);
			$options8    = array(
				array(
					'id_option' => '0.016',
					// The value of the 'value' attribute of the <option> tag.
					'name'      => $this->l('1')
					// The value of the text content of the  <option> tag.
				),
				array(
					'id_option' => '0.033',
					'name'      => $this->l('2')
				),
				array(
					'id_option' => '0.055',
					'name'      => $this->l('3')
				),
				array(
					'id_option' => '0.073',
					'name'      => $this->l('4')
				),
				array(
					'id_option' => '0.1',
					'name'      => $this->l('5')
				),
			);
			$fields_form = array(
				'form' => array(
					'legend' => array(
						'title' => $this->l('Countdown Specials'),
						'icon'  => 'icon-tag'
					),
					'input'  => array(
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '<div class="panel" style="background:#eee">
					<i class="icon-wrench"></i>'.$this->l('General setting').'
					</div>',
						),
						
						array(
							'type'   => 'switch',
							'label'  => $this->l('Disable products'),
							'name'   => 'enabledp',
							'desc'   => $this->l('Disable products when countdown date finish'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),

								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Enable products'),
							'name'   => 'disabledp',
							'desc'   => $this->l('Enable products when countdown date start'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Use CRON'),
							'name'   => 'cront',
							'desc'   => $this->l('Use a cron task to enable or disable the products. You must configure the cron task with the url provided in the help window and set a task for every day, every hour, as for example. you can set in Cron module of Prestashop'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Show sales'),
							'name'   => 'sales',
							'desc'   => $this->l('Display the total sales in the product page'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Push on checkout'),
							'name'   => 'push',
							'desc'   => $this->l('Show limited time offers on cart page (configure options with the slider section)'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Choice of sort'),
							'name'    => 'sort',
							'options' => array(
								'query' => $options1,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Style of time'),
							'name'    => 'styletime',
														'desc'  => $this->l('Only to formats 1 to 9'),

							'options' => array(
								'query' => $options2,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Upper range for the counter'),
							'name'  => 'padding',
							'desc'  => $this->l('The space between the time and the top button (default 3)'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Font size'),
							'name'  => 'fs',
							'desc'  => $this->l('Font size of the time in px, %, em, etc'),
						),
						
						array(
							'type'  => 'text',
							'label' => $this->l('Price Font size'),
							'name'  => 'fsp',
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Price color'),
							'name'  => 'colorp',
							'desc'  => $this->l('Color of the text (default 000000)'),
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Text date color / circle background'),
							'name'  => 'colort',
							'desc'  => $this->l('Color of the text (default ffffff)'),
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Circle color'),
							'name'  => 'cf',
							'desc'  => $this->l('Color of the circle (only for Circles style)'),
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Circle width'),
							'name'    => 'cw',
							'options' => array(
								'query' => $options8,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Style of countdown'),
							'name'    => 'but',
							'options' => array(
								'query' => $options3,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '
					<table width="200" border="0">

                            <tr>

                            <td><img src="../modules/countdownspecials/views/img/Countdown1.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown2.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown3.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown4.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown5.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown6.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown7.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown8.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown9.png" width="60"></td>
							<td><img src="../modules/countdownspecials/views/img/Countdown10.png" width="60"></td>
							<td><img src="../modules/countdownspecials/views/img/Countdown11.png" width="60"></td>
                            </tr>
							<tr>
							<td style="text-align:center">'.$this->l('Style 1').'</td>
														<td>'.$this->l('Style 2').'</td>

							<td style="text-align:center">'.$this->l('Style 3').'</td>

							<td style="text-align:center">'.$this->l('Style 4').'</td>

							<td style="text-align:center">'.$this->l('Style 5').'</td>

							<td style="text-align:center">'.$this->l('Style 6').'</td>

							<td style="text-align:center">'.$this->l('Style 7').'</td>

							<td style="text-align:center">'.$this->l('Style 8').'</td>

							<td style="text-align:center">'.$this->l('Style 9').'</td>
<td style="text-align:center">'.$this->l('Flip').'</td>
<td style="text-align:center">'.$this->l('Circles').'</td>
							 </tr>
							</table>'
						),
							array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '<div class="panel" style="background:#eee">
					<i class="icon-wrench"></i>'.$this->l('Category settings').'
					</div>',
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of the countdown'),
							'name'  => 'catw',
							'desc'  => $this->l('The width of the countdown'),
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Text color / circle background'),
							'name'  => 'catcolor',
							'desc'  => $this->l('Color of the text / circle (default cccccc)'),
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Circle color'),
							'name'  => 'catcolor2',
							'desc'  => $this->l('Color of the circle / circle (default 000000)'),
						),
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '<div class="panel" style="background:#eee">
					<i class="icon-random"></i>'.$this->l('Slider settings').'
					</div>',
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Responsive slider'),
							'name'   => 'respo',
							'desc'   => $this->l('Enable responsive slider (this option disable the width and height of the slider)'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Number of products'),
							'name'  => 'nbrtop',
							'desc'  => $this->l('Set 0 to disable slider'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of the slider'),
							'name'  => 'widtht',
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Height of the slider'),
							'name'  => 'heightt',
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of countdown'),
							'name'  => 'wt',
							'desc'  => $this->l('Only if the countdown style is set to Flip or circles'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Border style'),
							'name'  => 'bordersl',
							'desc'  => $this->l('The border style in css of the slider (like 1px solid #000). Leave blank for no border'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Box shadow'),
							'name'  => 'bs',
							'desc'  => $this->l('The shadow in css of the slider (like 1px -2px 28px 9px rgba(39, 0, 0, 0.5),
							dont unclude the last ";"'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Delay'),
							'name'  => 'delaycs',
						),
						array(
							'type'  => 'color',
							'label' => $this->l('Background color'),
							'name'  => 'colortop',
							'desc'  => $this->l('Color of the text (default ffffff)'),
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Enable slider in'),
							'name'    => 'slidercs',
							'options' => array(
								'query' => $options4,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Type of image'),
							'name'    => 'imagecs',
							'options' => array(
								'query' => $options7,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '<div class="panel" style="background:#eee">
					<i class="icon-list-alt"></i>'.$this->l('Column settings').'
					</div>',
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Image type'),
							'name'    => 'imagec',
							'desc'    => $this->l('The image type for the countdown'),
							'options' => array(
								'query' => $options7,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Image size'),
							'name'  => 'imagesizec',
							'desc'  => $this->l('The width for the image'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Number of products'),
							'name'  => 'nbr3',
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Speed'),
							'name'  => 'nbr2',
							'desc'  => $this->l('Speed of the scroll (1 to 10)'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width'),
							'name'  => 'width',
							'desc'  => $this->l('Width of the block (default 180)').''.$this->l('- 100%'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Height'),
							'name'  => 'height',
							'desc'  => $this->l('Height of the module(default 240)'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of the countdown'),
							'name'  => 'wtb',
							'desc'  => $this->l('Width of the countdown in the columns (only for Flip style or Circles)'),
						),
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '<div class="panel" style="background:#eee">
					<i class="icon-cogs"></i>'.$this->l('Home and countdown page settings').'
					</div>',
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Enable on home page'),
							'name'    => 'hp',
							'desc'    => $this->l('Put no if you want to disable on home page. You can put this code on your homefeatured.tpl
module to include in your home featured the countdown timer: </br>
 {include file="$tpl_dir./../../modules/countdownspecials/views/templates/front/countdownspecials-list.tpl"}'),
							'options' => array(
								'query' => $options5,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Image type'),
							'name'    => 'imageh',
							'desc'    => $this->l('The image type for the countdown'),
							'options' => array(
								'query' => $options7,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Image size'),
							'name'  => 'imagesizeh',
							'desc'  => $this->l('The width for the image'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Number of products to display in homepage'),
							'name'  => 'nbr',
							'desc'  => $this->l('The number of orders to display (default: 10, put 0 to disable in homepage'),
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Number of products to display in Countdown page'),
							'name'  => 'nbrpage',
							'desc'  => $this->l('Total of products to show in countdown page'),
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Enable pagination in homepage'),
							'name'    => 'pagination',
							'options' => array(
								'query' => $options5,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Enable pagination in countdown page'),
							'name'    => 'pagination2',
							'options' => array(
								'query' => $options5,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Products in pagination (homepage)'),
							'name'  => 'paginationn',
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Products in pagination (countdown page)'),
							'name'  => 'paginationn2',
						),
						
						array(
							'type'  => 'text',
							'label' => $this->l('Margin for each element'),
							'name'  => 'margin',
							'desc'  => $this->l('The margin for each product, use 2 as min'),

						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Show add to cart'),
							'name'    => 'color2',
							'options' => array(
								'query' => $options5,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Display type'),
							'name'    => 'home6',
							'desc'    => $this->l('Display the module in homepage as Tabs (with the featured, sales, etc tabs) or Normal'),
							'options' => array(
								'query' => $options9,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'    => 'select',
							'label'   => $this->l('Style of the module'),
							'name'    => 'grid',
							'desc'    => $this->l('Show items as grid or list (homepage and module page for normal display)'),
							'options' => array(
								'query' => $options6,
								'id'    => 'id_option',
								'name'  => 'name'
							)
						),
						array(
							'type'   => 'switch',
							'label'  => $this->l('Responsive products'),
							'name'   => 'respop',
							'desc'   => $this->l('Enable responsive products (this overwrites the width, height and module width. You template must be bootstrap compatible)'),
							'values' => array(
								array(
									'id'    => 'on',
									'value' => 1
								),
								array(
									'id'    => 'off',
									'value' => 0
								)
							)
						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of the module'),
							'name'  => 'width3',
							'desc'  => $this->l('Width of the block (default 540px)'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Height of each element'),
							'name'  => 'width3h',
							'desc'  => $this->l('The height for each element in homepage and page'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of each element'),
							'name'  => 'listw',
							'desc'  => $this->l('The width for each element in homepage and page'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Width of the countdown'),
							'name'  => 'wth',
							'desc'  => $this->l('The width of the countdown (only for Flip style)'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Border style'),
							'name'  => 'align',
							'desc'  => $this->l('For example: 1px solid #000. Leave blank for no border'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Border radius'),
							'name'  => 'rad',
							'desc'  => $this->l('Make the border of elements with a radius (max 20)'),

						),
						array(
							'type'  => 'text',
							'label' => $this->l('Box shadow'),
							'name'  => 'pbs',
							'desc'  => $this->l('Shadow for each element in css (like -1px 0px 6px 2px rgba(20, 0, 0, 0.5)). Leave blank for no shadow'),

						),
						array(
							'type'  => 'color',
							'label' => $this->l('Background color'),
							'name'  => 'colorbg',
							'desc'  => $this->l('Color of the background (default ffffff)'),

						),
						array(
							'type'         => 'html',
							'name'         => 'html_data',
							'html_content' => '
					',
						),

					),
					'submit' => array(
						'title' => $this->l('Save'),
					)


				),




			);

			$helper                           = new HelperForm();
			$helper->show_toolbar             = true;
			$helper->table                    = $this->table;
			$lang                             = new Language((int)Configuration::get('PS_LANG_DEFAULT'));
			$helper->default_form_language    = $lang->id;
			$helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ?
			Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0;
			$this->fields_form                = array();
			$helper->identifier               = $this->identifier;
			$helper->submit_action            = 'submitCountdownSpecials';
			$helper->currentIndex   = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name;

			$helper->token    = Tools::getAdminTokenLite('AdminModules');
			$helper->tpl_vars = array(
				'fields_value' => $this->getConfigFieldsValues(),
				'languages'    => $this->context->controller->getLanguages(),
				'id_language'  => $this->context->language->id
			);
			return $helper->generateForm(array($fields_form));
		}

		public function postProcess()
		{
			$errors = '';
			$output = '';
			if (Tools::isSubmit('submitDeleteAll'))
		{
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);


			Db::getInstance()->Execute('TRUNCATE '._DB_PREFIX_.'specific_price');
			Db::getInstance()->Execute('TRUNCATE '._DB_PREFIX_.'specific_price_priority');
			$output .= @$errors == '' ? $this->displayConfirmation('All discounts deleted') : @$errors;

		}
			if (Tools::isSubmit('submitall'))
			{
				
				$output .= $this->displayConfirmation($this->l('Expired time offers deleted').'<br/>');

			}
			if (Tools::isSubmit('submitDelete'))
			{
				if (_PS_VERSION_ < '1.4.0.0')
				{

					Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'product  SET  '._DB_PREFIX_.'product.`reduction_from`
					=  \'2011-07-05 09:27:24\',
`reduction_to` =  \'2011-07-05 09:27:24\' WHERE `id_product`='.(int)(Tools::getValue('id_product')));
					$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'));
				}
				if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
				{

					Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'specific_price
					WHERE '._DB_PREFIX_.'specific_price.`id_specific_price`='.(int)(Tools::getValue('id_discount')));
					$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'.Tools::getValue('id_discount')));
				}
				if (_PS_VERSION_ > '1.5.0.0')
				{
					Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'specific_price
					 WHERE '._DB_PREFIX_.'specific_price.`id_specific_price`='.(int)(Tools::getValue('id_discount')).' && '._DB_PREFIX_.'specific_price.`id_product`='.(int)(Tools::getValue('id_product')));
					$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'));
				}

			}
			if (Tools::isSubmit('submitCountdownSpecials'))
			{
			if (!file_exists('../themes/'._THEME_NAME_.'/img/flipper92.png'))
			{
			$mask = '../modules/countdownspecials/views/img/flipper*.png';
			$fil = glob($mask);	
			foreach ($fil as $fi)
			{
			$fi2 = str_replace('../modules/countdownspecials/views/img/', '', $fi);
			$fi3 = '../themes/'._THEME_NAME_.'/img/'.$fi2;
			//var_dump($fi3);
			if (_PS_VERSION_ > '1.5.5.0')
			@Tools::copy($fi, $fi3);
			else
			@CountdownSpecials::copy($fi, $fi3);
			}
			}
				if ($grid = Tools::getValue('grid'))
					Configuration::updateValue('COUNTDOWNSPECIALS_GRID', $grid);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_GRID');
					
					if ($respo = Tools::getValue('respo'))
					Configuration::updateValue('COUNTDOWNSPECIALS_RESPO', $respo);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_RESPO');
					
					if ($respop = Tools::getValue('respop'))
					Configuration::updateValue('COUNTDOWNSPECIALS_RESPOP', $respop);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_RESPOP');

				if ($disabledp = Tools::getValue('disabledp'))
					Configuration::updateValue('COUNTDOWNSPECIALS_DISABLEDP', $disabledp);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_DISABLEDP');

				if ($cw = Tools::getValue('cw'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CW', $cw);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CW');

				if ($sales = Tools::getValue('sales'))
					Configuration::updateValue('COUNTDOWNSPECIALS_SALES', $sales);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_SALES');

				if ($cf = Tools::getValue('cf'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CF', $cf);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CF');

				if ($pbs = Tools::getValue('pbs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PBS', $pbs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PBS');

				if ($home6 = Tools::getValue('home6'))
					Configuration::updateValue('COUNTDOWNSPECIALS_HOME6', $home6);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_HOME6');
if ($cront = Tools::getValue('cront'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CRONT', $cront);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CRONT');
				if ($push = Tools::getValue('push'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PUSH', $push);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PUSH');


				if ($enabledp = Tools::getValue('enabledp'))
					Configuration::updateValue('COUNTDOWNSPECIALS_ENABLEDP', $enabledp);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_ENABLEDP');
				if ($bordersl = Tools::getValue('bordersl'))
					Configuration::updateValue('COUNTDOWNSPECIALS_BORDERSL', $bordersl);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_BORDERSL');

				if ($sort = Tools::getValue('sort'))
					Configuration::updateValue('COUNTDOWNSPECIALS_SORT', $sort);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_SORT');
				if ($wtb = Tools::getValue('wtb'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WTB', $wtb);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WTB');
					if ($catw = Tools::getValue('catw'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CATW', $catw);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CATW');
						if ($catcolor = Tools::getValue('catcolor'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR', $catcolor);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CATCOLOR');
							if ($catcolor2 = Tools::getValue('catcolor2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR2', $catcolor2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_CATCOLOR2');
				if ($number = Tools::getValue('number'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NUMBER', $number);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NUMBER');

				if ($bs = Tools::getValue('bs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_BS', $bs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_BS');

				if ($wth = Tools::getValue('wth'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WTH', $wth);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WTH');


				if ($height = Tools::getValue('height'))
					Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHT', $height);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_HEIGHT');

				if ($width2 = Tools::getValue('width2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH2', $width2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WIDTH2');

				if ($fs = Tools::getValue('fs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_FS', $fs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_FS');

				if ($width3 = Tools::getValue('width3'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', $width3);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WIDTH3');

				if ($width = Tools::getValue('width'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH', $width);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WIDTH');

				if ($align = Tools::getValue('align'))
					Configuration::updateValue('COUNTDOWNSPECIALS_ALIGN', $align);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_ALIGN');

				if ($imagecs = Tools::getValue('imagecs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', $imagecs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_IMAGECS');

				if ($wt = Tools::getValue('wt'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WT', $wt);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WT');

				if ($color2 = Tools::getValue('color2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_COLOR2', $color2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_COLOR2');

				if ($colort = Tools::getValue('colort'))
					Configuration::updateValue('COUNTDOWNSPECIALS_COLOR', $colort);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_COLOR');

				if ($padding = Tools::getValue('padding'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PADDING', $padding);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PADDING');

				if ($styletime = Tools::getValue('styletime'))
					Configuration::updateValue('COUNTDOWNSPECIALS_STYLETIME', $styletime);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_STYLETIME');

				if ($margin = Tools::getValue('margin'))
					Configuration::updateValue('COUNTDOWNSPECIALS_MARGIN', $margin);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_MARGIN');

				if ($but = Tools::getValue('but'))
					Configuration::updateValue('COUNTDOWNSPECIALS_BUT', $but);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_BUT');


				if ($colorp = Tools::getValue('colorp'))
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORP', $colorp);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_COLORP');

				if ($fsp = Tools::getValue('fsp'))
					Configuration::updateValue('COUNTDOWNSPECIALS_FSP', $fsp);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_FSP');

				if ($nbr = Tools::getValue('nbr'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR', $nbr);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NBR');

				if ($imagesizec = Tools::getValue('imagesizec'))
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEC', $imagesizec);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_IMAGESIZEC');

				if ($imagesizeh = Tools::getValue('imagesizeh'))
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEH', $imagesizeh);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_IMAGESIZEH');

				if ($imagec = Tools::getValue('imagec'))
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', $imagec);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_IMAGEC');

				if ($imageh = Tools::getValue('imageh'))
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', $imageh);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_IMAGEH');

				if ($listw = Tools::getValue('listw'))
					Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', $listw);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_LISTW');

				if ($rad = Tools::getValue('rad'))
					Configuration::updateValue('COUNTDOWNSPECIALS_RAD', $rad);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_RAD');

				if ($pagination = Tools::getValue('pagination'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION', $pagination);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PAGINATION');

				if ($paginationn = Tools::getValue('paginationn'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', $paginationn);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PAGINATIONN');

				if ($pagination2 = Tools::getValue('pagination2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION2', $pagination2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PAGINATION2');

				if ($slidercs = Tools::getValue('slidercs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_SLIDERCS', $slidercs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_SLIDERCS');

				if ($paginationn2 = Tools::getValue('paginationn2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', $paginationn2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_PAGINATIONN2');

				if ($nbrpage = Tools::getValue('nbrpage'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NBRPAGE', $nbrpage);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NBRPAGE');

				if ($nbrtop = Tools::getValue('nbrtop'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NBRTOP', $nbrtop);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NBRTOP');

				if ($colortop = Tools::getValue('colortop'))
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORTOP', $colortop);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_COLORTOP');

				if ($colorbg = Tools::getValue('colorbg'))
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORBG', $colorbg);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_COLORBG');

				if ($widtht = Tools::getValue('widtht'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', $widtht);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WIDTHT');

				if ($heightt = Tools::getValue('heightt'))
					Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', $heightt);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_HEIGHTT');

				if ($delaycs = Tools::getValue('delaycs'))
					Configuration::updateValue('COUNTDOWNSPECIALS_DELAYCS', $delaycs);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_DELAYCS');

				if ($nbr2 = Tools::getValue('nbr2'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR2', $nbr2);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NBR2');


				if ($hp = Tools::getValue('hp'))
					Configuration::updateValue('COUNTDOWNSPECIALS_HP', $hp);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_HP');

				if ($width3h = Tools::getValue('width3h'))
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3H', $width3h);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_WIDTH3H');

				if ($nbr3 = Tools::getValue('nbr3'))
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR3', $nbr3);
				elseif (Shop::getContext() == Shop::CONTEXT_SHOP || Shop::getContext() == Shop::CONTEXT_GROUP)
					Configuration::deleteFromContext('COUNTDOWNSPECIALS_NBR3');
				$ht  = $wt * 60 / 275;
				$htc = $wt * 100 / 400;
				$htb = $wtb * 100 / 400;
				$hth = $wth * 100 / 400;
				$hthw = $catw * 100 / 400;
if ($but == 11 || $but == 10)
{
$chptop = 0;
$widcspec = '100%';
$mlef = '0%';
}
else
{
$chptop = 38;
$mlef = '-32%';
$widcspec = '0px';
}
				$output .= $this->displayConfirmation($this->l('Settings updated successfully').'<br/>');
				$xml2 = fopen('../modules/countdownspecials/views/css/'.((_PS_VERSION_ > '1.5.0.0') ?
						$this->context->shop->id : '').'jquery.countdown.css', 'w');
if ($styletime == 1)
{
$styl = '45';
$styl2 = '';
}
else
{
$styl = '7';
$styl2 = 'text-align:center;';
}
if ($respop == 1)
$width3 = '100%';

if (_PS_VERSION_ > '1.6.0.0')
$hascon = '189px';
else
$hascon = '149px';
				fwrite($xml2, '
				/* cat */
				#cstop{width:100%; clear:both; margin:0 auto;   background: url(../img/cat.jpg) center top; position:relative; float:left;display: table; height:95px}
				 #cstext{width:30%; position:relative; float:left; text-align:center;display: table-cell; vertical-align: middle; line-height:95px}
 #csofer{width:37%; position:relative; float:left; text-align:center;display: table-cell; vertical-align: middle;}
 #cscount{width:33%; position:relative; float:left; margin-top:15px}
  #cstext h1{font-size: 20px; font-weight: bolder; color:white;margin-top:0;line-height: 43px;text-shadow: 2px 2px 2px rgba(0, 0, 0, 1);}
	#csofer h2{font-size: 53px;    color: white;
    font-weight: bolder;margin-top:0;line-height: 95px;  text-shadow: 2px 2px 2px rgba(0, 0, 0, 1);}
				/* News */
.news-slider {clear:both
  /* Style the actual content */
}
.sy-list h1{margin-top:0}
.news-slider .text-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 1em;
  width: 49%;
  height: 100%;
}
.news-slider .text-content h2 {
  margin: 0; background:none;
}
.news-slider .text-content p {
  margin: 0.5em 0;padding-bottom:5px
}
.news-slider .text-content a.button-link {
  padding: 0.25em 0.5em;
  position: absolute;
  bottom: 1em;
  right: 1em;
}
.news-slider .image-content {
  line-height: 0;
}
.news-slider .image-content img {
  max-width: 100%;
}
.news-slider .news-pager {
  text-align: right;
  display: block;
  margin: 0.2em 0 0;
  padding: 0;
  list-style: none;
}
.news-slider .news-pager li {
  display: inline-block;
  padding: 0.6em;
  margin: 0 0 0 1em;
}
.news-slider .news-pager li.sy-active a {
  color: #31ace2;
}
.news-slider .news-pager li a {
  font-weight: 500;
  text-decoration: none;
  display: block;
  color: #222;
}
/**
 *
 * slippry v1.2.9 - Responsive content slider for jQuery
 * http://slippry.com
 *
 * Authors: Lukas Jakob Hafner - @saftsaak
 *          Thomas Hurd - @SeenNotHurd
 *
 * Copyright 2015, booncon oy - http://booncon.com
 *
 *
 * Released under the MIT license - http://opensource.org/licenses/MIT
 */
/* kenBurns animations, very basic */
@-webkit-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-moz-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-ms-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-webkit-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@-moz-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@-ms-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
/* added to the original element calling slippry */
.sy-box.sy-loading {
  background: url("../img/sy-loader.gif") 50% 50% no-repeat;
  -moz-background-size: 32px;
  -o-background-size: 32px;
  -webkit-background-size: 32px;
  background-size: 32px;
  min-height: 40px; }
  .sy-box.sy-loading .sy-slides-wrap, .sy-box.sy-loading .sy-pager {
    visibility: hidden; }

/* element that wraps the slides */
.sy-slides-wrap {
	box-shadow:'.$bs.';
-moz-box-shadow: '.$bs.';
-webkit-box-shadow:'.$bs.';
	background:url(../img/back.png) repeat-x '.$colortop.';
border:'.$bordersl.';
  position: relative;

  width: 100%; }
  .sy-slides-wrap:hover .sy-controls {
    display: block; }

/* element that crops the visible area to the slides */
.sy-slides-crop {
  height: 100%;
  width: 100%;
  position: absolute;
  overflow: hidden; }

/* list containing the slides */
.sy-list {
  width: 100%;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute; }
  .sy-list.horizontal {
    -moz-transition: left ease;
    -o-transition: left ease;
    -webkit-transition: left ease;
    transition: left ease; }
  .sy-list.vertical {
    -moz-transition: top ease;
    -o-transition: top ease;
    -webkit-transition: top ease;
    transition: top ease; }

/* single slide */
.sy-slide {min-height:322px;
  position: absolute;
  width: 100%;
  z-index: 2; }
  .sy-slide.kenburns {
    width: 140%;
    left: -20%; }
    .sy-slide.kenburns.useCSS {
      -moz-transition-property: opacity;
      -o-transition-property: opacity;
      -webkit-transition-property: opacity;
      transition-property: opacity; }
      .sy-slide.kenburns.useCSS.sy-ken:nth-child(1n) {
        -webkit-animation-name: left-right;
        -webkit-animation-fill-mode: forwards;
        -moz-animation-name: left-right;
        -moz-animation-fill-mode: forwards;
        -o-animation-name: left-right;
        -o-animation-fill-mode: forwards;
        animation-name: left-right;
        animation-fill-mode: forwards; }
      .sy-slide.kenburns.useCSS.sy-ken:nth-child(2n) {
        -webkit-animation-name: right-left;
        -webkit-animation-fill-mode: forwards;
        -moz-animation-name: right-left;
        -moz-animation-fill-mode: forwards;
        -o-animation-name: right-left;
        -o-animation-fill-mode: forwards;
        animation-name: right-left;
        animation-fill-mode: forwards; }
  .sy-slide.sy-active {
    z-index: 3; }
  .sy-slide > img {
    margin: 0;
    padding: 0;
    display: block;
    width: 100%;
    border: 0; }
  .sy-slide > a {
    margin: 0;
    padding: 0;
    display: block;
    width: 100%; }
    .sy-slide > a > img {
      margin: 0;
      padding: 0;
      display: block;
      width: 100%;
      border: 0; }

/* next/ prev buttons, with arrows and clickable area a lot larger than the visible buttons */
.sy-controls {
  display: none;
  list-style: none;
  height: 100%;
  width: 100%;
  position: absolute;
  padding: 0;
  margin: 0; }
  .sy-controls li {
    position: absolute;
    width: 10%;
    min-width: 4.2em;
    height: 100%;
    z-index: 33; }
    .sy-controls li.sy-prev {
      left: 0;
      top: 0; }
      .sy-controls li.sy-prev a:after {
        background-position: -5% 0; }
    .sy-controls li.sy-next {
      right: 0;
      top: 0; }
      .sy-controls li.sy-next a:after {
        background-position: 105% 0; }
    .sy-controls li a {
      position: relative;
      width: 100%;
      height: 100%;
      display: block;
      text-indent: -9999px; }
      .sy-controls li a:link, .sy-controls li a:visited {
        opacity: 0.4; }
      .sy-controls li a:hover, .sy-controls li a:focus {
        opacity: 0.8;
        outline: none; }
      .sy-controls li a:after {
        content: "";
        background-image: url("../img/arrows.svg");
        background-repeat: no-repeat;
        -moz-background-size: cover;
        -o-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
        text-align: center;
        text-indent: 0;
        line-height: 2.8em;
        color: #111;
        font-weight: 800;
        position: absolute;
        background-color: #fff;
        width: 2.8em;
        height: 2.8em;
        left: 50%;
        top: 50%;
        margin-top: -1.4em;
        margin-left: -1.4em;
        -moz-border-radius: 50%;
        -webkit-border-radius: 50%;
        border-radius: 50%; }
		.sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
 .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
  #count img{border:1px solid #ccc}
 #featured-products_block_centercs .col-md-4, #featured-products_block_centercs .col-md-3{padding-left:15px; padding-right:15px}
  @media only screen and (max-device-width: 600px) {
	  
    .sy-controls {
      display: block; }
      .sy-controls li {
        min-width: 2.1em; }
        .sy-controls li a:after {
          width: 1.4em;
          height: 1.4em;
          margin-top: -0.7em;
          margin-left: -0.7em; } }

/* captions, styled fo the overlay variant */
.sy-caption-wrap {
  position: absolute;
  bottom: 2em;
  z-index: 12;
  left: 50%; }
  .sy-caption-wrap .sy-caption {
    position: relative;
    left: -50%;
    background-color: rgba(0, 0, 0, 0.54);
    color: #fff;
    padding: 0.4em 1em;
    -moz-border-radius: 1.2em;
    -webkit-border-radius: 1.2em;
    border-radius: 1.2em; }
    .sy-caption-wrap .sy-caption a:link, .sy-caption-wrap .sy-caption a:visited {
      color: #e24b70;
      font-weight: 600;
      text-decoration: none; }
    .sy-caption-wrap .sy-caption a:hover, .sy-caption-wrap .sy-caption a:focus {
      text-decoration: underline; }
  @media only screen and (max-device-width: 600px), screen and (max-width: 768px) {
	   #cstext,#csofer,#cscount{width:100%; height:99px}
	   .examplecat{float:none;width:280px}
	   #cstop{background:url(../img/cat2.jpg) center top;}
	    .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
	  .sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
    .sy-caption-wrap {
      left: 0;
      bottom: 0.4em; }
      .sy-caption-wrap .sy-caption {
        left: 0;
        padding: 0.2em 0.4em;
        font-size: 0.92em;
        -moz-border-radius: 0;
        -webkit-border-radius: 0;
        border-radius: 0; } }

/* pager bubbles */
.sy-pager {
  overflow: hidden;
  *zoom: 1;
  display: block;
  width: 100%;
  margin: 1em 0 0;
  padding: 0;
  list-style: none;
  text-align: center; }
  .sy-pager li {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    margin: 0 1em 0 0;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%; }
    .sy-pager li.sy-active a {
      background-color: #e24b70; }
    .sy-pager li a {
      width: 100%;
      height: 100%;
      display: block;
      background-color: #ccc;
      text-indent: -9999px;
      -moz-background-size: 2em;
      -o-background-size: 2em;
      -webkit-background-size: 2em;
      background-size: 2em;
      -moz-border-radius: 50%;
      -webkit-border-radius: 50%;
      border-radius: 50%; }
      .sy-pager li a:link, .sy-pager li a:visited {
        opacity: 1.0; }
      .sy-pager li a:hover, .sy-pager li a:focus {
        opacity: 0.6; }

/* element to "keep/ fill" the space of the content, gets intrinsic height via js */
.sy-filler {
  width: 100%; }
  .sy-filler.ready {
    -moz-transition: padding 600ms ease;
    -o-transition: padding 600ms ease;
    -webkit-transition: padding 600ms ease;
    transition: padding 600ms ease; }

				.is-countdown {
					text-align:left;
	
}
.countdown-rtl {
	direction: rtl;
}
.countdown-holding span {
	/*color: #888;*/
}
.countdown-row {
	clear: both;
	width: 100%;
	padding: 0px 2px;
	text-align: center;
}
.countdown-show1 .countdown-section {
	width: 98%;
}
.countdown-show2 .countdown-section {
	width: 48%;
}
.countdown-show3 .countdown-section {
	width: 25.5%;
}
.countdown-show4 .countdown-section {
	width: 20.5%;
}
.countdown-show5 .countdown-section {
	width: 19.5%;
}
.countdown-show6 .countdown-section {
	width: 16.25%;
}
.countdown-show7 .countdown-section {
	width: 14%;
}
.countdown-section {
	display: block;
	float: left;
	font-size:'.$fs.';
	text-align: center;
}
#defaultCountdownhptop .countdown-amount{color:'.$catcolor2.'}
 .countdown-amount{margin:0 auto;
color:'.$colort.' ;
font-weight:bold;height:38px;}
.countdown-period {
    display: block;
	line-height:7px;
}
.countdown-descr {
	display: block;
	width: 100%;
}

				.cspec2{width:'.$widcspec.'; left:'.$mlef.';position:relative;float:left; z-index:500}
.wrappercs {

border-radius: 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
position: relative;
z-index: 90;
}

.ribbon-wrapper-green {
width: 85px;
height: 88px;
overflow: hidden;
position: absolute;
top: -11px;
right: -11px;
}

.ribbon-green {
font: bold 9px Sans-Serif;
color: #333;
text-align: center;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
position: relative;
padding: 7px 0;
left: -5px;
top: 15px;
width: 131px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45);
color: #6a6340;
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
box-shadow:3px 1px 2px 0px #000;
}

.ribbon-green:before, .ribbon-green:after {
content: "";
border-top: 3px solid #6e8900;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
position:absolute;
bottom: -3px;
}

.ribbon-green:before {
left: 0;
}
.ribbon-green:after {
right: 0;
}
/**
 *	This element is created inside your target element
 *	It is used so that your own element will not need to be altered
 **/
.time_circles {
    position: relative;
    width: 100%;
    height: 100%;
	float:left
}

/**
 *	This is all the elements used to house all text used
 * in time circles
 **/
.time_circles > div {
    position: absolute;
    text-align: center;
}

/**
 *	Titles (Days, Hours, etc)
 **/
.time_circles > div > h4, #left_column .time_circles > div > h4,#right_column .time_circles > div > h4 {
    margin: 0px;height:auto;box-shadow:none;-moz-box-shadow:none; -webkit-box-shadow:none;
    padding: 0px;
    text-align: center;
    text-transform: uppercase;
   /* font-family: \'Century Gothic\', Arial;*/
	color:'.$colort.';
	font-weight:bolder;
	border:none;
	background:transparent
} {
    margin: 0px;
    padding: 0px;
    text-align: center;
    text-transform: uppercase;
   /* font-family: \'Century Gothic\', Arial;*/
	color:'.$colort.';
	font-weight:bolder;
	border:none;
	background:transparent
}

/**
 *	Time numbers, ie: 12
 **/
#cscount .time_circles > div > span,#cscount .time_circles > div > h4, .hasCountdown,#cscount .is-countdown{color:'.$catcolor.'}
.time_circles > div > span {
    display: block;
    width: 100%;
    text-align: center;
    font-family: \'Century Gothic\', Arial;
    font-size: 300%;
    margin-top: 0.4em;
    font-weight: bold;
	color:'.$colort.'
}
.focl{margin:0 auto; width:'.$wt.'px}
.fooc{margin:0 auto; width:'.$wtb.'px}
.fooh{margin:0 auto; width:'.$wth.'px}
.foohcat{margin:0 auto; width:'.$catw.'px}
.fooh2{margin:0 auto; width:'.$wt.'px}
.foohh{margin:0 auto; width:'.$wth.'px}
.foop{margin:0 auto; width:200px}
.fool{margin:0 auto; width:200px}
.examplet{margin:0 auto; width:'.$wt.'px; height:'.$htc.'px; clear:both}
.examplec{margin:0 auto; width:'.$wtb.'px; height:'.$htb.'px; clear:both}
.examplep{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both}
.exampleh{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both;}
.examplecat{margin:0 auto; width:'.$catw.'px; height:'.$hthw.'px; clear:both;float:right}
.examplepp{margin:0 auto; width:230px; clear:both}
.examplel{margin:0 auto; width:210px; clear:both}
.examplel2{margin:0 auto; width:189px; clear:none}
.examplehh{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both}

/**/

#fssListc {
list-style: none;
width: 646px;
/* margin: auto; */
/* padding: 5px 0 0 45%; */
margin-top: -50px;
position: relative;
float: left;
margin-left: 11px;
}
#fssListc li {
display: inline;
border-radius: 55%;
/* width: 36px; */
/* height: 3px; */
padding: 3px 6px 3px 6px;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
margin: 3px;
/* line-height: 10px; */
}
#fssListc li.fssActivec a{/* background: #ddd; */
font-weight: bold;
color: red;}
/**/

#fssList {
list-style: none;
width: 646px;
/* margin: auto; */
/* padding: 5px 0 0 45%; */
margin-top: -40px;
position: relative;
float: left;
margin-left: 11px;
}
#fssList li {
display: inline;

/* width: 36px; */
/* height: 3px; */

text-align: center;
margin:3px  13px 3px 3px; position:relative;float:left;; width:15px
/* line-height: 10px; */
}
#fssList li.fssActive a{/* background: #ddd; */
font-weight: bold; text-decoration:none;
padding: 3px 6px 3px 6px;
background: #fff;
border: 2px solid #666;

border-radius: 55%;
text-align: center;
color: red;}
.cscart{margin:0 auto; float:left; width:100%; text-align:center; margin-top:5px; margin-bottom:5px}
.descs{min-height: 27px;
  position: relative;
  float: left;margin:0 auto}
.cscart .ajax_add_to_cart_button {

border: 2px solid #ccc;
padding: 6px 23px;
margin-top: -4px;
position: relative;
clear: both;
min-height: 28px;
line-height: 27px;
border-radius: 5px;   background: url(../img/atc.jpg) right top;
  color: white;
}
.cscart .ajax_add_to_cart_button:hover
{
  border: 2px solid #999;
    background: url(../img/atc2.jpg) right top;
}
/**/
#ajsliderc {
margin: 10px 0 10px 0;
border:'.$bordersl.';
position:relative;
float:left
}
#ajsliderc .s {
background:url(../img/back.png) repeat-x '.$colortop.';
padding:10px;
text-align: center;
}
.sy-list h4{text-align:center}
.sy-list .pricescs{font-size:21px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%; height:87px;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 67px;}
#ajsliderc .s h1 { background-image:none; font-size:18px;    margin: 1px 2px;}
#ajsliderc .s .pricescs {
font-size:25px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%; height:87px;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 87px;
 }
	#slic1{position: relative; float:left; width:60%}
	#slic2{position: relative; float:left; width:39%}
/**/
	#ajslider {
margin: 10px 0 10px 0;
border:'.$bordersl.';
box-shadow:'.$bs.';
-moz-box-shadow: '.$bs.';
-webkit-box-shadow:'.$bs.';
position:relative;
float:left
}
#ajslider .s {
background:url(../img/back.png) repeat-x '.$colortop.';
padding:10px;
text-align: center;
}
#ajslider .s h1 { background-image:none; font-size:18px; overflow:hidden; margin-top:1px}
#ajslider .s .pricescs {  margin-bottom:10px;
font-size:17px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%; height:87px;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 87px;
}
	.hasCountdown,.is-countdown {
position:absolute;
margin:0 auto;
color:'.$colort.' ;
font-weight:bold;
	background:url(../img/Countdown'.$but.'.png) no-repeat center;
	 padding-left:48px;
	 padding-top:'.$padding.'px;
	height:38px;
	clear:both;
	font-family:Arial;
	font-size:12px;
	width: '.$hascon.';
bottom: 3px;
left: 0;
right: 0;
}

.price_container{
text-align:center
}
.exclusive ajax_add_to_cart_button
{text-align:center; margin:0 auto}
#featured-products_block_centercs h2, #featured-products_block_centercs h3, #featured-products_block_centercs h4
{
padding: 2px 0 0 40px;
}
#featured-products_block_centercs .time_circles  h4, #center_column #featured-products_block_centercs .time_circles  h4{padding:0; margin-top:-4px;  background: none;border:none;text-align:center;
  color: '.$colort.';box-shadow:none;-moz-box-shadow:none; -webkit-box-shadow:none;
  height: inherit;
}
.countdown_rtl {
direction: rtl;
}
.countdown_holding span {
background-color: #ccc;
}
.countdown_row {
display:inline;
clear: both;
float:left;
width: 100%;
//margin-left:30px;
padding:1px 0 0 '.$styl.'px;
'.$styl2.'
//text-align: center;
line-height:14px;
width:200px
}
.countdown_show1 .countdown_section {
width: 33px;
color:'.$colort.' ;
}
.countdown_show2 .countdown_section {
width: 33px;
color:'.$colort.' ;
}
.countdown_show3 .countdown_section {
width: 33px;
color:'.$colort.' ;
}
.countdown_show4 .countdown_section {
width: 29px;
color:'.$colort.' ;
}
.countdown_show5 .countdown_section {
width: 19.5%;
color:'.$colort.' ;
}
.countdown_show6 .countdown_section {
width: 16.25%;
color:'.$colort.' ;
}
.countdown_show7 .countdown_section {
width: 14%;
color:'.$colort.' ;
}
.hasCountdown .countdown_section,.countdown_section{
display: block;
float: left;
font-size: 75%;
text-align: center;
font-weight:normal;
line-height:15px
}
.hasCountdown .countdown_amount,.countdown_amount {
font-size:'.$fs.';
line-height:14px
}
.countdown_descr {
display: block;
width: 100%;
}

	#marqueecontainercs{
	position: relative;
	width: '.$width.'; /*marquee width */
	height: '.$height.'px; /*marquee height */
	overflow: hidden;
	/*border: 3px solid orange;*/
	}
	/* Container DIV - automatically generated */
	
.titletime, .center_column h2.titletime{
line-height:46px;
	background:url(../img/title.png) no-repeat left center;
	height:46px;
	padding-left:40px; padding-top:1px; padding-bottom:0px; font-size:23px; text-transform:capitalize}
	.dash {
	float: left;
	position: relative;
	}
	.dash .digit {
	font-weight: bold;
	float: left;
	text-align: center;
	position: relative;
	}
	.dash_title {
	position: absolute;
	display: block;
	bottom: 0px;
	right: 6px;
	font-size: 9pt;
	color: #555;
	text-transform: uppercase;
	letter-spacing: 2px;
	}
	.dev_comment {
	font-size: 14pt;
	color: #777;
	text-align: center;
	font-style: italic;
	margin: 40px 10px;
	}
	#subscribe_form {
	position: relative;
	}
	#email_field {
	font-size: 16pt;
   padding: 6px 10px;
	width: 300px;
	}
	.copyright {
	font-size: 9pt;
	color: #333;
	margin: 40px 0px;
	}
	.faded {
	color: #999;
	}
	.form_message {
	width: 400px;
	padding: 10px;
	margin: 15px auto;
	display: none;
	}
	#error_message {
	background-color: #ffe;
	border-left: 5px solid #bb3;
	border-right: 5px solid #bb3;
	color: #770;
	}
	#info_message {
	background-color: #f0f9ff;
	border: 1px solid #eef;
	}
	#loading {
	text-align: center;
	margin: 10px;
	display: none;
	position: absolute;
	width: 100%;
	top: 60px;
	} 
	#short_description_blockcd .is-countdown{text-align:left}
	#short_description_blockcd{
	background: #ffffff;
	position: relative; clear:both;
	border: solid 1px #D0D3D8;
	margin-bottom: 1.5em;
	padding: 0.7em;
	margin-top: 1.5em;
	text-align:center;
	min-height:102px;
	min-width:195px

	}
	#cd{
	background-image:url(../img/icon.png);
	background-repeat:no-repeat;
	width:64px;
	height:37px;
	text-align:center;
	padding-top:27px;margin:0 auto;
	color:#000
	}
	#cd span{
	color:#fff
	}
	#sli1{position: relative; float:left; width:60%}
	#sli2{position: relative; float:left; width:39%}
	.sy-pager li.sy-active a {
  background-color: red;
}
.sy-pager li a {
  width: 100%;
  height: 100%;
  display: block;
  background-color: #ccc;
  text-indent: -9999px;
  -moz-background-size: 2em;
  -o-background-size: 2em;
  -webkit-background-size: 2em;
  background-size: 2em;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  border-radius: 50%;
}
.sy-slide #sli2{position: relative;margin:13px;
  float: right;
  width: 49%;
  text-align: right;}
#featured-products_block_centercs{width:'.$width3.'; float:left; background:none}
csf2{width:27%}
 #center_column .products_block ul li h5 a{font-weight:bolder}
#center_column .products_block ul li:hover{
	 transition: all 1.5s;
	-webkit-box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.52);
-moz-box-shadow:    0px 0px 15px 0px rgba(0, 0, 0, 0.52);
box-shadow:         0px 0px 15px 0px rgba(0, 0, 0, 0.52);
z-index:50;
	 }
#center_column .products_block ul#count li{padding-top:0; transition: all 2s;}
  ul#countdownspecials li{text-align: center;}
 ul#countdownspecials li .img-responsive{display:inherit}
/*.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs div{padding:1; width:100%}*/
 .time_circles > div > h4{padding:0}
.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:'.$listw.'px;
box-shadow:'.$pbs.'; clear:none; margin-top:0;
-webkit-box-shadow:'.$pbs.';
-moz-box-shadow:'.$pbs.';
transition:All 500ms ease;
-webkit-transition:All 500ms ease;
-moz-transition:All 500ms ease;
-o-transition:All 500ms ease;
transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-webkit-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-moz-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-o-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-ms-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
}
.ajax_block_productcs:hover{
	transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-webkit-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-moz-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-o-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-ms-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
z-index:1000;

	}

@media (max-width: 1024px) and (min-width: 992px){
#featured-products_block_centercs{width:100%; float:left; background:none;min-height:458px}
#ajslider{width:100%}
.ajax_block_productcs{width:49%}
}
@media (max-width: 1024px) and (min-width: 768px)
{
		.foohcat{width:300px}
		#csofer h2 {
    font-size: 29px;
    font-weight: bolder;
    margin-top: 0;
    line-height: 29px;
}
#cstop {
    background: url(../img/cat3.jpg) center top;
}
#csofer, #cscount{width:70%}
.examplecat{float:none}
#cstext{width:30%}
#csofer{height:13px}
	.fooh{width:242px}
	.examplep{margin:0 auto; width:135px; height:34px; clear:both}
		#featured-products_block_centercs .time_circles h4{margin-top:0}
		.time_circles > div > span{margin-top: 0.5em;}
		#defaultCountdownhptop{
			 position:relative;
			 margin:0 auto;
color:'.$colort.' ;
font-weight:bold;
height:'.$chptop.'px;
clear:both;
font-family:Arial;
font-size:25px;
width: 250px;

		 }
.hasCountdown, .is-countdown{
margin:0 auto;
color:'.$colort.' ;
font-weight:bold;
background:url(../img/Countdown'.$but.'-r.png) no-repeat center;
padding-left:48px;
padding-top:'.$padding.'px;
height:38px;
clear:both;
font-family:Arial;
font-size:11px;
width: 160px;
bottom: 3px;
left: 0;
right: 0;
		}
		.countdown-section {
	display: block;
	float: left;
	font-size:11px;
	text-align: center;
}
}
@media (max-width: 978px) and (min-width: 601px)
{
			.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:48%;margin-right:1%}

	
	}
@media (max-width: 991px) and (min-width: 200px)
{
	
	.time_circles > div > h4:after{display:none}
#featured-products_block_centercs{width:100%; float:left; background:none;min-height:458px}
#ajslider{display:none}
#fssList{display:none}
#marqueecontainercs{

	position: relative;
	width: 100%; /*marquee width */
}
}
@media (max-width: 767px) and (min-width: 601px)
{
	.foohcat{width:300px}
		#csofer h2 {
    font-size: 29px;
    font-weight: bolder;
    margin-top: 0;
    line-height: 29px;
}
#cstop {
    background: url(../img/cat3.jpg) center top;
}
#csofer, #cscount{width:70%}
.examplecat{float:none}
#cstext{width:30%}
#csofer{height:13px}
.sy-slide {
  min-height: 350px;
}
}
@media (max-width: 600px) and (min-width: 200px)
{
	#csofer h2{font-size:34px}
	#cstext h1{font-size: 18px;line-height: 38px;}
	 #cstext,#csofer,#cscount{width:100%; height:99px}
	   .examplecat{float:none;width:280px}
	   #cstop{background:url(../img/cat2.jpg) center top;}
	 .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
	.sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
	.focl{  position: relative;
  float: left;
  margin-top: 18px;}
		.news-slider .text-content {width:66%}
	.sy-list h4{font-size:13px; clear:both}
	.fooh2{  margin-top: 11px;
 
  position: relative;
  float: left;
  margin-bottom: 10px;}
	.respoima{  width: 60%;}
	.sy-list h1{font-size:20px}
	.sy-list .descs{display:none}
	.sy-list .pricescs{font-size:13px;height: 45px;
  line-height: 24px;}
  .news-slider .text-content{background-color:transparent}
  .sy-slide{min-height: 242px;}
	#informations_block_leftcs{display:none}
	.titletime, .center_column h2.titletime {
line-height: 16px;
height: 30px;
padding-left: 40px;
padding-top: 5px;
padding-bottom: 0px;
font-size: 16px;
}
		.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:99%}

#ajslider{display:none}
#fssList{display:none}
.ajax_block_productcs{width:100%}
.csf{display:none}
csf2{width:40%}
}
                        ');

				fwrite($xml2, '');
				//if (!$errors)
				return $output;

			}
		}

		public function getConfigFieldsValues()
		{
			$fields_values = array(
				'colorp'       => Tools::getValue('colorp', Configuration::get('COUNTDOWNSPECIALS_COLORP')),
					'catcolor'       => Tools::getValue('catcolor', Configuration::get('COUNTDOWNSPECIALS_CATCOLOR')),
					'catcolor2'       => Tools::getValue('catcolor2', Configuration::get('COUNTDOWNSPECIALS_CATCOLOR2')),
	'catw'       => Tools::getValue('catw', Configuration::get('COUNTDOWNSPECIALS_CATW')),
					'respo'       => Tools::getValue('respo', Configuration::get('COUNTDOWNSPECIALS_RESPO')),
					'respop'       => Tools::getValue('respop', Configuration::get('COUNTDOWNSPECIALS_RESPOP')),
					'cront'       => Tools::getValue('cront', Configuration::get('COUNTDOWNSPECIALS_CRONT')),
				'fsp'          => Tools::getValue('fsp', Configuration::get('COUNTDOWNSPECIALS_FSP')),
				'nbr'          => Tools::getValue('nbr', Configuration::get('COUNTDOWNSPECIALS_NBR')),
				'imagesizec'   => Tools::getValue('imagesizec', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEC')),
				'imagesizeh'   => Tools::getValue('imagesizeh', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH')),
				'imagec'       => Tools::getValue('imagec', Configuration::get('COUNTDOWNSPECIALS_IMAGEC')),
				'imageh'       => Tools::getValue('imageh', Configuration::get('COUNTDOWNSPECIALS_IMAGEH')),
				'bordersl'     => Tools::getValue('bordersl', Configuration::get('COUNTDOWNSPECIALS_BORDERSL')),
				'listw'        => Tools::getValue('listw', Configuration::get('COUNTDOWNSPECIALS_LISTW')),
				'rad'          => Tools::getValue('rad', Configuration::get('COUNTDOWNSPECIALS_RAD')),
				'wt'           => Tools::getValue('wt', Configuration::get('COUNTDOWNSPECIALS_WT')),
				'cw'           => Tools::getValue('cw', Configuration::get('COUNTDOWNSPECIALS_CW')),
				'wtb'          => Tools::getValue('wtb', Configuration::get('COUNTDOWNSPECIALS_WTB')),
				'wth'          => Tools::getValue('wth', Configuration::get('COUNTDOWNSPECIALS_WTH')),
				'pbs'          => Tools::getValue('pbs', Configuration::get('COUNTDOWNSPECIALS_PBS')),
				'home6'        => Tools::getValue('home6', Configuration::get('COUNTDOWNSPECIALS_HOME6')),
				'pagination'   => Tools::getValue('pagination', Configuration::get('COUNTDOWNSPECIALS_PAGINATION')),
				'paginationn'  => Tools::getValue('paginationn', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN')),
				'pagination2'  => Tools::getValue('pagination2', Configuration::get('COUNTDOWNSPECIALS_PAGINATION2')),
				'slidercs'     => Tools::getValue('slidercs', Configuration::get('COUNTDOWNSPECIALS_SLIDERCS')),
				'paginationn2' => Tools::getValue('paginationn2', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2')),
				'nbrpage'      => Tools::getValue('nbrpage', Configuration::get('COUNTDOWNSPECIALS_NBRPAGE')),
				'nbrtop'       => Tools::getValue('nbrtop', Configuration::get('COUNTDOWNSPECIALS_NBRTOP')),
				'push'         => Tools::getValue('push', Configuration::get('COUNTDOWNSPECIALS_PUSH')),
				'colortop'     => Tools::getValue('colortop', Configuration::get('COUNTDOWNSPECIALS_COLORTOP')),
				'colorbg'      => Tools::getValue('colorbg', Configuration::get('COUNTDOWNSPECIALS_COLORBG')),
				'widtht'       => Tools::getValue('widtht', Configuration::get('COUNTDOWNSPECIALS_WIDTHT')),
				'heightt'      => Tools::getValue('heightt', Configuration::get('COUNTDOWNSPECIALS_HEIGHTT')),
				'delaycs'      => Tools::getValue('delaycs', Configuration::get('COUNTDOWNSPECIALS_DELAYCS')),
				'nbr2'         => Tools::getValue('nbr2', Configuration::get('COUNTDOWNSPECIALS_NBR2')),
				'sales'        => Tools::getValue('sales', Configuration::get('COUNTDOWNSPECIALS_SALES')),
				'hp'           => Tools::getValue('hp', Configuration::get('COUNTDOWNSPECIALS_HP')),
				'bs'           => Tools::getValue('bs', Configuration::get('COUNTDOWNSPECIALS_BS')),
				'width3h'      => Tools::getValue('width3h', Configuration::get('COUNTDOWNSPECIALS_WIDTH3H')),
				'nbr3'         => Tools::getValue('nbr3', Configuration::get('COUNTDOWNSPECIALS_NBR3')),
				'but'          => Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')),
				'margin'       => Tools::getValue('margin', Configuration::get('COUNTDOWNSPECIALS_MARGIN')),
				'styletime'    => Tools::getValue('styletime', Configuration::get('COUNTDOWNSPECIALS_STYLETIME')),
				'padding'      => Tools::getValue('padding', Configuration::get('COUNTDOWNSPECIALS_PADDING')),
				'colort'        => Tools::getValue('colort', Configuration::get('COUNTDOWNSPECIALS_COLOR')),
				'color2'       => Tools::getValue('color2', Configuration::get('COUNTDOWNSPECIALS_COLOR2')),
				'imagecs'      => Tools::getValue('imagecs', Configuration::get('COUNTDOWNSPECIALS_IMAGECS')),
				'align'        => Tools::getValue('align', Configuration::get('COUNTDOWNSPECIALS_ALIGN')),
				'width'        => Tools::getValue('width', Configuration::get('COUNTDOWNSPECIALS_WIDTH')),
				'width3'       => Tools::getValue('width3', Configuration::get('COUNTDOWNSPECIALS_WIDTH3')),
				'fs'           => Tools::getValue('fs', Configuration::get('COUNTDOWNSPECIALS_FS')),
				'width2'       => Tools::getValue('width2', Configuration::get('COUNTDOWNSPECIALS_WIDTH2')),
				'height'       => Tools::getValue('height', Configuration::get('COUNTDOWNSPECIALS_HEIGHT')),
				'number'       => Tools::getValue('number', Configuration::get('COUNTDOWNSPECIALS_NUMBER')),
				'sort'         => Tools::getValue('sort', Configuration::get('COUNTDOWNSPECIALS_SORT')),
				'enabledp'     => Tools::getValue('enabledp', Configuration::get('COUNTDOWNSPECIALS_ENABLEDP')),
				'disabledp'    => Tools::getValue('disabledp', Configuration::get('COUNTDOWNSPECIALS_DISABLEDP')),
				'cf'           => Tools::getValue('cf', Configuration::get('COUNTDOWNSPECIALS_CF')),
				'grid'         => Tools::getValue('grid', Configuration::get('COUNTDOWNSPECIALS_GRID')),


			);

			return $fields_values;
		}

		public function getImages($type)
		{
			$sql = '
        SELECT *
        FROM '._DB_PREFIX_.'image_type it
        WHERE it.'.(string)$type.' = 1';
			return Db::getInstance()->ExecuteS($sql);
		}

		public function getImagesID($id)
		{
			$sql = '
        SELECT *
        FROM '._DB_PREFIX_.'image_type it
        WHERE it.id_image_type = '.(int)$id.' LIMIT 1';
			return Db::getInstance()->ExecuteS($sql);
		}

		public function uninstall()
		{
			if (parent::uninstall() == false)
				return false;
			if (!Configuration::deleteByName('COUNTDOWNSPECIALS_NBR')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_NBR2')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_MARGIN')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_PADDING')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_STYLETIME')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_NBR3')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_COLOR')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_COLOR2')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_BUT')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH2')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH3')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_HEIGHT')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_ALIGN')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_NUMBER')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_SORT')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_FS')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_ALIGN')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTH3H')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_WIDTHT')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_HEIGHTT')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_DELAYCS')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_IMAGECS')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORTOP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_NBRTOP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_NBRPAGE')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_ENABLEDP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_DISABLEDP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATION')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATIONN')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATION2')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_PAGINATIONN2')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_GRID')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_RAD')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_LISTW')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORBG')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_COLORP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_FSP')
			|| !Configuration::deleteByName('COUNTDOWNSPECIALS_SLIDERCS')
			|| !parent::uninstall())
			return false;
			return true;
		}

		public function getContent()
		{
			$errors = '';
			if (_PS_VERSION_ < '1.6.0.0')
			{
				$output = '<h2>'.$this->displayName.'</h2>
				<script type="text/javascript" src="'.$this->_path.'js/countdownspecials.js"></script>';
				if (Tools::isSubmit('submitDeleteAll'))
		{
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);


			Db::getInstance()->Execute('TRUNCATE '._DB_PREFIX_.'specific_price');
			Db::getInstance()->Execute('TRUNCATE '._DB_PREFIX_.'specific_price_priority');
			$output .= @$errors == '' ? $this->displayConfirmation('All discounts deleted') : @$errors;

		}
				if (Tools::isSubmit('submitDelete'))
				{
					if (_PS_VERSION_ < '1.4.0.0')
					{

						Db::getInstance()->Execute('UPDATE '._DB_PREFIX_.'product 
						SET  '._DB_PREFIX_.'product.`reduction_from` =  \'2011-07-05 09:27:24\',
`reduction_to` =  \'2011-07-05 09:27:24\' WHERE `id_product`='.(int)(Tools::getValue('id_product')));
						$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'));
					}
					if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
					{

						Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'specific_price
						WHERE '._DB_PREFIX_.'specific_price.`id_specific_price`='.(int)(Tools::getValue('id_discount')));
						$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'.Tools::getValue('id_discount')));
					}
					if (_PS_VERSION_ > '1.5.0.0')
					{
						Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'specific_price WHERE
						 '._DB_PREFIX_.'specific_price.`id_specific_price`='.(int)(Tools::getValue('id_discount')).' &&
						  '._DB_PREFIX_.'specific_price.`id_product`='.(int)(Tools::getValue('id_product')));
						$output .= $this->displayConfirmation($this->l('Price Promotion Deleted'));
					}

				}
				if (Tools::isSubmit('submitCountdownSpecials'))
				{
					if (!file_exists('../themes/'._THEME_NAME_.'/img/flipper92.png'))
					{
					$mask = '../modules/countdownspecials/views/img/flipper*.png';
					$fil = glob($mask);	
					foreach ($fil as $fi)
					{
					$fi2 = str_replace('../modules/countdownspecials/views/img/', '', $fi);
					$fi3 = '../themes/'._THEME_NAME_.'/img/'.$fi2;
					//var_dump($fi3);
					if (_PS_VERSION_ > '1.5.5.0')
					Tools::copy($fi, $fi3);
					else
					CountdownSpecials::copy($fi, $fi3);

					}
					}
					$errors       = '';
					$nbr          = Tools::getValue('nbr');
					$hp           = Tools::getValue('hp');
					$wth          = Tools::getValue('wth');
						$cront          = Tools::getValue('cront');
						$respo          = Tools::getValue('respo');
						$respop          = Tools::getValue('respop');
					$pagination   = Tools::getValue('pagination');
					$paginationn  = Tools::getValue('paginationn');
					$pagination2  = Tools::getValue('pagination2');
					$paginationn2 = Tools::getValue('paginationn2');
					$skipcat      = Tools::getValue('skipcat');
					$wt           = Tools::getValue('wt');
					$bs           = Tools::getValue('bs');
					$pbs          = Tools::getValue('pbs');
					$nbr2         = Tools::getValue('nbr2');
					$cw           = Tools::getValue('cw');
					$styletime    = Tools::getValue('styletime');
					$nbr3         = Tools::getValue('nbr3');
					$bordersl     = Tools::getValue('bordersl');
					$color        = '#'.Tools::getValue('color');
					$colort        = '#'.Tools::getValue('color');
					$colorbg      = '#'.Tools::getValue('colorbg');
					$color2       = Tools::getValue('color2');
					$padding      = Tools::getValue('padding');
					$widtht       = Tools::getValue('widtht');
					$heightt      = Tools::getValue('heightt');
					$delaycs      = Tools::getValue('delaycs');
					$imagecs      = Tools::getValue('imagecs');
					$colortop     = '#'.Tools::getValue('colortop');
					$grid         = Tools::getValue('grid');
					$nbrtop       = Tools::getValue('nbrtop');
					$nbrpage      = Tools::getValue('nbrpage');
					$rad          = Tools::getValue('rad');
					$wtb          = Tools::getValue('wtb');
					$push         = Tools::getValue('push');
					$cf           = '#'.Tools::getValue('cf');
					$catw           = '#'.Tools::getValue('catw');
					$listw        = Tools::getValue('listw');
					$slidercs     = Tools::getValue('slidercs');
					$sales        = Tools::getValue('sales');
					$number       = Tools::getValue('number');
					$widthlo      = Tools::getValue('width');
					$width3h      = Tools::getValue('width3h');
					$widthlo3     = Tools::getValue('width3');
					$heightlo     = Tools::getValue('height');
					$widthlo2     = Tools::getValue('widthlo2');
					$align        = Tools::getValue('align');
					$margin       = Tools::getValue('margin');
					$sort         = Tools::getValue('sort');
					$fs           = Tools::getValue('fs');
					$but          = Tools::getValue('but');
					$enabledp     = Tools::getValue('enabledp');
					$disabledp    = Tools::getValue('disabledp');
					$imagesizec   = Tools::getValue('imagesizec');
					$imagesizeh   = Tools::getValue('imagesizeh');
					$imagec       = Tools::getValue('imagec');
					$imageh       = Tools::getValue('imageh');
					$colorp       = '#'.Tools::getValue('colorp');
					$fsp          = Tools::getValue('fsp');
					$catw          = Tools::getValue('catw');
$catcolor          = Tools::getValue('catcolor');
$catcolor2          = Tools::getValue('catcolor2');

if ($but == 11 || $but == 10)
{
$chptop = 0;
$widcspec = '100%';
$mlef = '0%';
}
else
{
$chptop = 38;
$mlef = '-32%';
$widcspec = '0px';
}
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORP', $colorp);
					Configuration::updateValue('COUNTDOWNSPECIALS_CW', $cw);
						Configuration::updateValue('COUNTDOWNSPECIALS_RESPO', $respo);
						Configuration::updateValue('COUNTDOWNSPECIALS_RESPOP', $respop);
					Configuration::updateValue('COUNTDOWNSPECIALS_WT', $wt);
					Configuration::updateValue('COUNTDOWNSPECIALS_CATW', $catw);
					Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR', $catcolor);
					Configuration::updateValue('COUNTDOWNSPECIALS_CATCOLOR2', $catcolor2);
					Configuration::updateValue('COUNTDOWNSPECIALS_CF', $cf);
					Configuration::updateValue('COUNTDOWNSPECIALS_WTB', $wtb);
					Configuration::updateValue('COUNTDOWNSPECIALS_BS', $bs);
					Configuration::updateValue('COUNTDOWNSPECIALS_PUSH', $push);
					Configuration::updateValue('COUNTDOWNSPECIALS_FSP', $fsp);
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR', $nbr);
					Configuration::updateValue('COUNTDOWNSPECIALS_CRONT', $cront);
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEC', $imagesizec);
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGESIZEH', $imagesizeh);
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEC', $imagec);
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGEH', $imageh);
					Configuration::updateValue('COUNTDOWNSPECIALS_LISTW', $listw);
					Configuration::updateValue('COUNTDOWNSPECIALS_RAD', $rad);
					Configuration::updateValue('COUNTDOWNSPECIALS_SALES', $sales);
					Configuration::updateValue('COUNTDOWNSPECIALS_WTH', $wth);
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION', $pagination);
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN', $paginationn);
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATION2', $pagination2);
					Configuration::updateValue('COUNTDOWNSPECIALS_SLIDERCS', $slidercs);
					Configuration::updateValue('COUNTDOWNSPECIALS_PAGINATIONN2', $paginationn2);
					Configuration::updateValue('COUNTDOWNSPECIALS_NBRPAGE', $nbrpage);
					Configuration::updateValue('COUNTDOWNSPECIALS_NBRTOP', $nbrtop);
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORTOP', $colortop);
					Configuration::updateValue('COUNTDOWNSPECIALS_COLORBG', $colorbg);
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTHT', $widtht);
					Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHTT', $heightt);
					Configuration::updateValue('COUNTDOWNSPECIALS_DELAYCS', $delaycs);
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR2', $nbr2);
					Configuration::updateValue('COUNTDOWNSPECIALS_HP', $hp);
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3H', $width3h);
					Configuration::updateValue('COUNTDOWNSPECIALS_NBR3', $nbr3);
					Configuration::updateValue('COUNTDOWNSPECIALS_BUT', $but);
					Configuration::updateValue('COUNTDOWNSPECIALS_MARGIN', $margin);
					Configuration::updateValue('COUNTDOWNSPECIALS_STYLETIME', $styletime);
					Configuration::updateValue('COUNTDOWNSPECIALS_PADDING', $padding);
					Configuration::updateValue('COUNTDOWNSPECIALS_COLOR', $color);
					Configuration::updateValue('COUNTDOWNSPECIALS_COLOR2', $color2);
					Configuration::updateValue('COUNTDOWNSPECIALS_IMAGECS', $imagecs);
					Configuration::updateValue('COUNTDOWNSPECIALS_BORDERSL', $bordersl);
					Configuration::updateValue('COUNTDOWNSPECIALS_ALIGN', $align);
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH', $widthlo);
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH3', $widthlo3);
					Configuration::updateValue('COUNTDOWNSPECIALS_FS', $fs);
					Configuration::updateValue('COUNTDOWNSPECIALS_PBS', $pbs);
					Configuration::updateValue('COUNTDOWNSPECIALS_WIDTH2', $widthlo2);
					Configuration::updateValue('COUNTDOWNSPECIALS_HEIGHT', $heightlo);
					Configuration::updateValue('COUNTDOWNSPECIALS_NUMBER', $number);
					Configuration::updateValue('COUNTDOWNSPECIALS_SORT', $sort);
					Configuration::updateValue('COUNTDOWNSPECIALS_ENABLEDP', $enabledp);
					Configuration::updateValue('COUNTDOWNSPECIALS_DISABLEDP', $disabledp);
					Configuration::updateValue('COUNTDOWNSPECIALS_GRID', $grid);

					$ht   = $wt * 60 / 275;
					$htc  = $wt * 100 / 400;
					$htb  = $wtb * 100 / 400;
					$hth  = $wth * 100 / 400;
						$hthw  = $catw * 100 / 400;
					$xml2 = fopen('../modules/countdownspecials/views/css/'.((_PS_VERSION_ > '1.5.0.0') ?
					$this->context->shop->id : '').'jquery.countdown.css', 'w');
if ($styletime == 1)
{
$styl = '45';
$styl2 = '';
}
else
{
$styl = '7';
$styl2 = 'text-align:center;';
}
if ($respop == 1)
$widthlo3 = '100%';
if (_PS_VERSION_ > '1.6.0.0')
$hascon = '189px';
else
$hascon = '149px';

					fwrite($xml2, '
					
					
						
						
	#cstop{width:100%; clear:both; margin:0 auto; background: url(../img/cat.jpg) center top;position:relative; float:left;display: table; height:95px}
 #cstext{width:30%; position:relative; float:left; text-align:center;display: table-cell; vertical-align: middle; line-height:95px}
 #cstext h1{font-size: 20px; font-weight: bolder;color:white; margin-top:0;line-height: 43px;text-shadow: 2px 2px 2px rgba(0, 0, 0, 1);}
	#csofer h2{font-size: 53px;     color: white;
    font-weight: bolder;margin-top:0;line-height: 95px;   text-shadow: 2px 2px 2px rgba(0, 0, 0, 1);}
 #csofer{width:37%; position:relative; float:left; text-align:center;display: table-cell; vertical-align: middle;}
 #cscount{width:33%; position:relative; float:left;margin-top:15px}
/* kenBurns animations, very basic */
@-webkit-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-moz-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-ms-keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@keyframes left-right {
  0% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); }
  100% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); } }
@-webkit-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@-moz-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@-ms-keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
@keyframes right-left {
  0% {
    -moz-transform: translateY(0%) translateX(10%);
    -ms-transform: translateY(0%) translateX(10%);
    -webkit-transform: translateY(0%) translateX(10%);
    transform: translateY(0%) translateX(10%); }
  100% {
    -moz-transform: translateY(-20%) translateX(-10%);
    -ms-transform: translateY(-20%) translateX(-10%);
    -webkit-transform: translateY(-20%) translateX(-10%);
    transform: translateY(-20%) translateX(-10%); } }
/* added to the original element calling slippry */
.sy-box.sy-loading {
  background: url("../img/sy-loader.gif") 50% 50% no-repeat;
  -moz-background-size: 32px;
  -o-background-size: 32px;
  -webkit-background-size: 32px;
  background-size: 32px;
  min-height: 40px; }
  .sy-box.sy-loading .sy-slides-wrap, .sy-box.sy-loading .sy-pager {
    visibility: hidden; }

/* element that wraps the slides */
.sy-slides-wrap {
  position: relative;
 
  box-shadow:'.$bs.';
-moz-box-shadow: '.$bs.';
-webkit-box-shadow:'.$bs.';
  border:'.$bordersl.';
  background:url(../img/back.png) repeat-x '.$colortop.';min-height:298px;

  width: 100%; }
  .sy-slides-wrap:hover .sy-controls {
    display: block; }

/* element that crops the visible area to the slides */
.sy-slides-crop {
  height: 100%;
  width: 100%;
  position: absolute;
  overflow: hidden; }

/* list containing the slides */
.sy-list {
  width: 100%;
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
  position: absolute; }
  .sy-list.horizontal {
    -moz-transition: left ease;
    -o-transition: left ease;
    -webkit-transition: left ease;
    transition: left ease; }
  .sy-list.vertical {
    -moz-transition: top ease;
    -o-transition: top ease;
    -webkit-transition: top ease;
    transition: top ease; }

/* single slide */
.sy-slide {
	min-height:322px;
  position: absolute;
  width: 100%;
  z-index: 2; }
  .sy-slide.kenburns {
    width: 140%;
    left: -20%; }
    .sy-slide.kenburns.useCSS {
      -moz-transition-property: opacity;
      -o-transition-property: opacity;
      -webkit-transition-property: opacity;
      transition-property: opacity; }
      .sy-slide.kenburns.useCSS.sy-ken:nth-child(1n) {
        -webkit-animation-name: left-right;
        -webkit-animation-fill-mode: forwards;
        -moz-animation-name: left-right;
        -moz-animation-fill-mode: forwards;
        -o-animation-name: left-right;
        -o-animation-fill-mode: forwards;
        animation-name: left-right;
        animation-fill-mode: forwards; }
      .sy-slide.kenburns.useCSS.sy-ken:nth-child(2n) {
        -webkit-animation-name: right-left;
        -webkit-animation-fill-mode: forwards;
        -moz-animation-name: right-left;
        -moz-animation-fill-mode: forwards;
        -o-animation-name: right-left;
        -o-animation-fill-mode: forwards;
        animation-name: right-left;
        animation-fill-mode: forwards; }
  .sy-slide.sy-active {
    z-index: 3; }
  .sy-slide > img {
    margin: 0;
    padding: 0;
    display: block;
    width: 100%;
    border: 0; }
  .sy-slide > a {
    margin: 0;
    padding: 0;
    display: block;
    width: 100%; }
    .sy-slide > a > img {
      margin: 0;
      padding: 0;
      display: block;
      width: 100%;
      border: 0; }

/* next/ prev buttons, with arrows and clickable area a lot larger than the visible buttons */
.sy-controls {
  display: none;
  list-style: none;
  height: 100%;
  width: 100%;
  position: absolute;
  padding: 0;
  margin: 0; }
  .sy-controls li {
    position: absolute;
    width: 10%;
    min-width: 4.2em;
    height: 100%;
    z-index: 33; }
    .sy-controls li.sy-prev {
      left: 0;
      top: 0; }
      .sy-controls li.sy-prev a:after {
        background-position: -5% 0; }
    .sy-controls li.sy-next {
      right: 0;
      top: 0; }
      .sy-controls li.sy-next a:after {
        background-position: 105% 0; }
    .sy-controls li a {
      position: relative;
      width: 100%;
      height: 100%;
      display: block;
      text-indent: -9999px; }
      .sy-controls li a:link, .sy-controls li a:visited {
        opacity: 0.4; }
      .sy-controls li a:hover, .sy-controls li a:focus {
        opacity: 0.8;
        outline: none; }
      .sy-controls li a:after {
        content: "";
        background-image: url("../img/arrows.svg");
        background-repeat: no-repeat;
        -moz-background-size: cover;
        -o-background-size: cover;
        -webkit-background-size: cover;
        background-size: cover;
        text-align: center;
        text-indent: 0;
        line-height: 2.8em;
        color: #111;
        font-weight: 800;
        position: absolute;
        background-color: #fff;
        width: 2.8em;
        height: 2.8em;
        left: 50%;
        top: 50%;
        margin-top: -1.4em;
        margin-left: -1.4em;
        -moz-border-radius: 50%;
        -webkit-border-radius: 50%;
        border-radius: 50%; }
		.sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
 .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
  #featured-products_block_centercs .col-md-4, #featured-products_block_centercs .col-md-3{padding-left:15px; padding-right:15px}
  #count img{border:1px solid #ccc}
  @media only screen and (max-device-width: 600px) {
	   #cstext,#csofer,#cscount{width:100%; height:99px}
	   .examplecat{float:none; width:280px}
	   #cstop{background:url(../img/cat2.jpg) center top;}
    .sy-controls {
      display: block; }
      .sy-controls li {
        min-width: 2.1em; }
        .sy-controls li a:after {
          width: 1.4em;
          height: 1.4em;
          margin-top: -0.7em;
          margin-left: -0.7em; } }

/* captions, styled fo the overlay variant */
.sy-caption-wrap {
  position: absolute;
  bottom: 2em;
  z-index: 12;
  left: 50%; }
  .sy-caption-wrap .sy-caption {
    position: relative;
    left: -50%;
    background-color: rgba(0, 0, 0, 0.54);
    color: #fff;
    padding: 0.4em 1em;
    -moz-border-radius: 1.2em;
    -webkit-border-radius: 1.2em;
    border-radius: 1.2em; }
    .sy-caption-wrap .sy-caption a:link, .sy-caption-wrap .sy-caption a:visited {
      color: #e24b70;
      font-weight: 600;
      text-decoration: none; }
    .sy-caption-wrap .sy-caption a:hover, .sy-caption-wrap .sy-caption a:focus {
      text-decoration: underline; }
  @media only screen and (max-device-width: 600px), screen and (max-width: 768px) {
	  
	   .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
	  .sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
    .sy-caption-wrap {
      left: 0;
      bottom: 0.4em; }
      .sy-caption-wrap .sy-caption {
        left: 0;
        padding: 0.2em 0.4em;
        font-size: 0.92em;
        -moz-border-radius: 0;
        -webkit-border-radius: 0;
        border-radius: 0; } }

/* pager bubbles */
.sy-pager {
  overflow: hidden;
  *zoom: 1;
  display: block;
  width: 100%;
  margin: 1em 0 0;
  padding: 0;
  list-style: none;
  text-align: center; }
  .sy-pager li {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    margin: 0 1em 0 0;
    -moz-border-radius: 50%;
    -webkit-border-radius: 50%;
    border-radius: 50%; }
    .sy-pager li.sy-active a {
      background-color: #e24b70; }
    .sy-pager li a {
      width: 100%;
      height: 100%;
      display: block;
      background-color: #ccc;
      text-indent: -9999px;
      -moz-background-size: 2em;
      -o-background-size: 2em;
      -webkit-background-size: 2em;
      background-size: 2em;
      -moz-border-radius: 50%;
      -webkit-border-radius: 50%;
      border-radius: 50%; }
      .sy-pager li a:link, .sy-pager li a:visited {
        opacity: 1.0; }
      .sy-pager li a:hover, .sy-pager li a:focus {
        opacity: 0.6; }

/* element to "keep/ fill" the space of the content, gets intrinsic height via js */
.sy-filler {
  width: 100%; }
  .sy-filler.ready {
    -moz-transition: padding 600ms ease;
    -o-transition: padding 600ms ease;
    -webkit-transition: padding 600ms ease;
    transition: padding 600ms ease; }

					/* News */
.news-slider {clear:both
  /* Style the actual content */
}
.sy-list h1{margin-top:0}
.news-slider .text-content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 1em;
  width: 49%;
  height: 100%;
}
.news-slider .text-content h2 {
  margin: 0; background:none
}
.news-slider .text-content p {
  margin: 0.5em 0; padding-bottom:5px
}
.news-slider .text-content a.button-link {
  padding: 0.25em 0.5em;
  position: absolute;
  bottom: 1em;
  right: 1em;
}
.news-slider .image-content {
  line-height: 0;
}
.news-slider .image-content img {
  max-width: 100%;
}
.news-slider .news-pager {
  text-align: right;
  display: block;
  margin: 0.2em 0 0;
  padding: 0;
  list-style: none;
}
.news-slider .news-pager li {
  display: inline-block;
  padding: 0.6em;
  margin: 0 0 0 1em;
}
.news-slider .news-pager li.sy-active a {
  color: #31ace2;
}
.news-slider .news-pager li a {
  font-weight: 500;
  text-decoration: none;
  display: block;
  color: #222;
}
					.is-countdown {
	/*border: 1px solid #ccc;
	background-color: #eee;*/
	text-align:left;
}
.countdown-rtl {
	direction: rtl;
}
.countdown-holding span {
	/*color: #888;*/
}
.countdown-row {
	clear: both;
	width: 100%;
	padding: 0px 2px;
	text-align: center;
}
.countdown-show1 .countdown-section {
	width: 98%;
}
.countdown-show2 .countdown-section {
	width: 48%;
}
.countdown-show3 .countdown-section {
	width: 25.5%;
}
.countdown-show4 .countdown-section {
	width: 20.5%;
}
.countdown-show5 .countdown-section {
	width: 19.5%;
}
.countdown-show6 .countdown-section {
	width: 16.25%;
}
.countdown-show7 .countdown-section {
	width: 14%;
}
.countdown-section {
	display: block;
	float: left;
	font-size:'.$fs.';
	text-align: center;
}
#defaultCountdownhptop .countdown-amount{color:'.$catcolor2.'}

.countdown-amount {
   /*font-size: 110%;*/
}
.countdown-period {
    display: block;
	line-height:7px;
}
.countdown-descr {
	display: block;
	width: 100%;
}

					.cspec2{width:'.$widcspec.'; left:'.$mlef.';position:relative;float:left ;z-index:500}}
				.wrappercs {

border-radius: 10px;
-webkit-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
box-shadow: 0px 0px 8px rgba(0,0,0,0.3);
position: relative;
z-index: 90;
}

.ribbon-wrapper-green {
width: 85px;
height: 88px;
overflow: hidden;
position: absolute;
top: -11px;
right: -11px;
}

.ribbon-green {
font: bold 9px Sans-Serif;
color: #333;
text-align: center;
-webkit-transform: rotate(45deg);
-moz-transform: rotate(45deg);
-ms-transform: rotate(45deg);
-o-transform: rotate(45deg);
position: relative;
padding: 7px 0;
left: -5px;
top: 15px;
width: 131px;
background-color: #BFDC7A;
background-image: -webkit-gradient(linear, left top, left bottom, from(#BFDC7A), to(#8EBF45));
background-image: -webkit-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -moz-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -ms-linear-gradient(top, #BFDC7A, #8EBF45);
background-image: -o-linear-gradient(top, #BFDC7A, #8EBF45);
color: #6a6340;
-webkit-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
-moz-box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
box-shadow: 0px 0px 3px rgba(0,0,0,0.3);
box-shadow:3px 1px 2px 0px #000;
}

.ribbon-green:before, .ribbon-green:after {
content: "";
border-top: 3px solid #6e8900;
border-left: 3px solid transparent;
border-right: 3px solid transparent;
position:absolute;
bottom: -3px;
}

.ribbon-green:before {
left: 0;
}
.ribbon-green:after {
right: 0;
}
				/**
 *	This element is created inside your target element
 *	It is used so that your own element will not need to be altered
 **/
.time_circles {
    position: relative;
    width: 100%;
    height: 100%;
}

/**
 *	This is all the elements used to house all text used
 * in time circles
 **/
.time_circles > div {
    position: absolute;
    text-align: center;
}

/**
 *	Titles (Days, Hours, etc)
 **/
.time_circles > div > h4, #left_column .time_circles > div > h4,#right_column .time_circles > div > h4 {
box-shadow:none;-moz-box-shadow:none; -webkit-box-shadow:none;
    margin: 0px;height:auto;
    padding: 0px;
    text-align: center;
    text-transform: uppercase;
	font-weight:bolder;
   /* font-family: \'Century Gothic\', Arial;*/
	color:'.$color.';
		border:none;
	background:transparent
}

/**
 *	Time numbers, ie: 12
 **/
#cscount .time_circles > div > span,#cscount .time_circles > div > h4, #cscount .is-countdown{color:'.$catcolor.'}
.time_circles > div > span {
    display: block;
    width: 100%;
    text-align: center;
    font-family: \'Century Gothic\', Arial;
    font-size: 300%;
    margin-top: 0.4em;
    font-weight: bold;color:'.$color.'
}
.focl{margin:0 auto; width:'.$wt.'px}
.fooc{margin:0 auto; width:'.$wtb.'px}
.fooh{margin:0 auto; width:'.$wth.'px}
.foohcat{margin:0 auto; width:'.$catw.'px}
.fooh2{margin:0 auto; width:'.$wt.'px}
.foohh{margin:0 auto; width:'.$wth.'px}
.foop{margin:0 auto; width:200px}
.fool{margin:0 auto; width:200px}
.examplet{margin:0 auto; width:'.$wt.'px; height:'.$htc.'px; clear:both}
.examplec{margin:0 auto; width:'.$wtb.'px; height:'.$htb.'px; clear:both}
.examplep{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both}
.examplepp{margin:0 auto; width:230px; clear:both}
.exampleh{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both;}
.examplecat{margin:0 auto; width:'.$catw.'px; height:'.$hthw.'px; clear:both;float:right}

.examplel{margin:0 auto; width:210px; clear:both}
.examplehh{margin:0 auto; width:'.$wth.'px; height:'.$hth.'px; clear:both}
/**/

#fssListc {
list-style: none;
width: 646px;
/* margin: auto; */
/* padding: 5px 0 0 45%; */
margin-top: -50px;
position: relative;
float: left;
margin-left: 11px;
}
#fssListc li {
display: inline;
border-radius: 55%;
/* width: 36px; */
/* height: 3px; */
padding: 3px 6px 3px 6px;
background: #fff;
border: 2px solid #666;
color: #666;
text-align: center;
margin: 3px;
/* line-height: 10px; */
}
#fssListc li.fssActivec a{/* background: #ddd; */
font-weight: bold;
color: red;}
/**/
#fssList {
list-style: none;
width: 646px;
/* margin: auto; */
/* padding: 5px 0 0 45%; */
margin-top: -40px;
position: relative;
float: left;
margin-left: 11px;
}
#fssList li {
display: inline;

/* width: 36px; */
/* height: 3px; */

margin:3px  13px 3px 3px; position:relative;float:left;; width:15px
/* line-height: 10px; */
}
#fssList li.fssActive a{/* background: #ddd; */
font-weight: bold; text-decoration:none;
color: red;
padding: 3px 6px 3px 6px;
background: #fff;
border: 2px solid #666;

border-radius: 55%;
text-align: center;}
.descs{min-height: 27px;
  position: relative;
  float: left;margin:0 auto}
.cscart{margin:0 auto; float:left; width:100%; text-align:center; margin-top:5px;margin-bottom:5px}
.cscart .ajax_add_to_cart_button {

border: 2px solid #ccc;
padding: 6px 23px;
margin-top: -4px;
position: relative;
clear: both;
min-height: 28px;
line-height: 27px;
border-radius: 5px;
  background: url(../img/atc.jpg) right top;
  color: white;
}
.cscart .ajax_add_to_cart_button:hover
{
  border: 2px solid #999;
    background: url(../img/atc2.jpg) right top;
}
/**/
#ajsliderc {
margin: 10px 0 10px 0;
border:'.$bordersl.';
position:relative;
float:left
}
#ajsliderc .s {
background:url(../img/back.png) repeat-x '.$colortop.';
padding:10px;
text-align: center;
}
.sy-list h4{text-align:center}
.sy-list .pricescs{font-size:21px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%; height:87px;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 67px;}
#ajsliderc .s h1 { background-image:none; font-size:18px;    margin: 1px 2px;}
#ajsliderc .s .pricescs {
font-size:25px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%; height:87px;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 87px;
}
	#slic1{position: relative; float:left; width:60%}
	#slic2{position: relative; float:left; width:39%}
/**/
#ajslider {
margin: 10px 0 10px 0;
border:'.$bordersl.';
box-shadow:'.$bs.';
-moz-box-shadow: '.$bs.';
-webkit-box-shadow:'.$bs.';
position:relative;
float:left

}
#ajslider .s {
background:url(../img/back.png) repeat-x '.$colortop.';
padding:10px;
text-align: center;
}
#ajslider .s h1 { background-image:none; font-size:18px;overflow:hidden;margin-top:1px}
#ajslider .s .pricescs {margin-bottom:10px;
font-size:17px;
 color:#fff;
 font-weight:bolder;
 background:url(../img/fire.png) no-repeat center;
 width:100%;
 padding:inherit;
 text-align:center;
 height:87px;
line-height: 87px;
 }
 #defaultCountdownhptop .countdown-amount{color:'.$catcolor2.'}

 .countdown-amount{margin:0 auto;
color:'.$color.' ;
font-weight:bold;height:38px;}
#defaultCountdownhptop{
			 margin:0 auto;
			  position:relative;
color:'.$colort.' ;
font-weight:bold;
height:'.$chptop.'px;

clear:both;
font-family:Arial;
font-size:25px;
width: 250px;

		 }
.hasCountdown, .is-countdown {
position:absolute;
margin:0 auto;
color:'.$color.' ;
font-weight:bold;
background:url(../img/Countdown'.$but.'.png) no-repeat center;
padding-left:48px;
padding-top:'.$padding.'px;
height:38px;
clear:both;
font-family:Arial;
font-size:12px;
width: '.$hascon.';
bottom: 3px;
left: 0;
right: 0;
}
.price_container{
text-align:center
}
.exclusive ajax_add_to_cart_button
{text-align:center; margin:0 auto}
#featured-products_block_centercs h2, #featured-products_block_centercs h3, #featured-products_block_centercs h4
{
padding: 2px 0 0 40px;
}
#featured-products_block_centercs .time_circles  h4, #center_column #featured-products_block_centercs .time_circles  h4{padding:0; margin-top:-4px;background: none;border:none;text-align:center;
  color: '.$color.';box-shadow:none;
  -moz-box-shadow:none; 
  -webkit-box-shadow:none;
  height: inherit;}
.countdown_rtl {
direction: rtl;
}

.countdown_holding span {
background-color: #ccc;
}

.countdown_row {
display:inline;
clear: both;
float:left;
width: 100%;
//margin-left:30px;
padding:1px 0 0 '.$styl.'px;
'.$styl2.'
//text-align: center;
line-height:14px;
width:200px
}
.countdown_show1 .countdown_section {
width: 33px;
color:'.$color.' ;
}

.countdown_show2 .countdown_section {
width: 33px;
color:'.$color.' ;
}

.countdown_show3 .countdown_section {
width: 33px;
color:'.$color.' ;

}

.countdown_show4 .countdown_section {
width: 29px;
color:'.$color.' ;
}
.countdown_show5 .countdown_section {
width: 19.5%;
color:'.$color.' ;
}
.countdown_show6 .countdown_section {
width: 16.25%;


color:'.$color.' ;
}
.countdown_show7 .countdown_section {
width: 14%;
color:'.$color.' ;
}

.hasCountdown .countdown_section,.countdown_section{
display: block;
float: left;
font-size: 75%;
text-align: center;
font-weight:normal;
line-height:15px
}
.hasCountdown .countdown_amount, .countdown_amount  {
font-size:'.$fs.';
line-height:14px
}
.countdown_descr {
display: block;
width: 100%;
}
#marqueecontainercs{
position: relative;
width: '.$widthlo.'; /*marquee width */
height: '.$heightlo.'px; /*marquee height */
overflow: hidden;
/*border: 3px solid orange;*/
}
/* Container DIV - automatically generated */

.titletime, .center_column h2.titletime{
line-height:46px;
background:url(../img/title.png) no-repeat left center;
height:46px;
padding-left:40px; padding-top:0px; padding-bottom:0px; font-size:23px;text-transform:capitalize}
.dash {
float: left;
position: relative;
}
.dash .digit {
font-weight: bold;
float: left;
text-align: center;
position: relative;
}
.dash_title {
position: absolute;
display: block;
bottom: 0px;
right: 6px;
font-size: 9pt;
color: #555;
text-transform: uppercase;
letter-spacing: 2px;
}
.dev_comment {
font-size: 14pt;
color: #777;
text-align: center;
font-style: italic;
margin: 40px 10px;
}
#subscribe_form {
position: relative;
}
#email_field {
font-size: 16pt;
padding: 6px 10px;
width: 300px;
}
.copyright {
font-size: 9pt;
color: #333;
margin: 40px 0px;
}
.faded {
color: #999;
}
.form_message {
width: 400px;
padding: 10px;
margin: 15px auto;
display: none;
}
#error_message {
background-color: #ffe;
border-left: 5px solid #bb3;
border-right: 5px solid #bb3;
color: #770;
}
#info_message {
background-color: #f0f9ff;
border: 1px solid #eef;
}
#loading {
text-align: center;
margin: 10px;
display: none;
position: absolute;
width: 100%;
top: 60px;
}
	#short_description_blockcd .is-countdown{text-align:left}
#short_description_blockcd{
background: #ffffff;
position: relative; clear:both;
border: solid 1px #D0D3D8;
margin-bottom: 1.5em;
padding: 0.7em;
margin-top: 1.5em;
text-align:center;
min-height:102px;
min-width:195px

}
	.sy-pager li.sy-active a {
  background-color: red;
}
.sy-pager li a {
  width: 100%;
  height: 100%;
  display: block;
  background-color: #ccc;
  text-indent: -9999px;
  -moz-background-size: 2em;
  -o-background-size: 2em;
  -webkit-background-size: 2em;
  background-size: 2em;
  -moz-border-radius: 50%;
  -webkit-border-radius: 50%;
  border-radius: 50%;
}
#cd{
background-image:url(../img/icon.png);
background-repeat:no-repeat;
width:64px;
height:37px;
text-align:center;
padding-top:27px;margin:0 auto;
color:#000
}
#cd span{
color:#fff
}
#sli1{position: relative:; float:left; width:60%}
#sli2{position: relative:; float:left; width:39%}
.sy-slide #sli2{position: relative;margin:13px;
  float: right;
  width: 49%;
  text-align: right;}
#featured-products_block_centercs{width:'.$widthlo3.'; float:left; background:none}
csf2{width:27%}
 #center_column .products_block ul li h5 a{font-weight:bolder}
 ul#countdownspecials li{text-align: center;}
 ul#countdownspecials li .img-responsive{display:inherit}
 #center_column .products_block ul#count li{padding-top:0;transition: all 2s;}
 #center_column .products_block ul li:hover{
	transition: all 1.5s;
	-webkit-box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.52);
-moz-box-shadow:    0px 0px 15px 0px rgba(0, 0, 0, 0.52);
box-shadow:         0px 0px 15px 0px rgba(0, 0, 0, 0.52);z-index:50;
	 }
/*.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs div{padding:1; width:100%}*/

.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs .price{padding:3px}
.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:'.$listw.'px;
box-shadow:'.$pbs.';clear:none; margin-top:0;
-webkit-box-shadow:'.$pbs.';
-moz-box-shadow:'.$pbs.';
transition:All 500ms ease;
-webkit-transition:All 500ms ease;
-moz-transition:All 500ms ease;
-o-transition:All 500ms ease;
transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-webkit-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-moz-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-o-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
-ms-transform: rotate(0deg) scale(1) skew(0deg) translate(0px);
}
.ajax_block_productcs:hover{
	transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-webkit-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-moz-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-o-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
-ms-transform: rotate(0deg) scale(1.05) skew(0deg) translate(0px);
z-index:1000;

	}
@media (max-width: 1024px) and (min-width: 992px){
#featured-products_block_centercs{width:100%; float:left; background:none}
#ajslider{width:100%}
.ajax_block_productcs{width:49%}
}
@media (max-width: 1024px) and (min-width: 768px)
{
		.foohcat{width:300px}
		#csofer h2 {
    font-size: 29px;
    font-weight: bolder;
    margin-top: 0;
    line-height: 29px;
}
#cstop {
    background: url(../img/cat3.jpg) center top;
}
#csofer, #cscount{width:70%}
.examplecat{float:none}
#cstext{width:30%}
#csofer{height:13px}
	.fooh{width:242px}
	.time_circles > div > span{margin-top: 0.5em;}
		.examplep{margin:0 auto; width:135px; height:34px; clear:both}
		#featured-products_block_centercs .time_circles h4{margin-top:0}
		#defaultCountdownhptop{
			 margin:0 auto;
			 position:relative;
color:'.$colort.' ;
font-weight:bold;
height:'.$chptop.'px;
clear:both;
font-family:Arial;
font-size:25px;
width: 250px;

		 }
.hasCountdown, .is-countdown{
margin:0 auto;
color:'.$color.' ;
font-weight:bold;
background:url(../img/Countdown'.$but.'-r.png) no-repeat center;
padding-left:48px;
padding-top:'.$padding.'px;
height:38px;
clear:both;
font-family:Arial;
font-size:11px;
width: 160px;
bottom: 3px;
left: 0;
right: 0;
		}
			.countdown-section {
	display: block;
	float: left;
	font-size:11px;
	text-align: center;
}
}
@media (max-width: 978px) and (min-width: 601px)
{
			.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:48%; margin-right:1%}

	
	}
@media (max-width: 991px) and (min-width: 200px)
{.time_circles > div > h4:after{display:none}

	#fssList{display:none}
	
#featured-products_block_centercs{width:100%; float:left; background:none}
#ajslider{display:none}
#marqueecontainercs{
position: relative;
width: 100%; /*marquee width */
}
}
@media (max-width: 767px) and (min-width: 601px)
{
	.foohcat{width:300px}
	#cstop {
    background: url(../img/cat3.jpg) center top;
}
.examplecat{float:none}
	#cstext{width:30%}
	#csofer h2 {
    font-size: 29px;
    font-weight: bolder;
    margin-top: 0;
    line-height: 29px;
}
	#csofer, #cscount{width:70%}
#csofer{height:13px}
.sy-slide {
  min-height: 350px;
}
}
@media (max-width: 600px) and (min-width: 200px)
{
	#csofer h2{font-size:34px}
	#cstext h1{font-size: 18px;line-height: 38px;}
	 #cstext,#csofer,#cscount{width:100%; height:99px}
	   .examplecat{float:none;width:280px}
	   #cstop{background:url(../img/cat2.jpg) center top;}
	 .sy-slide .atc{margin:0 auto; text-align:center; width:100%}
	.sy-slide #slic2 {
  position: relative;
  margin: 13px;
  float: right;
  width: 49%;
  text-align: right;
}
	.focl{  position: relative;
  float: left;
  margin-top: 18px;}
		.news-slider .text-content {width:66%}
	.sy-list h4{font-size:13px; clear:both}
	.fooh2{  margin-top: 11px;

  position: relative;
  float: left;
  margin-bottom: 10px;}
	.news-slider .text-content {width:66%}
	.sy-list h4{font-size:13px}
		.respoima{  width: 60%;}
	.sy-list h1{font-size:20px}
	.sy-list .descs{display:none}
	.sy-list .pricescs{font-size:13px;height: 45px;
  line-height: 24px;}
  .sy-slide{min-height: 242px;}
  .news-slider .text-content{background-color:transparent}
		#informations_block_leftcs{display:none}

	.titletime, .center_column h2.titletime {
line-height: 16px;
height: 30px;
padding-left: 40px;
padding-top: 5px;
padding-bottom: 0px;
font-size: 16px;
}
	#fssList{display:none}
	.ajax_block_productcs, #center_column .products_block ul .ajax_block_productcs{width:99%}
#ajslider{display:none}
.ajax_block_productcs{width:100%}
.csf{display:none}
csf2{width:40%}
}


');

					fwrite($xml2, '');

					if (!empty($skipcat))
						Configuration::updateValue('COUNTDOWNSPECIALS_SKIP_CAT', implode(',', $skipcat));
					if ($errors)
						$output .= $this->displayError(implode('<br />', $errors));
					else
						$output .= $this->displayConfirmation($this->l('Settings updated'));

				}

				return $output.$this->displayForm();
			}

			else
				return $this->postProcess().$this->_displayInfo().$this->renderForm().$this->_displayAdds();
		}

		public function paginate_one($reload, $page, $tpages)
		{
			$firstlabel = $this->l('First');
			$prevlabel  = $this->l('Prev');
			$nextlabel  = $this->l('Next');
			$lastlabel  = $this->l('Last');

			$out = '<div class="pagin">';

			$reload2 = preg_replace('/&page=[0-9]/', '', $reload);

			// first

			if ($page > 1)
				$out .= '<a href="'.$reload2.'">'.$firstlabel.'</a>';
			else
				$out .= '<span>'.$firstlabel.'</span> ';

			// previous

			if ($page == 1)
				$out .= '<span>'.$prevlabel.'</span> ';
			elseif ($page == 2)
				$out .= '<a href="'.$reload2.'">'.$prevlabel.'</a>';
			else
				$out .= '<a href="'.$reload2.'&amp;page='.($page - 1).'">'.$prevlabel.'</a>';

			// current
			$out .= '<span class="current">'.$this->l('Page').' '.$page.' of '.$tpages.'</span> ';


			// next
			if ($page < $tpages)
				$out .= '<a href="'.$reload2.'&amp;page='.($page + 1).'">'.$nextlabel.'</a>';
			else
				$out .= '<span>'.$nextlabel.'</span> ';
			// last

			if ($page < $tpages)
				$out .= '<a href="'.$reload2.'&amp;page='.$tpages.'">'.$lastlabel.'</a>';
			else
				$out .= '<span>'.$lastlabel.'</span> ';

			$out .= '</div>';
			return $out;

		}

		public function paginate_two($reload, $page, $tpages)
		{
			$firstlabel = $this->l('First');
			$prevlabel  = $this->l('Prev');
			$nextlabel  = $this->l('Next');
			$lastlabel  = $this->l('Last');

			$out = '<div class="pagin">';

			$reload2 = preg_replace('/&page=[0-9]/', '', $reload);

			// first

			if ($page > 1)
				$out .= ' <a href="'.$reload2.'">'.$firstlabel.'</a> ';
			else
				$out .= ' <span>'.$firstlabel.'</span> ';

			// previous

			if ($page == 1)
				$out .= ' <span>'.$prevlabel.'</span> ';
			elseif ($page == 2)
				$out .= ' <a href="'.$reload2.'">'.$prevlabel.'</a> ';
			else
				$out .= ' <a href="'.$reload2.'&amp;page='.($page - 1).'">'.$prevlabel.'</a> ';

			// current
			$out .= ' <span class="current">'.$this->l('Page').' '.$page.' of '.$tpages.'</span> ';


			// next
			if ($page < $tpages)
				$out .= ' <a href="'.$reload2.'&amp;page='.($page + 1).'">'.$nextlabel.'</a> ';
			else
				$out .= ' <span>'.$nextlabel.'</span> ';
			// last

			if ($page < $tpages)
				$out .= ' <a href="'.$reload2.'&amp;page='.$tpages.'">'.$lastlabel.'</a> ';
			else
				$out .= ' <span>'.$lastlabel.'</span> ';

			$out .= '</div>';
			return $out;

		}

		public function displayForm()
		{
			$current_date = date('Y-m-d H:M:S');
			$orderBy     = null;
			$orderWay    = null;
			$beginning   = true;
			$ending      = false;
			$current_date = date('Y-m-d H:i:s');
			$i           = 0;
			$var         = '';
			$var2        = '';
			$var3        = '';
			$imgtyp      = CountdownSpecials::getImages('products');

			$count = count($imgtyp);
			$count;
			for ($i = 0; $i < $count; $i++)
			{
				$idimage  = $imgtyp[$i]['name'];
				$idimaget = $imgtyp[$i]['id_image_type'];

				$var .= '<option value="'.$idimaget.'"'.((Configuration::get('COUNTDOWNSPECIALS_IMAGECS') == $idimaget) ?
				'selected="selected"' : '').'>
				'.$idimage.'</option>';
				$var2 .= '<option value="'.$idimaget.'"'.((Configuration::get('COUNTDOWNSPECIALS_IMAGEC') == $idimaget) ?
				'selected="selected"' : '').'>
				'.$idimage.'</option>';
				$var3 .= '<option value="'.$idimaget.'"'.((Configuration::get('COUNTDOWNSPECIALS_IMAGEH') == $idimaget) ?
				'selected="selected"' : '').'>
				'.$idimage.'</option>';

			}
			if (_PS_VERSION_ < '1.5.0.0')
				$productToken = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id;
			else
				$productToken = Tools::getAdminTokenLite('adminproducts');
			if (_PS_VERSION_ > '1.4.0.0')
			{
				$output = '<script type="text/javascript" src="../modules/countdownspecials/views/js/accordion.ui.js">
				</script>
<style type="text/css">
.nobootstrap label{clear:both}
</style>
            <script type="text/javascript">
$(function() {
        $( "#accordion" ).accordion({ autoHeight: false });
    });
    </script>';
			}
			$output .= '<link rel="stylesheet" href="../modules/countdownspecials/views/css/colorpicker.css" type="text/css" />
                            <script type="text/javascript" src="../modules/countdownspecials/views/js/colorpicker.js"></script>
                            <script type="text/javascript" src="../modules/countdownspecials/views/js/eye.js"></script>
                            <script type="text/javascript" src="../modules/countdownspecials/views/js/utils.js"></script>
                            <script type="text/javascript" src="../modules/countdownspecials/views/js/layout.js?ver=1.0.2"></script>
    <style type="text/css">
#accordion h3 span{height:0}
.ui-accordion-content{padding:5px}
    label {
float: left;
width: 300px;
padding: 0.2em 0.5em 0 0;
text-align: right;
font-weight: bold;
}
    </style>
                            <form action="'.$_SERVER['REQUEST_URI'].'" method="post">
                            <fieldset>
                            <div id="accordion">
                        <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/module.png" alt="" title="" />'.$this->l('General settings').'</h3>
                        <div>
                           
                                <label>'.$this->l('Disable products').'</label>
                            <div class="margin-form">
                            <select name="enabledp" id="enabledp">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_ENABLEDP') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_ENABLEDP') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                                <p class="clear">'.$this->l('Disable products when countdown date finish').'</p>
                            </div>

                                <label>'.$this->l('Enable products').'</label>
                            <div class="margin-form">
                            <select name="disabledp" id="disabledp">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                                <p class="clear">'.$this->l('Use a cron task to enable or disable the products. You must configure the cron task with the url provided in the help window and set a task for every day, every hour, as for example. You can set in Cron module of Prestashop').'</p>
                            </div>

 <label>'.$this->l('Use Cron').'</label>
                            <div class="margin-form">
                            <select name="cront" id="cront">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_CRONT') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_CRONT') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                                <p class="clear">'.$this->l('Enable products when countdown date start').'</p>
                            </div>
							 <label>'.$this->l('Show sales').'</label>
                            <div class="margin-form">
                            <select name="disabledp" id="disabledp">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_DISABLEDP') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                            <p class="clear">'.$this->l('Enable products when countdown date start').'</p>
                            </div>

							<label>'.$this->l('Push on checkout').'</label>
                            <div class="margin-form">
                            <select name="push" id="push">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_PUSH') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_PUSH') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                            <p class="clear">'.$this->l('Show limited time offers on checkout (same configuration as slider section )').'</p>
                            </div>

                            <label>'.$this->l('Choice of sort').'</label>
                            <div class="margin-form">
                            <select name="sort" id="sort">
                            <option value="ASC" '.(Configuration::get('COUNTDOWNSPECIALS_SORT') == 'ASC' ? 'selected' : '').'>'.$this->l('Expiring first').'</option>
                            <option value="DESC" '.(Configuration::get('COUNTDOWNSPECIALS_SORT') == 'DESC' ? 'selected' : '').'>'.$this->l('Last expiring').'</option>
                            </select>
                            </div>
                            <label>'.$this->l('Style of time').'</label>
                            <div class="margin-form">
                            <select name="styletime" id="styletime">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_STYLETIME') == '1' ? 'selected' : '').'>'.$this->l('With words').'</option>
                            <option value="2" '.(Configuration::get('COUNTDOWNSPECIALS_STYLETIME') == '2' ? 'selected' : '').'>'.$this->l('With :').'</option>
                            </select>
							                            <p class="clear">'.$this->l('Only to formats 1 to 9').'</p>

                            </div>
                            <label>'.$this->l('Upper range for the counter').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="padding" value="'.Tools::getValue('padding', Configuration::get('COUNTDOWNSPECIALS_PADDING')).'" />
                            <p class="clear">'.$this->l('The space between the time and the top button (default 3)').'</p>
                            </div>

                            <label>'.$this->l('Font size').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="fs" value="'.Tools::getValue('fs', Configuration::get('COUNTDOWNSPECIALS_FS')).'" />
                            <p class="clear">'.$this->l('Font size of the time in px, %, em, etc').'</p>


                            </div>
                            <label>'.$this->l('Price Font size').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="fsp" value="'.Tools::getValue('fsp', Configuration::get('COUNTDOWNSPECIALS_FSP')).'" />
                            </div>
							
                            <label>'.$this->l('Price color').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="colorp" size="6" id="colorpickerField4" value="'.str_replace('#', '', Tools::getValue('colorp', Configuration::get('COUNTDOWNSPECIALS_COLORP'))).'" />
                                <p class="clear">'.$this->l('Color of the text (default 000000)').'</p>
                            </div>
                            </div>
							 <label>'.$this->l('Text date color / circle background').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="color" size="6" id="colorpickerField1"
                            value="'.str_replace('#', '', Tools::getValue('color', Configuration::get('COUNTDOWNSPECIALS_COLOR'))).'" />
							
                            <p class="clear">'.$this->l('Color of the text (default ffffff)').'</p>
                            </div>
                            </div>
  <label>'.$this->l('Circle color').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="cf" size="6" id="colorpickerField5" value="'.str_replace('#', '', Tools::getValue('cf', Configuration::get('COUNTDOWNSPECIALS_CF'))).'" />
                                <p class="clear">'.$this->l('Color of the circle (only for Circles style)').'</p>
                            </div>
                            </div>
                              <label>'.$this->l('Circle width').'</label>
                            <div class="margin-form">
                            <select name="cw" id="cw">
                            <option value="0.016" '.(Configuration::get('COUNTDOWNSPECIALS_CW') == '0.016' ? 'selected' : '').'>'.$this->l('1').'</option>
						 <option value="0.033" '.(Configuration::get('COUNTDOWNSPECIALS_CW') == '0.033' ? 'selected' : '').'>'.$this->l('2').'</option>
                            <option value="0.055" '.(Configuration::get('COUNTDOWNSPECIALS_CW') == '0.055' ? 'selected' : '').'>'.$this->l('3').'</option>
                            <option value="0.073" '.(Configuration::get('COUNTDOWNSPECIALS_CW') == '0.073' ? 'selected' : '').'>'.$this->l('4').'</option>
                            <option value="0.1" '.(Configuration::get('COUNTDOWNSPECIALS_CW') == '0.1' ? 'selected' : '').'>'.$this->l('5').'</option>
                            </select>
                            </div>
                            <label>'.$this->l('Type of countdown').'</label>
                            <div class="margin-form">
                            <table width="200" border="0">
                            <tr>
                            <td><img src="../modules/countdownspecials/views/img/Countdown1.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown2.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown3.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown4.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown5.png" width="60"></td>

                            <td><img src="../modules/countdownspecials/views/img/Countdown6.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown7.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown8.png" width="60"></td>
                            <td><img src="../modules/countdownspecials/views/img/Countdown9.png" width="60"></td>
							 <td><img src="../modules/countdownspecials/views/img/Countdown10.png" width="60"></td>
							 <td><img src="../modules/countdownspecials/views/img/Countdown11.png" width="60"></td>
                            </tr>
                            <tr>';

			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '1')
				$output .= '<td>1<input type="radio" name="but" id="radio1" value="1"  checked="checked"  /></td>';
			else
				$output .= ' <td>1<input type="radio" name="but" id="radio1" value="1"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 2)
				$output .= '<td>2<input type="radio" name="but" id="radio2" value="2"  checked="checked"  /></td>';
			else
				$output .= ' <td>2<input type="radio" name="but" id="radio2" value="2"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 3)
				$output .= '<td>3<input type="radio" name="but" id="radio3" value="3"  checked="checked"  /></td>';
			else
				$output .= '<td>3<input type="radio" name="but" id="radio3" value="3"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 4)
				$output .= '<td>4<input type="radio" name="but" id="radio4" value="4"  checked="checked"  /></td>';
			else
				$output .= '<td>4<input type="radio" name="but" id="radio4" value="4"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == 5)
				$output .= '<td>5<input type="radio" name="but" id="radio5" value="5"  checked="checked"  /></td>';
			else
				$output .= '<td>5<input type="radio" name="but" id="radio5" value="5"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '6')
				$output .= '<td>6<input type="radio" name="but" id="radio6" value="6"  checked="checked"  /></td>';
			else
				$output .= ' <td>6<input type="radio" name="but" id="radio6" value="6"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '7')
				$output .= '<td>7<input type="radio" name="but" id="radio7" value="7"  checked="checked"  /></td>';
			else
				$output .= ' <td>7<input type="radio" name="but" id="radio7" value="7"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '8')
				$output .= '<td>8<input type="radio" name="but" id="radio8" value="8"  checked="checked"  /></td>';
			else
				$output .= ' <td>8<input type="radio" name="but" id="radio8" value="8"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '9')
				$output .= '<td>9<input type="radio" name="but" id="radio9" value="9"  checked="checked"  /></td>';
			else
				$output .= ' <td>9<input type="radio" name="but" id="radio9" value="9"  /></td>';

			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '10')
				$output .= '<td>10<input type="radio" name="but" id="radio10" value="10"  checked="checked"  /></td>';
			else
				$output .= ' <td>10<input type="radio" name="but" id="radio10" value="10"  /></td>';
			if (Tools::getValue('but', Configuration::get('COUNTDOWNSPECIALS_BUT')) == '11')
				$output .= '<td>11<input type="radio" name="but" id="radio11" value="11"  checked="checked"  /></td>';
			else
				$output .= ' <td>11<input type="radio" name="but" id="radio11" value="11"  /></td>';
			$output .= '</tr>
                            </table></div>';

			if (_PS_VERSION_ > '1.4.0.0')

				$output .= '        <center><input type="submit" name="submitCountdownSpecials" value="'.$this->l('Save').'" class="button" /></center><br/>';

			$output .= '</div>
			 <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/slide.png" alt="" title="" />'.$this->l('Category settings').'</h3>
                        <div>
						 <label>'.$this->l('Width of the countdown').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="catw" value="'.Tools::getValue('catw', Configuration::get('COUNTDOWNSPECIALS_CATW')).'" />
							<p class="clear">'.$this->l('The width of the countdown').'</p>
                            </div>
					
						  <label>'.$this->l('Text color / circle background').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="catcolor" size="6" id="colorpickerField3"
                            value="'.str_replace('#', '', Tools::getValue('catcolor', Configuration::get('COUNTDOWNSPECIALS_CATCOLOR'))).'" />
						<p class="clear">'.$this->l('Color of the text / circle (default cccccc)').'</p>
                            </div>
                           </div>
						    <label>'.$this->l('Circle color').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="catcolor2" size="6" id="colorpickerField3"
                            value="'.str_replace('#', '', Tools::getValue('catcolor2', Configuration::get('COUNTDOWNSPECIALS_CATCOLOR2'))).'" />
						<p class="clear">'.$this->l('Color of the circle / circle (default 000000)').'</p>
                            </div>
                           </div>';
$output .= '<center><input type="submit" name="submitCountdownSpecials" value="'.$this->l('Save').'" class="button" /></center><br/>';
$output .= ' </div>
                        <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/slide.png" alt="" title="" />'.$this->l('Slider settings').'</h3>
                        <div>
						  <label>'.$this->l('Responsive slider').'</label>
                            <div class="margin-form">
<select name="respo" id="respo">
<option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_RESPO') == '1' ? 'selected' : '').'>'
.$this->l('Yes').'</option>
<option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_RESPO') == '0' ? 'selected' : '').'>'
.$this->l('No').'</option>

</select>
	<p class="clear">'.$this->l('Enable responsive slider (this option disable the width and height of the slider)').'</p>

                            </div>
                            <label>'.$this->l('Number of products').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="nbrtop" value="'.Tools::getValue('nbrtop', Configuration::get('COUNTDOWNSPECIALS_NBRTOP')).'" />
							<p class="clear">'.$this->l('Set 0 to disable slider').'</p>
                            </div>
                            <label>'.$this->l('Width of the slider').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="widtht" value="'.Tools::getValue('widtht', Configuration::get('COUNTDOWNSPECIALS_WIDTHT')).'" />
                            </div>
                            <label>'.$this->l('Height of the slider').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="heightt" value="'.Tools::getValue('heightt', Configuration::get('COUNTDOWNSPECIALS_HEIGHTT')).'" />

                            </div>
						 <label>'.$this->l('Width of the countdown').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="wt" value="'.Tools::getValue('wt', Configuration::get('COUNTDOWNSPECIALS_WT')).'" />
<p class="clear">'.$this->l('Only for Flip style').'</p>
                            </div>
                              <label>'.$this->l('Border style').'</label>
                            <div class="margin-form">
                            <input type="text" size="15" name="bordersl" value="'.Tools::getValue('bordersl', Configuration::get('COUNTDOWNSPECIALS_BORDERSL')).'" />
<p class="clear">'.$this->l('The border style in css of the slider (like 1px solid #000).  Leave blank for no border').'</p>
                            </div>
<label>'.$this->l('Box shadow').'</label>
                            <div class="margin-form">
                            <input type="text" size="15" name="bs" value="'.Tools::getValue('bs', Configuration::get('COUNTDOWNSPECIALS_BS')).'" />
<p class="clear">'.$this->l('The shadow in css of the slider (like 1px -2px 28px 9px rgba(39, 0, 0, 0.5), dont unclude the last ";". Leave blank for no shadow').'</p>
                            </div>
                            <label>'.$this->l('Delay ').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="delaycs" value="'.Tools::getValue('delaycs', Configuration::get('COUNTDOWNSPECIALS_DELAYCS')).'" />
                            </div>
                            <label>'.$this->l('Type of image').'</label>
                            <div class="margin-form">
                            <select name="imagecs" id="imagecs">

'.$var.'


                            </select>
                            </div>
                                <label>'.$this->l('Enable slider in:').'</label>
                            <div class="margin-form">
<select name="slidercs" id="slidercs">
<option value="hometop" '.(Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'hometop' ? 'selected' : '').'>'
.$this->l('only in home, top of pages').'</option>
<option value="topcs" '.(Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'topcs' ? 'selected' : '').'>'
.$this->l('all pages, in top of pages').'</option>
<option value="homecs" '.(Configuration::get('COUNTDOWNSPECIALS_SLIDERCS') == 'homecs' ? 'selected' : '').'>'
.$this->l('homepage').'</option>
</select>

                            </div>
                                <label>'.$this->l('Background color').'</label>
                            <div class="margin-form">
                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="colortop" size="6" id="colorpickerField3"
                            value="'.str_replace('#', '', Tools::getValue('colortop', Configuration::get('COUNTDOWNSPECIALS_COLORTOP'))).'" />
						<p class="clear">'.$this->l('Color of the text (default ffffff)').'</p>
                            </div>
                           </div>';

			if (_PS_VERSION_ > '1.4.0.0')
			{

				$output .= '        <center><input type="submit" name="submitCountdownSpecials" value="'.$this->l('Save').'" class="button" /></center><br/>';

			}

			$output .= '</div>
                        <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/column.png" alt="" title="" />'.$this->l('Column settings').'</h3>
                            <div>
                                <label>'.$this->l('Image type').'</label>
                            <div class="margin-form">
                            <select name="imagec" id="imagec">
'.$var2.'
                            </select>
                                <p class="clear">'.$this->l('The image type for the countdown').'</p>
                            </div>
                                <label>'.$this->l('Image size').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="imagesizec"
                            value="'.Tools::getValue('imagesizec', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEC')).'" />
                            <p class="clear">'.$this->l('The width for the image').'</p>
                            </div>
                            <label>'.$this->l('Number of products').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="nbr3" value="'.Tools::getValue('nbr3', Configuration::get('COUNTDOWNSPECIALS_NBR3')).'" />
                            </div>

                            <label>'.$this->l('Speed').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="nbr2" value="'.Tools::getValue('nbr2', Configuration::get('COUNTDOWNSPECIALS_NBR2')).'" />
                            <p class="clear">'.$this->l('Speed of the scroll (1 to 10)').'</p>
                            </div>

                            <label>'.$this->l('Width').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="width" value="'.Tools::getValue('width', Configuration::get('COUNTDOWNSPECIALS_WIDTH')).'" />
                            <p class="clear">'.$this->l('Width of the block (default 180)').''.$this->l('- 100%').'</p>
                            </div>
                            <label>'.$this->l('Height').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="height" value="'.Tools::getValue('height', Configuration::get('COUNTDOWNSPECIALS_HEIGHT')).'" />
                            <p class="clear">'.$this->l('Height of the module(default 240)').'</p>

                            </div>
							 <label>'.$this->l('Width of the countdown').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="wtb" value="'.Tools::getValue('wtb', Configuration::get('COUNTDOWNSPECIALS_WTB')).'" />
                            <p class="clear">'.$this->l('Width of the countdown (only for flip style)').'</p>
                            </div>
							';
			if (_PS_VERSION_ > '1.4.0.0')
			{
				$output .= '        <center><input type="submit" name="submitCountdownSpecials" value="'.$this->l('Save').'" class="button" /></center><br/>';

			}
			$output .= '</div>
                            <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/home.png" alt="" title="" />'.$this->l('Home and countdown page').'</h3>
                            <div>
    <label>'.$this->l('Enable on home page').'</label>
                            <div class="margin-form">
                            <select name="hp" id="hp">
                            <option value="yes" '.(Configuration::get('COUNTDOWNSPECIALS_HP') == 'yes' ? 'selected' : '').'>'.$this->l('yes').'</option>
                            <option value="no" '.(Configuration::get('COUNTDOWNSPECIALS_HP') == 'no' ? 'selected' : '').'>'.$this->l('no').'</option>
                            </select>
                                <p class="clear">'.$this->l('Put no if you want to disable on home page. You can put this code on your homefeatured.tpl
module to include in your home featured the countdown timer: </br>{include file="$tpl_dir./../../modules/countdownspecials/views/templates/front/countdownspecials-list.tpl"}').'</p>
                            </div>
                                <label>'.$this->l('Image type').'</label>
                            <div class="margin-form">
                            <select name="imageh" id="imageh">
                        '.$var3.'
                            </select>
                                <p class="clear">'.$this->l('The image type for the countdown').'</p>
                            </div>
                                <label>'.$this->l('Image size').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="imagesizeh" value="'.Tools::getValue('imagesizeh', Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH')).'" />
                            <p class="clear">'.$this->l('The width for the image').'</p>
                            </div>
                            <label>'.$this->l('Number of products to display in homepage').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="nbr" value="'.Tools::getValue('nbr', Configuration::get('COUNTDOWNSPECIALS_NBR')).'" />
                            <p class="clear">'.$this->l('The number of orders to display (default: 10, put 0 to disable in homepage)').'</p>
                            </div>
                            <label>'.$this->l('Number of products to display in Countdown page').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="nbrpage" value="'.Tools::getValue('nbrpage', Configuration::get('COUNTDOWNSPECIALS_NBRPAGE')).'" />
                            <p class="clear">'.$this->l('Total of products to show in countdown page').'</p>
                            </div>
<label>'.$this->l('Enable pagination in homepage').'</label>
                            <div class="margin-form">
                            <select name="pagination" id="pagination">
                            <option value="yes" '.(Configuration::get('COUNTDOWNSPECIALS_PAGINATION') == 'yes' ? 'selected' : '').'>'.$this->l('yes').'</option>
                            <option value="no" '.(Configuration::get('COUNTDOWNSPECIALS_PAGINATION') == 'no' ? 'selected' : '').'>'.$this->l('no').'</option>
                           </select>
                            </div>
                                <label>'.$this->l('Enable pagination in countdown page').'</label>
                            <div class="margin-form">
                            <select name="pagination2" id="pagination2">
                            <option value="yes" '.(Configuration::get('COUNTDOWNSPECIALS_PAGINATION2') == 'yes' ? 'selected' : '').'>'.$this->l('yes').'</option>
                            <option value="no" '.(Configuration::get('COUNTDOWNSPECIALS_PAGINATION2') == 'no' ? 'selected' : '').'>'.$this->l('no').'</option>
                            </select>
                            </div>
                            <label style="padding:0">'.$this->l('Products in pagination (homepage)').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="paginationn" value="'.Tools::getValue('paginationn', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN')).'" />
                            </div>
                            <label style="padding:0">'.$this->l('Products in pagination (countdown page)').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="paginationn2" value="'.Tools::getValue('paginationn2', Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2')).'" />
                            </div>
                         
                            <label>'.$this->l('Margin for each element').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="margin" value="'.Tools::getValue('margin', Configuration::get('COUNTDOWNSPECIALS_MARGIN')).'" />
                                                         <p class="clear">'.$this->l('The margin for each product, use 2 as min').'</p>

                            </div>
              <label>'.$this->l('Show add to cart').'</label>
                            <div class="margin-form">
                            <select name="color2" id="color2">
                            <option value="yes" '.(Configuration::get('COUNTDOWNSPECIALS_COLOR2') == 'yes' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="no" '.(Configuration::get('COUNTDOWNSPECIALS_COLOR2') == 'no' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                            <p class="clear">'.$this->l('Show total price').'</p>
                            </div>

                                <label>'.$this->l('Style of the module').'</label>
                            <div class="margin-form">
                            <select name="grid" id="grid">
                            <option value="no" '.(Configuration::get('COUNTDOWNSPECIALS_GRID') == 'no' ? 'selected' : '').'>'.$this->l('Grid').'</option>
                            <option value="yes" '.(Configuration::get('COUNTDOWNSPECIALS_GRID') == 'yes' ? 'selected' : '').'>'.$this->l('List').'</option>
                            </select>
                            <p class="clear">'.$this->l('Show items as grid or list (homepage and module page)').'</p>
                            </div>
    <label>'.$this->l('Responsive products').'</label>
                            <div class="margin-form">
                            <select name="respop" id="respop">
                            <option value="1" '.(Configuration::get('COUNTDOWNSPECIALS_RESPOP') == '1' ? 'selected' : '').'>'.$this->l('Yes').'</option>
                            <option value="0" '.(Configuration::get('COUNTDOWNSPECIALS_RESPOP') == '0' ? 'selected' : '').'>'.$this->l('No').'</option>
                            </select>
                            <p class="clear">'.$this->l('Enable responsive products (this overwrites the width, height and module width.You template must be bootstrap compatible)').'</p>
                            </div>
                            <label>'.$this->l('Width of the module').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="width3" value="'.Tools::getValue('width3', Configuration::get('COUNTDOWNSPECIALS_WIDTH3')).'" />
                            <p class="clear">'.$this->l('Width of the block (default 540px)').'</p>
                            </div>

                                <label>'.$this->l('Height of each element').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="width3h" value="'.Tools::getValue('width3h', Configuration::get('COUNTDOWNSPECIALS_WIDTH3H')).'" />
                            <p class="clear">'.$this->l('The height for each element in homepage and page').'</p>
                            </div>

                                <label>'.$this->l('Width of each element').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="listw" value="'.Tools::getValue('listw', Configuration::get('COUNTDOWNSPECIALS_LISTW')).'" />
                            <p class="clear">'.$this->l('The width for each element in homepage and page').'</p>
                            </div>

							 <label>'.$this->l('Width of the countdown').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="wth" value="'.Tools::getValue('wth', Configuration::get('COUNTDOWNSPECIALS_WTH')).'" />
                            <p class="clear">'.$this->l('The width of the countdown (only for Flip style)').'</p>
                            </div>
  <label style="padding:0">'.$this->l('Border style').'</label>
                            <div class="margin-form">
                            <input type="text" size="20" name="align" value="'.Tools::getValue('align', Configuration::get('COUNTDOWNSPECIALS_ALIGN')).'" />
                            <p class="clear">'.$this->l('For example: 1px solid #000.Leave blank for no border').'</p>
                            </div>
                                <label>'.$this->l('Border radius').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="rad" value="'.Tools::getValue('rad', Configuration::get('COUNTDOWNSPECIALS_RAD')).'" />
                            <p class="clear">'.$this->l('Make the border of elements with a radius (max 20)').'</p>
                            </div>
							  <label>'.$this->l('Box shadow').'</label>
                            <div class="margin-form">
                            <input type="text" size="5" name="pbs" value="'.Tools::getValue('pbs', Configuration::get('COUNTDOWNSPECIALS_PBS')).'" />
                            <p class="clear">'.$this->l('Shadow for each element in css (like -1px 0px 6px 2px rgba(20, 0, 0, 0.5)). Leave blank for no shadow').'</p>
                            </div>
                            <label>'.$this->l('Background color').'</label>
                            <div class="margin-form">

                            <div id="customWidget">
                            <input type="text" maxlength="6"  name="colorbg" size="6" id="colorpickerField2"
                            value="'.str_replace('#', '', Tools::getValue('colorbg', Configuration::get('COUNTDOWNSPECIALS_COLORBG'))).'" />
                                <p class="clear">'.$this->l('Color of the background (default ffffff)').'</p>
                            </div>
                            </div>
                            <center><input type="submit" name="submitCountdownSpecials" value="'.$this->l('Save').'" class="button" /></center><br/>
                            </div>
                                <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/pdf.png" alt="" title="" />'.$this->l('Documentation').'</h3>
                                <div>
<p>'.$this->l('If you need to add countdown timer in product list, edit the product-list.tpl of your
theme and put this code where you need the timer:').'<br/>{include file="$tpl_dir./../../modules/countdownspecials/views/templates/front/countdownspecials-list.tpl"}</p>
<p>'.$this->l('If you use layered navigation module, edit in modules/blocklayered/blocklayered.php,
and add at the beginning this code:').'<br/>include(dirname(__FILE__).\'/../countdownspecials/countdownspecials.php\');</p>

<p>'.$this->l('and search this line:').'<br/>\'nb_products\' => $nb_products,</p>
<p>'.$this->l('and put this code after it:').'<br/>\'productlist\' => CountdownSpecials::productList(),</p> <br/>
<p>'.$this->l('To generate css3 shadows, you can use this site:').'
<a href="http://css3gen.com/box-shadow/">CSS3</a></p></br>
    <p> <center>'.$this->l('Ask your hosting provider to setup a "Cron task" to load the following URL at the time you would like to disable/enable the products automatically:').'<a href="'._PS_BASE_URL_._MODULE_DIR_.'countdownspecials/cron.php?token='.Tools::substr(Tools::encrypt('countdownspecials/cron'), 0, 10).'&id_shop='.$this->context->shop->id.'">'._PS_BASE_URL_._MODULE_DIR_.'countdownspecials/cron.php?token='.Tools::substr(Tools::encrypt('countdownspecials/cron'), 0, 10).'&id_shop='.$this->context->shop->id.'</a></center><br/><center>'.$this->l('You can use the free Prestashop module Cron tasks manager (cronjobs).Just install it and configure the url and time').'</center></p><br/><br/> <br/>

                            <center><a href="../modules/countdownspecials/countdown.pdf">README</a></center><br/>
                            <center><a href="../modules/countdownspecials/termsandconditions.pdf">TERMS</a></center>
							<center><a href="../modules/countdownspecials/views/img/help.jpg" target="_blank">Quick help</a></center><br/>
<center>Video:</center>
		<iframe width="640" height="360" src="https://www.youtube.com/embed/6fYPT0u_dsY?rel=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe><br/>
							
                            </div>
                                <h3 style="padding-left:40px"><img src="'.$this->_path.'views/img/date.png" alt="" title="" />'
								.$this->l('Active and expired products').'</h3>
                                <div>
                            ';

			$output .= '<h4>'.$this->l('Active prices drop list - Current time: ').date('Y-m-d H:i:s').'</h4>

                          
                            <table class="table">

        <tr>
        <th>'.$this->l('ID').'</th>
        <th>'.$this->l('Reference').'</th>
    <th>'.$this->l('Name').'</th>
    <th>'.$this->l('From').'</th>
    <th>'.$this->l('To').'</th>
    <th>'.$this->l('Edit').'</th>

        </tr>';
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to
                              AS reduction_to,sp.`id_specific_price`,sp.`id_product`
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)$this->context->language->id.')
                            LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                            WHERE sp.from <= sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to >= \''.pSQL($current_date).'\'
                            ';

			}
			if (_PS_VERSION_ > '1.5.0.0')
			{
				$current_date = date('Y-m-d H:i:s');

				$sql         = '
                SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
                pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`,sp.`id_specific_price`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)$this->context->language->id.')
                WHERE sp.from <= sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to >= \''.pSQL($current_date).'\' && ps.id_shop = '.(int)$this->context->shop->id.'
 && pl.id_shop = '.(int)$this->context->shop->id.'
                ';

			}

			if (_PS_VERSION_ < '1.4.0.0')
			{
				$sql = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
                            pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`, pl.`name`
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)$this->context->language->id.')
                            WHERE p.reduction_from < p.reduction_to && p.reduction_from < \''.pSQL($current_date).'\'
                             && p.reduction_to > \''.pSQL($current_date).'\' GROUP BY p.`id_product`';

			}
			$resultt     = mysql_query($sql);
			$pricesDrop  = Db::getInstance()->ExecuteS($sql);
			$prices_drop = array();
			/*paginate*/
			$rpp       = 10; // results per page
			$adjacents = 2;
			$page      = (int)(@Tools::getValue('page'));

			if ($page <= 0)
				$page = 1;
			$reload = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];
			// count total number of appropriate listings:
			@$tcount = mysql_num_rows(@$resultt);
			// count number of pages:
			$tpages = ($tcount) ? ceil($tcount / $rpp) : 1; // total pages, last page number
			$count  = 0;
			$i      = ($page - 1) * $rpp;
			while (($count < $rpp) && ($i < $tcount))
			{
				mysql_data_seek($resultt, $i);
				$query = mysql_fetch_array($resultt);
				$type  = CountdownSpecials::getImages('products');
				$imo   = new Image;
				$im    = $imo->getCover((int)($query['id_product']));
				$im2o  = new Link;
				$im2   = $im2o->getImageLink($query['link_rewrite'], $query['id_product'].'-'.$im['id_image'], $type[0]['name']);

				// output each row:
								if (_PS_VERSION_ > '1.5.0.0')

				$im2 = str_replace($_SERVER['HTTP_HOST'], '../../', $im2);
				else
				$im2 = str_replace($_SERVER['HTTP_HOST'].__PS_BASE_URI__, '../../', $im2);

				$output .= '
        <tr>
		  <form method="post" action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data" >
		<td>'.$query['id_product'].'</td>
        <td>'.$query['reference'].'</td>
        <td style="text-align:center"><img src="../'.$im2.'" width="55"/><br/>'.$query['name'].'</td>
        <td>'.$query['reduction_from'].'</td>
        <td>'.$query['reduction_to'].'</td>';
				if (_PS_VERSION_ < '1.5.0.0')

					$product_token2 = Tools::getAdminToken('AdminCatalog'.(int)Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id;

				else

					$product_token2 = Tools::getAdminTokenLite('updateproduct'.$query['id_product']);

				if (_PS_VERSION_ < '1.5.0.0')
				{
					$output .= '<td><a href="index.php?tab=AdminCatalog&id_product='.$query['id_product'].'&addproduct&token='.$product_token2.'"
					target="_blank">'.$this->l('Edit').'</a>
                <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />';
					if (_PS_VERSION_ > '1.4.0.0')
						$output .= '    <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />';
					$output .= '<input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" />
                ';
				}
				else
				{
					$output .= '<td><a href="index.php?controller=adminproducts&id_product='.$query['id_product'].'&updateproduct&token='.$product_token2.'"
					target="_blank">'.$this->l('Edit').'</a>
                <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />
                <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />
                <input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0" style="border:none;cursor: pointer;" />
                ';
				}

				$output .= '</td></form>
        </tr>';
				$i++;
				$count++;
			}
			// call pagination function:
			/*endpaginate*/
			/*    foreach ($pricesDrop AS $priceDrop){
            </td>
            </tr>';
            }*/
			$output .= '</table><br/>';
			$output .= CountdownSpecials::paginate_one($reload, $page, $tpages, $adjacents);
			$output .= '<br/><h4>'.$this->l('Expired prices drop list').'</h4>
			
						<table class="table">
						<tr>
						<th>'.$this->l('ID').'</th>
						<th>'.$this->l('Reference').'</th>
						<th>'.$this->l('Name').'</th>
						<th>'.$this->l('From').'</th>
						<th>'.$this->l('To').'</th>
						<th>'.$this->l('Edit').'</th>
						</tr>';
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql2 = '
			SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
			 pl.`meta_keywords`, pl.`meta_title`, pl.`name`, sp.from AS reduction_from, sp.to
			  AS reduction_to, sp.id_specific_price
			FROM `'._DB_PREFIX_.'product` p
			LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
			 pl.`id_lang` = '.(int)$this->context->language->id.')
			LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
			WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to < \''.pSQL($current_date).'\'
			GROUP BY p.`id_product`
                            ';
			}
			if (_PS_VERSION_ > '1.5.0.0')
			{
				$current_date = date('Y-m-d H:i:s');
				$current_date = date('Y-m-d H:i:s');
				$sql2        = '
                SELECT p.*,ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`,
				 pl.`meta_description`, pl.`meta_keywords`, pl.`meta_title`,
                pl.`name`, p.`ean13`, p.`upc`, sp.`from` AS  reduction_from,  sp.`to`
				 AS reduction_to, sp.`id_product` ,sp.`id_specific_price`
                FROM `'._DB_PREFIX_.'product` p
				LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
				 pl.`id_lang` = '.(int)$this->context->language->id.')
                WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' &&
				 sp.to < \''.pSQL($current_date).'\' && ps.id_shop = '.(int)$this->context->shop->id.'
 && pl.id_shop = '.(int)$this->context->shop->id.'
                ';

			}
			if (_PS_VERSION_ < '1.4.0.0')
			{
				$sql2 = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
							 pl.`id_lang` = '.(int)$this->context->language->id.')
                            WHERE p.reduction_from < p.reduction_to && p.reduction_to < \''.pSQL($current_date).'\' GROUP BY p.`id_product`';
			}

			$pricesDrop2  = Db::getInstance()->ExecuteS($sql2);
			$resulttt     = mysql_query($sql2);
			$prices_drop2 = array();
			@$tcount = mysql_num_rows(@$resulttt);
			// count number of pages:
			$tpages = ($tcount) ? ceil($tcount / $rpp) : 1; // total pages, last page number
			$count  = 0;
			$i      = ($page - 1) * $rpp;
			while (($count < $rpp) && ($i < $tcount))
			{
				mysql_data_seek($resulttt, $i);
				$query = mysql_fetch_array($resulttt);
				$type  = CountdownSpecials::getImages('products');
				$imo   = new Image;
				$im    = $imo->getCover((int)($query['id_product']));
				$im2o  = new Link;
				$im2   = $im2o->getImageLink($query['link_rewrite'], $query['id_product'].'-'.$im['id_image'], $type[0]['name']);

				// output each row:
					if (_PS_VERSION_ > '1.5.0.0')

				$im2 = str_replace($_SERVER['HTTP_HOST'], '../../', $im2);
				else
				$im2 = str_replace($_SERVER['HTTP_HOST'].__PS_BASE_URI__, '../../', $im2);
				$output .= '
        <tr>
		<form method="post" action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data" >
		<td>'.$query['id_product'].'</td>
        <td>'.$query['reference'].'</td>
        <td style="text-align:center"><img src="../'.$im2.'" width="55"/><br/>'.$query['name'].'</td>
        <td>'.$query['reduction_from'].'</td>
        <td>'.$query['reduction_to'].'</td>';
				if (_PS_VERSION_ < '1.5.0.0')
					$product_token3 = Tools::getAdminToken('AdminCatalog'.
					(int)Tab::getIdFromClassName('AdminCatalog')).(int)$this->context->employee->id;
				else
					$product_token3 = Tools::getAdminTokenLite('AdminProducts'.$query['id_product']);
				if (_PS_VERSION_ < '1.5.0.0')
				{
					$output .= '<td><a href="index.php?tab=AdminCatalog&id_product='.$query['id_product'].'&addproduct&token='.$product_token3.'"
					target="_blank">'.$this->l('Edit').'</a>
                    <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />';
					if (_PS_VERSION_ > '1.4.0.0')
						$output .= '    <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />';
					$output .= '<input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0"
style="border:none;cursor: pointer;" />';
				}
				else
				{
					$output .= '<td><a href="index.php?controller=adminproducts&id_product='.$query['id_product'].'&updateproduct&token='.$product_token3.'"
					target="_blank">'.$this->l('Edit').'</a>
                    <input name="id_product" type="hidden" id="id_product" value="'.$query['id_product'].'" />
                <input name="id_discount" type="hidden" id="id_discount" value="'.$query['id_specific_price'].'" />
                <input type="image" src="../img/admin/delete.gif" name="submitDelete" id="submitDelete" border="0"
                style="border:none;cursor: pointer;" />';

				}
				$output .= '
        </td></form>
        </tr>';
				$i++;
				$count++;

			}
			$output .= '</table><br/>';
			$output .= CountdownSpecials::paginate_one($reload, $page, $tpages, $adjacents);
			$output .= '</div>
</fieldset>
</form>
<fieldset>
  <form action="'.$_SERVER['REQUEST_URI'].'" method="post" enctype="multipart/form-data">


	<center><input type="submit" name="submitDeleteAll" value="'.$this->l('Delete all price reductions').'" class="button" />
<p>** WARNING: This option delete all reductions created with the module, and all reductions created from product prices tab</p>
		</form></fieldset>
';
			return $output;

		}

		public function getPricesDropsh($id_lang, $page_number = 0, $nbProducts, $count = false,
			$orderBy = null,
			$orderWay = null, $beginning = true, $ending = false)
		{
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());
			if ($page_number < 0)
				$page_number = 0;
			if ($nbProducts < 1)
				$nbProducts = 10;
			if (empty($orderBy) || $orderBy == 'position')
				$orderBy = 'myprice';
			if (empty($orderWay))
				$orderWay = 'DESC';
			if ($orderBy == 'id_product' || $orderBy == 'price' || $orderBy == 'date_add')
				$order_by_prefix = 'p';
			elseif ($orderBy == 'name')
				$order_by_prefix = 'pl';
			if (!Validate::isOrderBy($orderBy) || !Validate::isOrderWay($orderWay))
				die(Tools::displayError());
			if ($count)
			{
				$sql = '

                            SELECT COUNT(DISTINCT p.`id_product`) AS nb
                            FROM `'._DB_PREFIX_.'product` p
                            WHERE p.`active` = 1
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN
                             (SELECT id_group FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';

				$result = Db::getInstance()->getRow($sql);
				return (int)($result['nb']);
			}

			$current_date = date('Y-m-d H:i:s');
			$sql         = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`,
                              (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
                            LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = p.`id_tax`)
                            LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
                            WHERE (`reduction_price` >= 0 || `reduction_percent` >= 0)
                            '.((!$beginning && !$ending) ? '&& ((`reduction_from` <= \''.pSQL($current_date).'\' &&
                             `reduction_to` >= \''.pSQL($current_date).'\'))' : ($beginning ? '&& `reduction_from` <=
                              \''.pSQL($beginning).'\'' : '').($ending ? '&& `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
                            && p.`active` = 1 && p.`price` > 0 
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN (SELECT id_group FROM
                             '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';
			if ($sort != 'RAND()')
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY `reduction_to` '.(string)$sort.'
                            LIMIT '.(int)$nbProducts;
			}
			else
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY RAND()
                            LIMIT '.(int)$nbProducts;
			}

			$result = Db::getInstance()->ExecuteS($sql);
			if ($orderBy == 'price')

				Tools::orderbyPrice($result, $orderWay);

			if (!$result)
				return false;
			return Product::getProductsProperties($id_lang, $result);
		}

		/**/
		public function getPricesDropshea($id_lang, $page_number = 0, $nbProducts, $count = false,
			$orderBy = null,
			$orderWay = null, $beginning = true, $ending = false)
		{
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());
			if ($page_number < 0)
				$page_number = 0;
			if ($nbProducts < 1)
				$nbProducts = 10;
			if (empty($orderBy) || $orderBy == 'position')

				$orderBy = 'myprice';
			if (empty($orderWay))
				$orderWay = 'DESC';
			if ($orderBy == 'id_product' || $orderBy == 'price' || $orderBy == 'date_add')
				$order_by_prefix = 'p';
			elseif ($orderBy == 'name')
				$order_by_prefix = 'pl';
			if (!Validate::isOrderBy($orderBy) || !Validate::isOrderWay($orderWay))
				die(Tools::displayError());
			if ($count)
			{

				$sql = '
                            SELECT COUNT(DISTINCT p.`id_product`) AS nb
                            FROM `'._DB_PREFIX_.'product` p
                            WHERE p.`active` = 1
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN (SELECT id_group
                            FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';

				$result = Db::getInstance()->getRow($sql);
				return (int)($result['nb']);
			}

			$current_date = date('Y-m-d H:i:s');
			$sql         = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`,
                              (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
							 pl.`id_lang` = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1) ¡
                            LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang`
							 = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = p.`id_tax`)
                            LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
                            WHERE (`reduction_price` >= 0 || `reduction_percent` >= 0)
                            '.((!$beginning && !$ending) ? '&& ((`reduction_from` <= \''.pSQL($current_date).'\' &&
                             `reduction_to` >= \''.pSQL($current_date).'\'))' : ($beginning ? '&& `reduction_from` <=
                              \''.pSQL($beginning).'\'' : '').($ending ? '&& `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
                            && p.`active` = 1 && p.`price` > 0 
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN (SELECT id_group
                            FROM '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';

			if ($sort != 'RAND()')
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY `reduction_to` '.(string)$sort.'
                            LIMIT '.(int)$nbProducts;
			}
			else
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY RAND()
                            ';

			}
			$result = Db::getInstance()->ExecuteS($sql);
			if ($orderBy == 'price')

				Tools::orderbyPrice($result, $orderWay);

			if (!$result)
				return false;
			return Product::getProductsProperties($id_lang, $result);
		}

		/**/
		public function getPricesDropT($id_lang, $page_number = 0, $nbProducts, $count = false,
			$orderBy = null,
			$orderWay = null, $beginning = true, $ending = false)
		{
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());
			if ($page_number < 0)
				$page_number = 0;
			if ($nbProducts < 1)
				$nbProducts = 10;
			if (empty($orderBy) || $orderBy == 'position')
				$orderBy = 'myprice';
			if (empty($orderWay))
				$orderWay = 'DESC';
			if ($orderBy == 'id_product' || $orderBy == 'price' || $orderBy == 'date_add')
				$order_by_prefix = 'p';
			elseif ($orderBy == 'name')
				$order_by_prefix = 'pl';
			if (!Validate::isOrderBy($orderBy) || !Validate::isOrderWay($orderWay))
				die(Tools::displayError());

			if ($count)
			{

				$sql    = '
                            SELECT COUNT(DISTINCT p.`id_product`) AS nb
                            FROM `'._DB_PREFIX_.'product` p
                            WHERE p.`active` = 1
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN (SELECT id_group FROM
                             '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';
				$result = Db::getInstance()->getRow($sql);
				return (int)($result['nb']);
			}

			$current_date = date('Y-m-d H:i:s');
			$sql         = '
                            SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                             pl.`meta_keywords`, pl.`meta_title`, pl.`name`, p.`ean13`, i.`id_image`, il.`legend`, t.`rate`,
                              (p.`reduction_price` + (p.`reduction_percent` * p.`price`)) AS myprice, m.`name` AS manufacturer_name
                            FROM `'._DB_PREFIX_.'product` p
                            LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
							 pl.`id_lang` = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
                            LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` &&
							 il.`id_lang` = '.(int)($id_lang).')
                            LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = p.`id_tax`)
                            LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
                            WHERE (`reduction_price` >= 0 || `reduction_percent` >= 0)
                            '.((!$beginning && !$ending) ? '&& ((`reduction_from` <= \''.pSQL($current_date).'\' &&
                             `reduction_to` >= \''.pSQL($current_date).'\'))' : ($beginning ? '&& `reduction_from` <=
                              \''.pSQL($beginning).'\'' : '').($ending ? '&& `reduction_to` >= \''.pSQL($ending).'\'' : '')).'
                            && p.`active` = 1 && p.`price` > 0 
                            && p.`id_product` IN (
                            SELECT cp.`id_product`
                            FROM `'._DB_PREFIX_.'category_group` cg
                            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
                            WHERE cg.`id_group` '.(!(int)($this->context->customer->id) ? '= 1' : 'IN (SELECT id_group FROM
                             '._DB_PREFIX_.'customer_group WHERE id_customer = '.(int)($this->context->customer->id).')').'
                            )';
			if ($sort != 'RAND()')
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY `reduction_to` '.(string)$sort.'
                            ';

			}
			else
			{
				$sql .= '
                            GROUP BY p.`id_product`
                            ORDER BY RAND()
                            ';
			}

			$result = Db::getInstance()->ExecuteS($sql);
			if ($orderBy == 'price')
				Tools::orderbyPrice($result, $orderWay);
			if (!$result)
				return false;
			return Product::getProductsProperties($id_lang, $result);
		}

		public function getList($id_lang)
		{
			/*product list code*/
			if (_PS_VERSION_ > '1.4.0.0')
			{
				$current_date = date('Y-m-d H:i:s');
				$sql         = mysql_query('
                SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
                 pl.`meta_keywords`, pl.`meta_title`,
                pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
                 sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` &&
				 pl.`id_lang` = '.(int)$this->context->language->id.')
                LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
                LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` &&
				 il.`id_lang` = '.(int)$this->context->language->id.')
                LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                           && tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                           && tr.`id_state` = 0)
                LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
                LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = 1 && p.`price` > 0 
                && sp.`to` < "'.pSQL($current_date).'"');
			}
			/*end product list*/
			$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
			if (!$result)
				return false;
			return CountdownSpecials::getProductsProperties((int)$this->context->language->id, $result);
		}

		public function getPricesDrop2($id_lang, $page_number = 0, $nbProducts, $count = false,
			$orderBy = null,
			$orderWay = null, $beginning = false, $ending = false, Context $context = null)
		{
			$front     = true;
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());
			$current_date = date('Y-m-d H:i:s');
			$ids_product = $this->_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending));
			$groups      = FrontController::getCurrentCustomerGroups();
			$sqlGroups   = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');

			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql = '
        SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
         pl.`meta_keywords`, pl.`meta_title`,
        pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
         sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                   && tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                      && tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
        WHERE 1
        && sp.`from` < sp.`to`
        && sp.`to` >= "'.pSQL($current_date).'"
        && p.`active` = 1 && p.`price` > 0 
        && p.`show_price` = 1
        && p.`id_product` IN (
            SELECT cp.`id_product`
            FROM `'._DB_PREFIX_.'category_group` cg
            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
            WHERE cg.`id_group` '.(string)$sqlGroups.'
        )
        GROUP BY p.`id_product`
        ORDER BY sp.`to` '.$sort.'
        LIMIT '.(int)($page_number * $nbProducts).', '.(int)($nbProducts);
			}
			if (_PS_VERSION_ > '1.5.0.0')
			{
				$sql = '
        SELECT p.*, ps.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
         pl.`meta_keywords`, pl.`meta_title`,
        pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
         sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p

        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
           LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                   && tr.`id_country` = '.(int)Context::getContext()->country->id.'
                   && tr.`id_state` = 0)
                   LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
        WHERE 1
        && sp.`from` < sp.`to`
        && sp.`to` >= "'.pSQL($current_date).'"
        && p.`active` = 1 && p.`price` > 0 
        && p.`show_price` = 1
        && p.`id_product` IN (
            SELECT cp.`id_product`
            FROM `'._DB_PREFIX_.'category_group` cg
            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
            WHERE cg.`id_group` '.(string)$sqlGroups.'
        )
&& ps.id_shop = '.(int)$this->context->shop->id.'
 && pl.id_shop = '.(int)$this->context->shop->id.'
        GROUP BY p.`id_product`
        ORDER BY sp.`to` '.$sort.'
        LIMIT '.(int)($page_number * $nbProducts).', '.(int)($nbProducts);
			}

			$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
			if ($orderBy == 'price')
				Tools::orderbyPrice($result, $orderWay);
			if (!$result)
				return false;
			return CountdownSpecials::getProductsProperties($id_lang, $result);
		}

		/*header*/
		public function getPricesDrop2header($id_lang, $page_number = 0, $nbProducts,
			$count = false, $orderBy = null,
			$orderWay = null, $beginning = false, $ending = false, Context $context = null)
		{
			$front     = true;
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());

			$current_date = date('Y-m-d H:i:s');
			$ids_product = CountdownSpecials::_getProductIdByDate((!$beginning ? $current_date : $beginning),
				(!$ending ? $current_date : $ending));
			$groups      = FrontController::getCurrentCustomerGroups();
			$sqlGroups   = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');

			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql = '
        SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
         pl.`meta_keywords`, pl.`meta_title`,
        pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name,
         sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                   && tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                      && tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
        WHERE 1
        && sp.`from` < sp.`to`
        && sp.`to` >= "'.pSQL($current_date).'"
        && p.`active` = 1 && p.`price` > 0 
        && p.`show_price` = 1
        '.((!$beginning && !$ending) ? ' && p.`id_product` IN
		('.((is_array($ids_product) && count($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
        && p.`id_product` IN (
            SELECT cp.`id_product`
            FROM `'._DB_PREFIX_.'category_group` cg
            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
            WHERE cg.`id_group` '.(string)$sqlGroups.'
        )
        GROUP BY p.`id_product`
        ORDER BY sp.`to` '.(string)$sort;
			}
			if (_PS_VERSION_ > '1.5.0.0')
			{
				$sql = '
        SELECT p.*, ps.*,pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
         pl.`meta_keywords`, pl.`meta_title`,
        pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name` AS manufacturer_name, sp.`from`
         AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
           LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                   && tr.`id_country` = '.(int)Context::getContext()->country->id.'
                   && tr.`id_state` = 0)
                   LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
        WHERE 1
        && sp.`from` < sp.`to`
        && sp.`to` >= "'.pSQL($current_date).'"
        && p.`active` = 1 && p.`price` > 0 
        && p.`show_price` = 1
        '.((!$beginning && !$ending) ? ' && p.`id_product` IN
         ('.((is_array($ids_product) && count($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
        && p.`id_product` IN (
            SELECT cp.`id_product`
            FROM `'._DB_PREFIX_.'category_group` cg
            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
            WHERE cg.`id_group` '.(string)$sqlGroups.'
        )
&& ps.id_shop = '.(int)$this->context->shop->id.'
&& pl.id_shop = '.(int)$this->context->shop->id.'
       GROUP BY p.`id_product`
        ORDER BY sp.`to` '.$sort;
			}
			$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
			if ($orderBy == 'price')
				Tools::orderbyPrice($result, $orderWay);
			if (!$result)
				return false;
			return CountdownSpecials::getProductsProperties($id_lang, $result);
		}

		/**/
		public function getPricesDrop2T($id_lang, $page_number = 0, $nbProducts, $count = false,
			$orderBy = null,
			$orderWay = null, $beginning = false, $ending = false)
		{
			$sort      = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$psversion = _PS_VERSION_;
			if (!Validate::isBool($count))
				die(Tools::displayError());
			$current_date = date('Y-m-d H:i:s');
			$ids_product = CountdownSpecials::_getProductIdByDate((!$beginning ? $current_date : $beginning), (!$ending ? $current_date : $ending));
			$groups      = FrontController::getCurrentCustomerGroups();
			$sqlGroups   = (count($groups) ? 'IN ('.implode(',', $groups).')' : '= 1');
			$sql         = '

        SELECT p.*, pl.`description`, pl.`description_short`, pl.`link_rewrite`, pl.`meta_description`,
         pl.`meta_keywords`, pl.`meta_title`,
        pl.`name`, p.`ean13`, p.`upc`, i.`id_image`, il.`legend`, t.`rate`, m.`name`
         AS manufacturer_name, sp.`from` AS  reduction_from,  sp.`to` AS reduction_to, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON
		 (p.`id_product` = pl.`id_product` && pl.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_product` = p.`id_product` && i.`cover` = 1)
        LEFT JOIN `'._DB_PREFIX_.'image_lang` il ON
		 (i.`id_image` = il.`id_image` && il.`id_lang` = '.(int)($id_lang).')
        LEFT JOIN `'._DB_PREFIX_.'tax_rule` tr ON
		 (p.`id_tax_rules_group` = tr.`id_tax_rules_group`
                                                   && tr.`id_country` = '.(int)Country::getDefaultCountryId().'
                                                      && tr.`id_state` = 0)
        LEFT JOIN `'._DB_PREFIX_.'tax` t ON (t.`id_tax` = tr.`id_tax`)
        LEFT JOIN `'._DB_PREFIX_.'manufacturer` m ON (m.`id_manufacturer` = p.`id_manufacturer`)
        WHERE 1
        && sp.`from` < sp.`to`
        && sp.`to` >= "'.pSQL($current_date).'"
        && p.`active` = 1 && p.`price` > 0 
        && p.`show_price` = 1
        '.((!$beginning && !$ending) ? ' && p.`id_product` 
		IN ('.((is_array($ids_product) && count($ids_product)) ? implode(', ', $ids_product) : 0).')' : '').'
        && p.`id_product` IN (
            SELECT cp.`id_product`
            FROM `'._DB_PREFIX_.'category_group` cg
            LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_category` = cg.`id_category`)
            WHERE cg.`id_group` '.(string)$sqlGroups.'
       )
        GROUP BY p.`id_product`
        LIMIT 2
    ';

			$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($sql);
			if ($orderBy == 'price')
				Tools::orderbyPrice($result, $orderWay);
			if (!$result)
				return false;
			return CountdownSpecials::getProductsProperties($id_lang, $result);
		}

		public function getProductProperties($id_lang, $row)
		{
			if (!$row['id_product'])
				return false;
			$specific_prices = '';
			// Product::getDefaultAttribute is only called if id_product_attribute is missing from the SQL query at the origin of it: consider adding it in order to avoid unnecessary queries
			$row['allow_oosp'] = Product::isAvailableWhenOutOfStock($row['out_of_stock']);
			if ((!isset($row['id_product_attribute']) || !$row['id_product_attribute']) && ((isset($row['cache_default_attribute']) && ($ipa_default = $row['cache_default_attribute']) !== null) || ($ipa_default = Product::getDefaultAttribute($row['id_product'], !$row['allow_oosp']))))
				$row['id_product_attribute'] = $ipa_default;
			if (!isset($row['id_product_attribute']))
				$row['id_product_attribute'] = 0;
			// Tax
			$usetax   = Tax::excludeTaxeOption();
			$cacheKey = $row['id_product'].'-'.$row['id_product_attribute'].'-'.$id_lang.'-'.(int)($usetax);

			if (array_key_exists($cacheKey, $this->producPropertiesCache))
				return $this->producPropertiesCache[$cacheKey];
			// Datas
			$link                   = new Link();
			$row['category']        = Category::getLinkRewrite((int)$row['id_category_default'], (int)($id_lang));
			$row['link']            = $link->getProductLink((int)$row['id_product'], $row['link_rewrite'], $row['category'], $row['ean13']);
			$row['attribute_price'] = (isset($row['id_product_attribute']) && $row['id_product_attribute'])
				? (float)(Product::getProductAttributePrice($row['id_product_attribute'])) : 0;
			$row['price_tax_exc']   = Product::getPriceStatic((int)$row['id_product'], false, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null), ($this->_taxCalculationMethod == PS_TAX_EXC ? 2 : 6));
			if ($this->_taxCalculationMethod == PS_TAX_EXC)
			{
				$row['price_tax_exc'] = Tools::ps_round($row['price_tax_exc'], 2);
				$row['price']         = Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null), 6);
			}
			else
				$row['price'] = Tools::ps_round(Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null), 6), 2);
			$row['reduction']               = Product::getPriceStatic((int)($row['id_product']),
				(bool)$usetax, (int)($row['id_product_attribute']), 6, null, true, true, 1, true, null, null, null, $specific_prices);
			$row['specific_prices']         = $specific_prices;
			$row['price_without_reduction'] = Product::getPriceStatic((int)$row['id_product'], true, ((isset($row['id_product_attribute']) && !empty($row['id_product_attribute'])) ? (int)($row['id_product_attribute']) : null), 6, null, false, false);
			if ($row['id_product_attribute'])
				$row['quantity'] = Product::getQuantity((int)$row['id_product'], $row['id_product_attribute'],
					isset($row['cache_is_pack']) ? $row['cache_is_pack'] : null);
			$row['id_image']    = Product::defineProductImage($row, $id_lang);
			$row['features']    = Product::getFrontFeaturesStatic((int)$id_lang, $row['id_product']);
			$row['attachments'] = ((!isset($row['cache_has_attachments']) || $row['cache_has_attachments']) ?

				Product::getAttachmentsStatic((int)($id_lang), $row['id_product']) : array());
			// Pack management
			$row['pack']        = (!isset($row['cache_is_pack']) ? Pack::isPack($row['id_product']) : (int)$row['cache_is_pack']);
			$row['packItems']   = $row['pack'] ? Pack::getItemTable($row['id_product'], $id_lang) : array();
			$row['nopackprice'] = $row['pack'] ? Pack::noPackPrice($row['id_product']) : 0;
			if ($row['pack'] && !Pack::isInStock($row['id_product']))
				$row['quantity'] = 0;
			$this->producPropertiesCache[$cacheKey] = $row;
			return $this->producPropertiesCache[$cacheKey];
		}

		public function getProductsProperties($id_lang, $query_result)
		{
			$resultsArray = array();
			foreach ($query_result as $row)
				if ($row2 = $this->getProductProperties($id_lang, $row))
					$resultsArray[] = $row2;
			return $resultsArray;
		}

		public function getTaxCalculationMethod($id_customer = null)
		{
			if ($id_customer)
				CountdownSpecials::initPricesComputation((int)($id_customer));
			return (int)($this->_taxCalculationMethod);
		}

		public function _getProductIdByDate($beginning, $ending, Context $context = null)
		{
			$front       = true;
			$current_date = date('Y-m-d H:M:S');
			$id_group    = (int)($this->context->customer->id) ?
				(int)(Customer::getDefaultGroupId((int)($this->context->customer->id))) : _PS_DEFAULT_CUSTOMER_GROUP_;
			$id_address  = $this->context->cart->{Configuration::get('PS_TAX_ADDRESS_TYPE')};
			$ids         = Address::getCountryAndState($id_address);
			$id_country  = (int)($ids['id_country'] ?
				$ids['id_country'] : Configuration::get('PS_COUNTRY_DEFAULT'));
			if (_PS_VERSION_ < '1.5.0.0')
				return SpecificPrice::getProductIdByDate((int)(Shop::getCurrentShop()),
					(int)($this->context->currency->id), $id_country, $id_group, $current_date, $current_date);
			else
				return SpecificPrice::getProductIdByDate(Context::getContext()->shop->id,
					(int)($this->context->currency->id), $id_country, $id_group, $current_date, $current_date);
		}

		public function productpage()
		{
			$id_product = '';
			$result     = Db::getInstance()->ExecuteS('
                            SELECT *.p
                            FROM `'._DB_PREFIX_.'product` p
                            WHERE p.active = 1 && p.id_product = '.(int)$id_product);
		}

		public function hookTop($params)
		{
			$id_cat  = (int)(Tools::getValue('id_category'));
			$categ = $this->getPricesDropshPR($id_cat);
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbrtop     = Configuration::get('COUNTDOWNSPECIALS_NBRTOP');
			$respo     = Configuration::get('COUNTDOWNSPECIALS_RESPO');
			$widtht     = Configuration::get('COUNTDOWNSPECIALS_WIDTHT');
			$heightt    = Configuration::get('COUNTDOWNSPECIALS_HEIGHTT');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$color      = Configuration::get('COUNTDOWNSPECIALS_COLOR');
			$wt         = Configuration::get('COUNTDOWNSPECIALS_WT');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$imagecs    = Configuration::get('COUNTDOWNSPECIALS_IMAGECS');
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$slidercs   = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$but        = Configuration::get('COUNTDOWNSPECIALS_BUT');
			$home6      = Configuration::get('COUNTDOWNSPECIALS_HOME6');
			$ht         = $wt * 60 / 275;
			$sa         = $this->getImagesID($imagecs);
			$imagecs    = $sa[0]['name'];
			if ($sort == 'ASC')
				$sort = 'DESC';
			else
				$sort = 'ASC';
			$psversion = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id,
					$page_number = 0, $nbrtop, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id,
					$page_number = 0, $nbrtop, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd2[] = $priceDrop;
			
					
$ptypee = Page::getCurrentId();
$pety = $this->getPages($ptypee);
foreach ($pety as $pet)
{
$petid = $pet['id_page'];
$petnam = $pet['name'];
$pettyp = $pet['id_page_type'];
}
if (_PS_VERSION_ > '1.5.0.0' && _PS_VERSION_ < '1.6.0.0')
{

			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$catw     = Configuration::get('COUNTDOWNSPECIALS_CATW');
			$wthcat        = Configuration::get('COUNTDOWNSPECIALS_CATW');
			$catcolor     = Configuration::get('COUNTDOWNSPECIALS_CATCOLOR');
			$catcolor2    = Configuration::get('COUNTDOWNSPECIALS_CATCOLOR2');
			$hthcat        = $wthcat * 60 / 275;
			$this->context->smarty->assign(array(
				'categs'  => $categ,
				'catcolor'     => $catcolor,
				'styletime'  => $styletime,
				'catw'     => $catw,
				'cathth'        => $hthcat,
				'catcolor2'    => $catcolor2,
				'psversion'    => _PS_VERSION_,
			));
}
if (_PS_VERSION_ < '1.5.0.0')
{
$ptypee1 = CountdownSpecials::getPageTypeByName('category');
$ptypee2 = CountdownSpecials::getPageTypeByName('category.php');
}
else
{
$ptypee1 = Page::getPageTypeByName('category');
		$ptypee2 = Page::getPageTypeByName('category.php');
}
		
if (_PS_VERSION_ > '1.6.0.0')
	{
	if ($pettyp == $ptypee1 || $pettyp == $ptypee2)
		$this->context->smarty->assign(array('productlist' => CountdownSpecials::productList()));
}
			$this->context->smarty->assign(array(
			'categs'  => $categ,
				'productsd2'  => $productsd2,
				'imagecs'     => $imagecs,
				'home6'     => $home6,
				'colort'      => $color,
				'wt'          => $wt,
				'ht'          => $ht,
				'respo'          => $respo,
				'widtht'      => $widtht,
				'heightt'     => $heightt,
				'slidercs'    => $slidercs,
				'styletime'   => $styletime,
				'lang'        => 'text_'.(int)$this->context->language->id
			));
			return $this->display(__FILE__, 'views/templates/front/countdownspecials-top.tpl');
		}
		public function copy($source, $destination, $stream_context = null)
		{
		if (is_null($stream_context) && !preg_match('/^https?:\/\//', $source))
			return @copy($source, $destination);
		return @file_put_contents($destination, Tools::file_get_contents($source, false, $stream_context));
		}
		
		public function getPageTypeByName($name)
		{
		if ($value = Db::getInstance()->getValue('
				SELECT id_page_type
				FROM '._DB_PREFIX_.'page_type
				WHERE name = \''.pSQL($name).'\''))
			return $value;

	//	Db::getInstance()->insert('page_type', array('name' => pSQL($name)));

		return Db::getInstance()->Insert_ID();
		}
	
public function getPages($pety)
	{
		$result = Db::getInstance()->ExecuteS('
		SELECT pt.`id_page_type`,pt.`name`,p.`id_page_type`,p.`id_page`,p.`id_object`  
		FROM `'._DB_PREFIX_.'page` p
		LEFT JOIN `'._DB_PREFIX_.'page_type` pt ON p.`id_page_type` = pt.`id_page_type`
		WHERE p.`id_page` = '.(int)$pety.' LIMIT 1');
		return ($result);
	}
		public function hookHome($params)
		{
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbr        = Configuration::get('COUNTDOWNSPECIALS_NBR');
				$respo        = Configuration::get('COUNTDOWNSPECIALS_RESPO');
					$respop        = Configuration::get('COUNTDOWNSPECIALS_RESPOP');
			$width3     = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$width3h    = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$hpcp       = Configuration::get('COUNTDOWNSPECIALS_HP');

			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$colorbg    = Configuration::get('COUNTDOWNSPECIALS_COLORBG');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$grid       = Configuration::get('COUNTDOWNSPECIALS_GRID');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$rad        = Configuration::get('COUNTDOWNSPECIALS_RAD');
			$wth        = Configuration::get('COUNTDOWNSPECIALS_WTH');
			$home6      = Configuration::get('COUNTDOWNSPECIALS_HOME6');
			$hth        = $wth * 60 / 275;
			$listw      = Configuration::get('COUNTDOWNSPECIALS_LISTW');
			$imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH');
			$imageh     = Configuration::get('COUNTDOWNSPECIALS_IMAGEH');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$sa         = $this->getImagesID($imageh);
			$imageh     = $sa[0]['name'];
			$psversion  = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id,
					$page_number = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id,
					$page_number = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);

			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd[] = $priceDrop;

			$this->context->smarty->assign(array(
				'productsd'  => $productsd,
				'color2'     => $color2,
				'hpcp'       => $hpcp,
				'widthlo3'   => $widthlo3,
				'margin'     => $margin,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'align'      => $align,
				'width3'     => $width3,
				'wth'        => $wth,
				'hth'        => $hth,
				'respop'        => $respop,
				'width3h'    => $width3h,
				'delaycs'    => $delaycs,
				'grid'       => $grid,
				'rad'        => $rad,
				'colorbg'    => $colorbg,
				'listw'      => $listw,
				'imageh'     => $imageh,
				'imagesizeh' => $imagesizeh,
				'nbrcs'      => $nbr
			));
			if ($home6 != 'Tab')
				return $this->display(__FILE__, 'views/templates/front/countdownspecials.tpl');

		}
	

		public function hookdisplayTopColumn($params)
		{
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbr        = Configuration::get('COUNTDOWNSPECIALS_NBR');
				$respo        = Configuration::get('COUNTDOWNSPECIALS_RESPO');
			$width3     = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$width3h    = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$hpcp       = Configuration::get('COUNTDOWNSPECIALS_HP');

			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$colorbg    = Configuration::get('COUNTDOWNSPECIALS_COLORBG');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$grid       = Configuration::get('COUNTDOWNSPECIALS_GRID');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$rad        = Configuration::get('COUNTDOWNSPECIALS_RAD');
			
			$wth        = Configuration::get('COUNTDOWNSPECIALS_WT');
			$home6      = Configuration::get('COUNTDOWNSPECIALS_HOME6');
			$hth        = $wth * 60 / 275;
			$listw      = Configuration::get('COUNTDOWNSPECIALS_LISTW');
			$imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH');
			$imageh     = Configuration::get('COUNTDOWNSPECIALS_IMAGEH');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$sa         = $this->getImagesID($imageh);
			$imageh     = $sa[0]['name'];
			$psversion  = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id,
					$page_number = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id,
					$page_number = 0, $nbr, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);

			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd[] = $priceDrop;

			$this->context->smarty->assign(array(
				'productsd'  => $productsd,
				'color2'     => $color2,
				'hpcp'       => $hpcp,
				'widthlo3'   => $widthlo3,
				'margin'     => $margin,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'align'      => $align,
				'width3'     => $width3,
				'wth'        => $wth,
				'hth'        => $hth,
				'respo'        => $respo,
				'width3h'    => $width3h,
				'delaycs'    => $delaycs,
				'grid'       => $grid,
				'rad'        => $rad,
				'colorbg'    => $colorbg,
				'listw'      => $listw,
				'imageh'     => $imageh,
				'imagesizeh' => $imagesizeh,
				'nbrcs'      => $nbr
			));
			if ($home6 == 'Tab')
				return $this->display(__FILE__, 'views/templates/front/countdownspecials-tc.tpl');

		}
		public function hookLeftColumn($params)
		{
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$countdowns = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbr3       = Configuration::get('COUNTDOWNSPECIALS_NBR3');
			$height     = Configuration::get('COUNTDOWNSPECIALS_HEIGHT');
			$nbr2       = Configuration::get('COUNTDOWNSPECIALS_NBR2');
			$imagesizec = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEC');
			$imagec     = Configuration::get('COUNTDOWNSPECIALS_IMAGEC');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$wtb        = Configuration::get('COUNTDOWNSPECIALS_WTB');
			$htb        = $wtb * 60 / 275;
			$sa         = $this->getImagesID($imagec);
			$imagec     = $sa[0]['name'];
			$psversion  = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id,
					$page_number = 0, $nbr3, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id,
					$page_number = 0, $nbr3, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$countdowns[] = $priceDrop;
			$this->context->smarty->assign(array(
				'countdowns' => $countdowns,
				'height'     => $height,
				'nbr2'       => $nbr2,
				'wtb'        => $wtb,
				'htb'        => $htb,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'imagesizec' => $imagesizec,
				'imagec'     => $imagec
			));

			return $this->display(__FILE__, 'views/templates/front/countdownspecials-column.tpl');
		}

		public function hookRightColumn($params)
		{
			return $this->hookLeftColumn($params);
		}

		public function productList()
		{
			$productsdd = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$this->context->smarty->assign(array(
				'styletime' => $styletime
			));
			$front        = true;
			$styletime    = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$pagination   = Configuration::get('COUNTDOWNSPECIALS_PAGINATION');
			$colorp       = Configuration::get('COUNTDOWNSPECIALS_COLORP');
			$fsp          = Configuration::get('COUNTDOWNSPECIALS_FSP');
			$paginationn  = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN');
			$pagination2  = Configuration::get('COUNTDOWNSPECIALS_PAGINATION2');
			$paginationn2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2');
			$widthlo      = Configuration::get('COUNTDOWNSPECIALS_WIDTH');
			$slidercs     = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS');
			$delaycs      = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$psversion    = _PS_VERSION_;
			$enabledp     = Configuration::get('COUNTDOWNSPECIALS_ENABLEDP');
			$disabledp    = Configuration::get('COUNTDOWNSPECIALS_DISABLEDP');
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropshea((int)((int)$this->context->language->id),
					$page_number = 0, 10, $count = false, $orderBy = null, $orderWay = null, $beginning = 1, $ending = 10);

			else
				$pricesDrop = CountdownSpecials::getPricesDrop2header((int)((int)$this->context->language->id),
					$page_number = 0, 10, $count = false, $orderBy = null, $orderWay = null, $beginning = 1, $ending = 10);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsdd[] = $priceDrop;
			return $productsdd;
		}

				public function hookHeader($params)
		{
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			$productsdd   = '';
			/*timezone*/

			/**/
			$language = $this->context->language->iso_code;
			if ($language == 'en')
			
			$language = '';
			
			else
			
			$language = '-'.$language;
			
			$front        = true;
			$styletime    = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$pagination   = Configuration::get('COUNTDOWNSPECIALS_PAGINATION');
			$colorp       = Configuration::get('COUNTDOWNSPECIALS_COLORP');
			$colort       = Configuration::get('COUNTDOWNSPECIALS_COLOR');
			$fsp          = Configuration::get('COUNTDOWNSPECIALS_FSP');
			$respo          = Configuration::get('COUNTDOWNSPECIALS_RESPO');
			$cront          = Configuration::get('COUNTDOWNSPECIALS_CRONT');
			$paginationn  = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN');
			$pagination2  = Configuration::get('COUNTDOWNSPECIALS_PAGINATION2');
			$paginationn2 = Configuration::get('COUNTDOWNSPECIALS_PAGINATIONN2');
			$widthlo      = Configuration::get('COUNTDOWNSPECIALS_WIDTH');
			$slidercs     = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS');
			$delaycs      = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$but          = Configuration::get('COUNTDOWNSPECIALS_BUT');
			$cw           = Configuration::get('COUNTDOWNSPECIALS_CW');
			$pbs           = Configuration::get('COUNTDOWNSPECIALS_PBS');
			$cf           = Configuration::get('COUNTDOWNSPECIALS_CF');
			$respop        = Configuration::get('COUNTDOWNSPECIALS_RESPOP');
			$psversion    = _PS_VERSION_;
			$enabledp     = Configuration::get('COUNTDOWNSPECIALS_ENABLEDP');
			$disabledp    = Configuration::get('COUNTDOWNSPECIALS_DISABLEDP');
			if ($cront == null)
			$cront = 0;
			if ($enabledp == null)
			$enabledp = 0;
			if ($disabledp == null)
			$disabledp = 0;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropshea($this->context->language->id,
					$page_number = 0, 10, $count = false, $orderBy = null, $orderWay = null, $beginning = 1, $ending = 10);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2header($this->context->language->id,
					$page_number = 0, 10, $count = false, $orderBy = null, $orderWay = null, $beginning = 1, $ending = 10);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsdd[] = $priceDrop;

			/*    $id_product = (int)(Tools::getValue('id_product'));

            $product = new Product($id_product, true, (int)((int)$this->context->language->id));*/

				/*disable products*/

			if ($enabledp == 1 && $cront == 0)
			{
				if ($psversion > '1.4.0.0' && $psversion < '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*, sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = \'1\'
                && sp.`to` < "'.pSQL($current_date).'"');
				}

				if ($psversion > '1.5.0.0')
				{
					
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*,ps.*,  sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
            
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = \'1\'
                && ps.`id_shop` = \''.(int)$this->context->shop->id.'\'
                && sp.`to` < "'.pSQL($current_date).'"');
		
				}
			/*	
			print_r( '1-
                SELECT p.*,ps.*,  sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
            
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = \'1\'
                && ps.`id_shop` = \''.$this->context->shop->id.'\'
                && sp.`to` < "'.pSQL($current_date).'"');
				*/
				if ($psversion < '1.4.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('SELECT p.*
            FROM `'._DB_PREFIX_.'product` p
            WHERE p.reduction_from < p.reduction_to && p.reduction_to < \''.pSQL($current_date).'\' && p.`active` = \'1\'');
				}

				$veridc = mysql_fetch_assoc($sorgudc);
				do
				{
					
					$num_rows = mysql_num_rows($sorgudc);
					if ($num_rows != null)
					{
					
						Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` = \'0\'
						WHERE `'._DB_PREFIX_.'product`.`id_product` = \''.@(int)$veridc['id_product'].'\';');
						
						if (_PS_VERSION_ > '1.5.0.0')
						{
							Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product_shop` SET `active` = \'0\'
							WHERE `'._DB_PREFIX_.'product_shop`.`id_product` = \''.@(int)$veridc['id_product'].'\'  &&
							 `'._DB_PREFIX_.'product_shop`.`id_shop` = \''.(int)$this->context->shop->id.'\';');
							 
						}
							 
print_r('UPDATE `'._DB_PREFIX_.'product_shop` SET `active` = \'0\'
							WHERE `'._DB_PREFIX_.'product_shop`.`id_product` = \''.@(int)$veridc['id_product'].'\'  &&
							 `'._DB_PREFIX_.'product_shop`.`id_shop` = \''.(int)$this->context->shop->id.'\';');
					}

				} while (@$veridc = mysql_fetch_assoc($sorgudc));

			}

			/*enable them*/



			if ($disabledp == '1' && $cront == 0)
			{
				if ($psversion > '1.4.0.0' && $psversion < '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
        SELECT p.*,  sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        WHERE 1
        && sp.`from` < sp.`to`
        && p.`active` = \'0\'
        && sp.`from` < "'.pSQL($current_date).'" && sp.`to` > "'.pSQL($current_date).'"');

				}

				if ($psversion > '1.5.0.0')
				{
				
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*, ps.*, sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                   LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
             
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = \'0\'
               && ps.`id_shop` = \''.(int)$this->context->shop->id.'\'
                && sp.`from` < "'.pSQL($current_date).'" && sp.`to` > "'.pSQL($current_date).'"');
				}
				/*
				print_r( '3-
                SELECT p.*, ps.*, sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                   LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
             
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = \'0\'
               && ps.`id_shop` = \''.$this->context->shop->id.'\'
                && sp.`from` < "'.pSQL($current_date).'"');
				*/
				if ($psversion < '1.4.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('SELECT p.*
            FROM `'._DB_PREFIX_.'product` p
    
            WHERE p.`reduction_from` < p.`reduction_to` && p.`reduction_from` < \''.pSQL($current_date).'\' && p.`reduction_to` > "'.pSQL($current_date).'" && p.`active` = \'0\'');
				}



				$veridc = mysql_fetch_assoc($sorgudc);

				do
				{

					$num_rows = mysql_num_rows($sorgudc);

					if ($num_rows != null)
					{

						Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` = \'1\'
						 WHERE `'._DB_PREFIX_.'product`.`id_product` = '.@(int)$veridc['id_product'].';');
						if (_PS_VERSION_ > '1.5.0.0')
							Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product_shop` SET `active` = \'1\'
							 WHERE `'._DB_PREFIX_.'product_shop`.`id_product` = '.@(int)$veridc['id_product'].'  &&
							  `'._DB_PREFIX_.'product_shop`.`id_shop` = \''.(int)$this->context->shop->id.'\';');	  
					}

				} while ($veridc = mysql_fetch_assoc($sorgudc));


			}
			$special = Product::getRandomSpecial((int)($params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY');

$timezone = new DateTimeZone(Configuration::get('PS_TIMEZONE'));
$offset = $timezone->getOffset(new DateTime('now')); 
$timenow = date('d.m.Y H:i:s', time());
			$this->context->smarty->assign(array(
				'pagination'                     => $pagination,
				'paginationn'                    => $paginationn,
				'pagination2'                    => $pagination2,
				'styletime'                      => $styletime,
				'paginationn2'                   => $paginationn2,
				'psversion'                      => $psversion,
				'colorpcs'                       => $colorp,
				'fsp'                            => $fsp,
				'colort'                            => $colort,
				'productlisthp' => CountdownSpecials::productList(),
				'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
				'special'                        => $special,
				'widthlo'                        => $widthlo,
				'timenow'                        => $timenow,
				'respop'                        => $respop,
				'tzone' => ($offset < 0 ? '' : '+').$offset / 60 / 60,
					
				'slidercs'                       => $slidercs,
				'delaycs'                        => $delaycs,
				'but'                            => $but,
				'cf'                             => $cf,
					'pbs'                             => $pbs,
				'cw'                             => $cw,

			));

			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/ticker.js');
				if ($but == '10')
				{
					Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/countdown.js');
					//Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/js/knob.js');
					//Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/js/thro.js');
				}
				if ($but == '11')
					Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/circcountdown.js');
				if ($but > '0' && $but < '10')
				{
					Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/jquery.plugin.js');
				Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/jquery.countdown.js');
					Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/jquery.countdown'.$language.'.js');
				}
				Tools::addCSS(__PS_BASE_URI__.'modules/countdownspecials/views/css/jquery.countdown.css', 'all');
					if ($respo == '1')
				Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/slippry.js');
				else
								Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/fadeSlideShow.js');

				
			}

			if (_PS_VERSION_ > '1.5.0.0')
			{
				$this->context->controller->addJS(($this->_path).'views/js/ticker.js');
				$this->context->controller->addJS(($this->_path).'views/js/jquery.simplyscroll.js');
				if ($but == '10')
				{
					$this->context->controller->addJS(($this->_path).'views/js/countdown.js');
					//  $this->context->controller->addJS(($this->_path).'js/thro.js');
					//	 $this->context->controller->addJS(($this->_path).'js/knob.js');
				}
				if ($but == '11')

					$this->context->controller->addJS(($this->_path).'views/js/circcountdown.js');

				if ($but > '0' && $but < '10')
				{
				$this->context->controller->addJS(($this->_path).'views/js/jquery.plugin.js');
$this->context->controller->addJS(($this->_path).'views/js/jquery.countdown.js');
					$this->context->controller->addJS(($this->_path).'views/js/jquery.countdown'.$language.'.js');
				}
				$this->context->controller->addCSS(($this->_path).'views/css/'.((_PS_VERSION_ > '1.5.0.0') ?
				$this->context->shop->id : '').'jquery.countdown.css', 'all');
				if ($respo == '1')
				$this->context->controller->addJS(($this->_path).'views/js/slippry.js');
				else
				$this->context->controller->addJS(($this->_path).'views/js/fadeSlideShow.js');	
			}

			if ($pagination == 'yes' && _PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/views/js/easypaginate.js');
				//Tools::addJS(__PS_BASE_URI__.'modules/countdownspecials/js/jquery.simplePagination.js');
				//Tools::addCSS(__PS_BASE_URI__.'modules/countdownspecials/css/simplePagination.css', 'all');
				Tools::addCSS(__PS_BASE_URI__.'modules/countdownspecials/views/css/style.css', 'all');
			}

			if ($pagination == 'yes' && _PS_VERSION_ > '1.5.0.0')
			{
				$this->context->controller->addJS(($this->_path).'views/js/easypaginate.js');
			//$this->context->controller->addJS(($this->_path).'js/jquery.easyPaginate.js');
			//$this->context->controller->addJS(($this->_path).'js/jquery.simplePagination.js');
				//$this->context->controller->addCSS(($this->_path).'css/simplePagination.css', 'all');
				$this->context->controller->addCSS(($this->_path).'views/css/style.css', 'all');
			}
			return $this->display(__FILE__, 'views/templates/front/countdownspecials-header.tpl');

		}

		public function getProductscath($id_product)
		{
			$result = Db::getInstance()->getRow('
		SELECT SUM(od.`product_quantity`) AS totalCount
		FROM '._DB_PREFIX_.'order_detail od
		WHERE od.product_id = '.(int)$id_product.'');
			return $result['totalCount'];

		}

		public function hookextraLeft($params)
		{
			return $this->hookextraRight($params);
		}
		public function hookproductActions($params)
		{
			return $this->hookextraRight($params);
		}

		public function hookextraRight($params)
		{
			$current_date = date('Y-m-d H:i:s');
			$styletime   = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$sales       = Configuration::get('COUNTDOWNSPECIALS_SALES');
			$id_product  = (int)(Tools::getValue('id_product'));
			if ($id_product == null)
			$id_product  = (int)(Tools::getValue('id'));
		
			$result      = '
		SELECT COUNT(p.`id_product`) AS totalCount
		FROM `'._DB_PREFIX_.'product` p
		LEFT JOIN '._DB_PREFIX_.'order_detail od ON od.product_id = p.id_product
		LEFT JOIN '._DB_PREFIX_.'orders o ON od.id_order = o.id_order
		WHERE p.active = 1 AND o.valid = 1 AND p.id_product = '.(int)$id_product.'';


			$productsi = CountdownSpecials::getProductscath($id_product);
			$psversion = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
			{
				$results = Db::getInstance()->ExecuteS('
                        SELECT p.*
                        FROM `'._DB_PREFIX_.'product` p
                        WHERE p.reduction_from < p.reduction_to && p.reduction_from < \''.pSQL($current_date).'\' &&
                         p.reduction_to > \''.pSQL($current_date).'\' && p.id_product = '.(int)$id_product.' LIMIT 1');
			}
			else
			{
				$results = Db::getInstance()->ExecuteS('
                        SELECT p.*, sp.from AS reduction_from, sp.to AS reduction_to
                        FROM `'._DB_PREFIX_.'product` p
                        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                        WHERE sp.from <= sp.to && sp.from <= \''.pSQL($current_date).'\' &&
                         sp.to >= \''.pSQL($current_date).'\' && p.id_product = '.(int)$id_product.' LIMIT 1');
			}

			$this->context->smarty->assign(array(
				'results'    => $results,
				'sales'      => $sales,
				'id_product' => $id_product,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'productsi'  => $productsi
			));
			return $this->display(__FILE__, 'views/templates/front/countdownspecials-product.tpl');
		}

		public function hookshoppingCart($params)
		{
			$push       = Configuration::get('COUNTDOWNSPECIALS_PUSH');
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
				$respo  = Configuration::get('COUNTDOWNSPECIALS_RESPO');
			$nbrtop     = Configuration::get('COUNTDOWNSPECIALS_NBRTOP');
			$widtht     = Configuration::get('COUNTDOWNSPECIALS_WIDTHT');
			$heightt    = Configuration::get('COUNTDOWNSPECIALS_HEIGHTT');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$color      = Configuration::get('COUNTDOWNSPECIALS_COLOR');
			$wt         = Configuration::get('COUNTDOWNSPECIALS_WT');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$imagecs    = Configuration::get('COUNTDOWNSPECIALS_IMAGECS');
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$slidercs   = Configuration::get('COUNTDOWNSPECIALS_SLIDERCS');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$but        = Configuration::get('COUNTDOWNSPECIALS_BUT');
			$ht         = $wt * 60 / 275;
			$sa         = $this->getImagesID($imagecs);
			$imagecs    = $sa[0]['name'];
			if ($sort == 'ASC')
				$sort = 'DESC';
			else
				$sort = 'ASC';
			$psversion = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id, $page_number = 0,
					$nbrtop, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id, $page_number = 0,
					$nbrtop, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd2[] = $priceDrop;

			if ($push == 1)
			{
				$this->context->smarty->assign(array(
					'productsd2'  => $productsd2,
					'imagecs'     => $imagecs,
					'colort'      => $color,
					'wt'          => $wt,
					'ht'          => $ht,
					'respo'          => $respo,
					'productlist' => CountdownSpecials::productList(),
					'widtht'      => $widtht,
					'heightt'     => $heightt,
					'slidercs'    => $slidercs,
					'styletime'   => $styletime,
					'lang'        => 'text_'.(int)$this->context->language->id
				));
				return $this->display(__FILE__, 'views/templates/front/countdownspecials-push.tpl');
			}
		}

		public function displayFrontForm()
		{
			$beginning2 = '';
			$ending2    = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbrpage    = Configuration::get('COUNTDOWNSPECIALS_NBRPAGE');
			$width3     = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$width3h    = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$colorbg    = Configuration::get('COUNTDOWNSPECIALS_COLORBG');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$grid       = Configuration::get('COUNTDOWNSPECIALS_GRID');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$rad        = Configuration::get('COUNTDOWNSPECIALS_RAD');
			$listw      = Configuration::get('COUNTDOWNSPECIALS_LISTW');
			$imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH');
			$imageh     = Configuration::get('COUNTDOWNSPECIALS_IMAGEH');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$wth        = Configuration::get('COUNTDOWNSPECIALS_WTH');
			$hth        = $wth * 60 / 275;
			$sa         = $this->getImagesID($imageh);
			$imageh     = $sa[0]['name'];
			$psversion  = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh((int)$this->context->language->id,
					$page_number = 0, $nbrpage, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2((int)$this->context->language->id,
					$page_number = 0, $nbrpage, $count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd[] = $priceDrop;

			$this->context->smarty->assign(array(
				'productsd'  => $productsd,
				'color2'     => $color2,
				'widthlo3'   => $widthlo3,
				'margin'     => $margin,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'align'      => $align,
				'width3'     => $width3,
				'width3h'    => $width3h,
				'delaycs'    => $delaycs,
				'grid'       => $grid,
				'colorbg'    => $colorbg,
				'rad'        => $rad,
				'hth'        => $hth,
				'wth'        => $wth,
				
				'listw'      => $listw,
				'imagesizeh' => $imagesizeh,
				'imageh'     => $imageh
			));
			return $this->display(__FILE__, 'views/templates/front/countdownspecials-page.tpl');
		}

		public function deleteExp()
		{
			$orderBy     = null;
			$orderWay    = null;
			$beginning   = true;
			$ending      = false;
			$current_date = date('Y-m-d H:i:s');
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			if (_PS_VERSION_ > '1.4.0.0' && _PS_VERSION_ < '1.5.0.0')
			{
				$sql2 = '
				SELECT * FROM `'._DB_PREFIX_.'specific_price`
				WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' && sp.to < \''.pSQL($current_date).'\'
                            ';

			}

			if (_PS_VERSION_ > '1.5.0.0')
			{
				$current_date = date('Y-m-d H:i:s');
				$sql2        = '
                SELECT * FROM
                `'._DB_PREFIX_.'specific_price` sp
                WHERE sp.from < sp.to && sp.from <= \''.pSQL($current_date).'\' &&
                 sp.to < \''.pSQL($current_date).'\' && sp.id_shop = '.(int)$this->context->shop->id.'
                ';

			}

			if (_PS_VERSION_ < '1.4.0.0')
			{
				$sql2 = '
                            SELECT p.*
                            FROM `'._DB_PREFIX_.'product` p
                            WHERE p.reduction_from < p.reduction_to && p.reduction_to < \''.pSQL($current_date).'\'
                             GROUP BY p.`id_product`';
			}

			$pricesDrop2  = Db::getInstance()->ExecuteS($sql2);
			$resulttt     = mysql_query($sql2);
			$prices_drop2 = array();
			if (_PS_VERSION_ > '1.5.0.0')
			{
				foreach ($prices_drop2 as $pr)

					Db::getInstance()->Execute('DELETE FROM `'._DB_PREFIX_.'specific_price`
					 WHERE `id_specific_price` = '.(int)$pr['id_specific_price'].';');

			}
			$this->displayConfirmation($this->l('Expired time offers deleted').'<br/>');

		}
		public function hookDisplayBanner($params)
		{
				return $this->hookDisplayNav($params);
		}
public function hookDisplayNav($params)
{
	$id_cat  = (int)(Tools::getValue('id_category'));
			$categ = $this->getPricesDropshPR($id_cat);
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$catw     = Configuration::get('COUNTDOWNSPECIALS_CATW');
			$wthcat        = Configuration::get('COUNTDOWNSPECIALS_CATW');

			$catcolor     = Configuration::get('COUNTDOWNSPECIALS_CATCOLOR');
			$catcolor2    = Configuration::get('COUNTDOWNSPECIALS_CATCOLOR2');
			$hthcat        = $wthcat * 60 / 275;
			
			$this->context->smarty->assign(array(
				'categs'  => $categ,
				'catcolor'     => $catcolor,
				'styletime'  => $styletime,
				'catw'     => $catw,
				'cathth'        => $hthcat,
				'catcolor2'    => $catcolor2,
				'psversion'    => _PS_VERSION_,
			));
				return $this->display(__FILE__, 'views/templates/front/countdownspecials-nav.tpl');
}
public function getPricesDropshPR($id_cat)
{
	$current_date = date('Y-m-d H:i:s');
$sql 	= '
SELECT spr.*, sprc.*, sprg.*,cat.*
FROM `'._DB_PREFIX_.'specific_price_rule` spr
LEFT JOIN `'._DB_PREFIX_.'specific_price_rule_condition_group` sprg ON (sprg.`id_specific_price_rule` = spr.`id_specific_price_rule`)
LEFT JOIN `'._DB_PREFIX_.'specific_price_rule_condition` sprc ON (sprc.`id_specific_price_rule_condition_group` = sprg.`id_specific_price_rule_condition_group`)	
LEFT JOIN `'._DB_PREFIX_.'category` cat ON (sprc.`value` = cat.`id_parent`)										
WHERE spr.`reduction` > 0 && spr.`from` <= \''.pSQL($current_date).'\' && spr.`to` >= \''.pSQL($current_date).'\' && spr.`from` < spr.`to` && sprc.`type` = \'category\' && sprc.`value` = \''.$id_cat.'\' OR spr.`reduction` > 0 && spr.`from` <= \''.pSQL($current_date).'\' && spr.`to` >= \''.pSQL($current_date).'\' && spr.`from` < spr.`to` && sprc.`type` = \'category\' && sprc.`value` = cat.`id_parent` && cat.`id_category` = \''.$id_cat.'\'
LIMIT 1';

			$result = Db::getInstance()->ExecuteS($sql);
			if (!$result)
				return false;
			return $result;	
}
			
		public function hookDisplayHomeTab($params)
		{
			$home6 = Configuration::get('COUNTDOWNSPECIALS_HOME6');
			if ($home6 == 'Tab')
				return $this->display(__FILE__, 'views/templates/front/tab.tpl');
		}

		public function hookDisplayHomeTabContent($params)
		{
			$beginning2 = '';
			$ending2    = '';
			$productsd2 = '';
			$productsd  = '';
			$styletime  = Configuration::get('COUNTDOWNSPECIALS_STYLETIME');
			$nbr        = Configuration::get('COUNTDOWNSPECIALS_NBR');
			$home6      = Configuration::get('COUNTDOWNSPECIALS_HOME6');
			$width3     = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$width3h    = Configuration::get('COUNTDOWNSPECIALS_WIDTH3H');
			$margin     = Configuration::get('COUNTDOWNSPECIALS_MARGIN');
			$widthlo3   = Configuration::get('COUNTDOWNSPECIALS_WIDTH3');
			$hpcp       = Configuration::get('COUNTDOWNSPECIALS_HP');
			$color2     = Configuration::get('COUNTDOWNSPECIALS_COLOR2');
			$colorbg    = Configuration::get('COUNTDOWNSPECIALS_COLORBG');
			$align      = Configuration::get('COUNTDOWNSPECIALS_ALIGN');
			$grid       = Configuration::get('COUNTDOWNSPECIALS_GRID');
			$delaycs    = Configuration::get('COUNTDOWNSPECIALS_DELAYCS');
			$rad        = Configuration::get('COUNTDOWNSPECIALS_RAD');
			$wth        = Configuration::get('COUNTDOWNSPECIALS_WTH');
			$cw         = Configuration::get('COUNTDOWNSPECIALS_CW');
			$hth        = $wth * 60 / 275;
			$wth2       = 220;
			$listw      = Configuration::get('COUNTDOWNSPECIALS_LISTW');
			$imagesizeh = Configuration::get('COUNTDOWNSPECIALS_IMAGESIZEH');
			$imageh     = Configuration::get('COUNTDOWNSPECIALS_IMAGEH');
			$sort       = Configuration::get('COUNTDOWNSPECIALS_SORT');
			$sa         = $this->getImagesID($imageh);
			$imageh     = $sa[0]['name'];
			$psversion  = _PS_VERSION_;
			if ($psversion < '1.4.0.0')
				$pricesDrop = CountdownSpecials::getPricesDropsh($this->context->language->id, $page_number = 0, $nbr,
					$count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);
			else
				$pricesDrop = CountdownSpecials::getPricesDrop2($this->context->language->id, $page_number = 0, $nbr,
					$count = false, $orderBy = $sort, $orderWay = null, $beginning = $beginning2, $ending = $ending2);

			$prices_drop = array();
			if ($pricesDrop)
				foreach ($pricesDrop as $priceDrop)
					$productsd[] = $priceDrop;

			$this->context->smarty->assign(array(
				'productsd'  => $productsd,
				'color2'     => $color2,
				'hpcp'       => $hpcp,
				'widthlo3'   => $widthlo3,
				'margin'     => $margin,
				'styletime'  => $styletime,
				'psversion'  => $psversion,
				'align'      => $align,
				'width3'     => $width3,
				'wth'        => $wth,
				'wth2'       => $wth2,
				'hth'        => $hth,
				'width3h'    => $width3h,
				'delaycs'    => $delaycs,
				'grid'       => $grid,
				'rad'        => $rad,
				'colorbg'    => $colorbg,
				'listw'      => $listw,
				'imageh'     => $imageh,
				'imagesizeh' => $imagesizeh,
				'nbrcs'      => $nbr
			));
			if ($home6 == 'Tab')
				return $this->display(__FILE__, 'views/templates/front/product-list.tpl');
		}

		public function hookFooter($params)
		{
			return $this->display(__FILE__, 'views/templates/front/countdownspecials-footer.tpl');
		}
		
		public function cron()
		{
			@mysql_connect(_DB_SERVER_, _DB_USER_, _DB_PASSWD_);
			mysql_query('SET NAMES UTF8');//this is needed for UTF 8 characters - multilanguage
			mysql_select_db(_DB_NAME_);
			$productsdd   = '';
			$front        = true;
			$psversion    = _PS_VERSION_;
			$cront     = Configuration::get('COUNTDOWNSPECIALS_CRONT');
			$enabledp     = Configuration::get('COUNTDOWNSPECIALS_ENABLEDP');
			$disabledp    = Configuration::get('COUNTDOWNSPECIALS_DISABLEDP');
		

			/*    $id_product = (int)(Tools::getValue('id_product'));

            $product = new Product($id_product, true, (int)((int)$this->context->language->id));*/

			/*disable products*/

			if ($enabledp == 1 && $cront == 1)
			{
				if ($psversion > '1.4.0.0' && $psversion < '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*, sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = 1 && p.`price` > 0 
                && sp.`to` < "'.pSQL($current_date).'"');
				}

				if ($psversion > '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*,ps.*,  sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
            
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = 1 
				&& ps.`active` = 1 
				&& p.`price` > 0 
                && ps.`id_shop` = '.(int)$this->context->shop->id.'
                && sp.`to` < "'.pSQL($current_date).'"');
				}
			
				if ($psversion < '1.4.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('SELECT p.*
            FROM `'._DB_PREFIX_.'product` p
            WHERE p.reduction_from < p.reduction_to && p.reduction_to < \''.pSQL($current_date).'\' && p.`active` = 1 && p.`price` > 0 ');
				}

				$veridc = mysql_fetch_assoc($sorgudc);
				do
				{
					$num_rows = mysql_num_rows($sorgudc);
					if ($num_rows != null)
					{
						Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` = \'0\'
						WHERE `'._DB_PREFIX_.'product`.`id_product` = '.@(int)$veridc['id_product'].';');
						if (_PS_VERSION_ > '1.5.0.0')
							Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product_shop` SET `active` = \'0\'
						WHERE `'._DB_PREFIX_.'product_shop`.`id_product` = '.@(int)$veridc['id_product'].'  &&
							 `'._DB_PREFIX_.'product_shop`.`id_shop` = '.(int)$this->context->shop->id.';');

					}

				} while (@$veridc = mysql_fetch_assoc($sorgudc));

			}

			/*enable them*/



			if ($disabledp == 1 && $cront == 1)
			{
				if ($psversion > '1.4.0.0' && $psversion < '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
        SELECT p.*,  sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
        FROM `'._DB_PREFIX_.'product` p
        LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
        WHERE 1
        && sp.`from` < sp.`to`
        && p.`active` = 0
        && sp.`from` < "'.pSQL($current_date).'" && sp.`to` > "'.pSQL($current_date).'"');

				}

				if ($psversion > '1.5.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('
                SELECT p.*, ps.*, sp.`from` AS  `reduction_from`,  sp.`to` AS `reduction_to`, sp.`id_product`
                FROM `'._DB_PREFIX_.'product` p
                   LEFT JOIN `'._DB_PREFIX_.'product_shop` ps ON (p.`id_product` = ps.`id_product`)
                LEFT JOIN `'._DB_PREFIX_.'specific_price` sp ON (p.`id_product` = sp.`id_product`)
             
                WHERE 1
                && sp.`from` < sp.`to`
                && p.`active` = 0
				 && ps.`active` = 0
               && ps.`id_shop` = '.(int)$this->context->shop->id.'
                && sp.`from` < "'.pSQL($current_date).'" && sp.`to` > "'.pSQL($current_date).'"');
				}
				
				
				if ($psversion < '1.4.0.0')
				{
					$current_date = date('Y-m-d H:i:s');
					$sorgudc     = mysql_query('SELECT p.*
            FROM `'._DB_PREFIX_.'product` p
    
            WHERE p.`reduction_from` < p.`reduction_to` && p.`reduction_from` < \''.pSQL($current_date).'\' && p.`reduction_to` > "'.pSQL($current_date).'" && p.`active` = \'0\'');
				}



				$veridc = mysql_fetch_assoc($sorgudc);

				do
				{

					$num_rows = mysql_num_rows($sorgudc);

					if ($num_rows != null)
					{

						Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product` SET `active` = \'1\'
						 WHERE `'._DB_PREFIX_.'product`.`id_product` = '.@(int)$veridc['id_product'].';');
						if (_PS_VERSION_ > '1.5.0.0')
							Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'product_shop` SET `active` = \'1\'
							 WHERE `'._DB_PREFIX_.'product_shop`.`id_product` = '.@(int)$veridc['id_product'].'  &&
							  `'._DB_PREFIX_.'product_shop`.`id_shop` = '.(int)$this->context->shop->id.';');
					}

				} while ($veridc = mysql_fetch_assoc($sorgudc));


			}

		//	$special = Product::getRandomSpecial((int)($params['cookie']->id_lang)) && !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY');

	}
	}
	
}
?>