<?php
/*
  www.oscGold.com (C) Kamelia-Net Jacek Krysiak
  modul oscGold wer 4.0
*/
if ( SPECIAL_PRICES_HIDE == 'false' ) {

$query_price_to_guest_result = ALLOW_GUEST_TO_SEE_PRICES;

$boxHeading = BOX_HEADING_SPECIALS;
$corner_left = 'rounded';
$corner_right = 'rounded';
$boxContent_attributes = ' align="center"';
$szerokosc = SMALL_IMAGE_WIDTH+10;
$wysokosc = SMALL_IMAGE_HEIGHT+10;

$box_base_name = 'specials_scroll';
$box_id = $box_base_name . 'Box';
$boxLink = '<a class="boxLink" href="' . tep_href_link(FILENAME_SPECIALS) . '">' .tep_image(DIR_WS_TEMPLATES . 'images/infobox/arrow_right.gif') .'</a>';

if (DISPLAY_PRICE_BRUTTO_NETTO == 'true') {
	$display_nb = 1;
  } else {
	$display_nb = 0;
}

if (!isset($customer_id)) $customer_id = 0;
	$customer_group = tep_get_customers_groups_id();
    $rp_query = tep_db_query("select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS . " s, " . TABLE_CATEGORIES . " c, " . TABLE_PRODUCTS_TO_CATEGORIES . " p2c  where c.categories_status='1' and p.products_id = p2c.products_id and p2c.categories_id = c.categories_id and p.products_status = '1' and p.products_id = s.products_id and pd.products_id = s.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' and ((s.customers_id = '" . $customer_id . "' and s.customers_groups_id = '0') or (s.customers_id = '0' and s.customers_groups_id = '" . $customer_group . "') or (s.customers_id = '0' and s.customers_groups_id = '0')) order by RAND() limit " . MAX_RANDOM_SELECT_SPECIALS);
    if (tep_db_num_rows($rp_query)) {    

	$i = 0;
    $pausecontent = Array();
    while ($random_product = tep_db_fetch_array($rp_query)) {

	  $random_product['products_price'] = tep_xppp_getproductprice($random_product['products_id']);
      $random_product['specials_new_products_price'] = tep_get_products_special_price($random_product['products_id']);
      $query_special_prices_hide_result = SPECIAL_PRICES_HIDE;

	  $random_product['products_name'] = str_replace('"','`',$random_product['products_name']);
	  $random_product['products_name'] = str_replace("'","`",$random_product['products_name']);
     
      $pausecontent[$i] .= '<div class="spec_kont">';

      if ($random_product['products_image'] != ''){
        $pausecontent[$i] .= '<div class="spec_img" align="center">';  
        $fotog = str_replace('/','%2F',tep_image(DIR_WS_IMAGES . $random_product['products_image'], $random_product['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$random_product['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']),true));
        $pausecontent[$i] .= $fotog;
        $pausecontent[$i] .= '<%2Fdiv>';
      }

	  $pausecontent[$i] .= '<div class="spec_text">';
      if ((($query_price_to_guest_result=='true') && !(tep_session_is_registered('customer_id'))) || ((tep_session_is_registered('customer_id')))) {
          $pausecontent[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50, 1) . '<%2Fa><br><br><span class="boxText"><s>' . $currencies->display_price($random_product['products_id'], $random_product['products_price'], tep_get_tax_rate($random_product['products_tax_class_id'])) . '<%2Fs><%2Fspan><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($random_product['products_id'], $random_product['specials_new_products_price'], tep_get_tax_rate($random_product['products_tax_class_id']),1,$display_nb) . '<%2Fspan>';
        } else {
          $pausecontent[$i] .= '<a class="boxLink" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $random_product['products_id']) . '">' . osc_trunc_string($random_product['products_name'], 50 ,1) . '<%2Fa><br><br><span class="smallText"><b>' .PRICES_LOGGED_IN_TEXT. '<%2Fb><%2Fspan>';
      }
      $pausecontent[$i] .= '<%2Fdiv><%2Fdiv>';
      $pausecontent[$i] = str_replace('</span>','<%2Fspan>',$pausecontent[$i]);
	  $i++;
    }

	$i = 0;
    $tablica_spec = '';
	while ($pausecontent[$i]) { $tablica_spec .= "pausecontent[".$i."] = '".$pausecontent[$i]."';"."\n"; $i++; }
	if ($i == 1) { $tablica_spec .= "pausecontent[".$i."] = '".$pausecontent[0]."';"."\n"; }

	$boxContent = '<script type="text/javascript">var pausecontent=new Array();'."\n".$tablica_spec.'new pausescroller(pausecontent, "pscroller1", "someclass", 2000);</script>';
	$boxContent .= '<noscript><span class="smallText">Brak obslugi JavaScript</span><br><br></noscript>';   
	$boxContent .= '<a class="boxLink" href="'.tep_href_link(FILENAME_SPECIALS).'"><b>'.WHATS_NEW_ALL.'</b></a>';

    include (bts_select('boxes', $box_base_name)); // BTS 1.5

    $boxLink = '';
    $boxContent_attributes = '';

}
}
?>