<?php
$szerokosc = SMALL_IMAGE_WIDTH+10;
$wysokosc = SMALL_IMAGE_HEIGHT+10;
$szer_tab = SMALL_IMAGE_WIDTH*2;

$info_box_contents = array();

$ciag = '';

$ile_rek = tep_db_num_rows($new_products_query);
$licznik = 1;

while ($new_products = tep_db_fetch_array($new_products_query)) {
  $new_products['products_name'] = osc_trunc_string($new_products['products_name'], 50, 1);

  if ($new_products['products_quantity']  > 0) {
    if ($new_products['products_price'] > 0) {
      $form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $new_products['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '">');
      $form_koniec = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '</form>');
      $przcisk_kup = '<input type="hidden" name="products_id" value="' . $new_products['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $new_products['products_name']);
      $ilosc = ENTRY_CANTIDAD.'&nbsp;&nbsp;<input type="text" name="quantity" value="1" maxlength="4" size="2">';
    } else {
      $form_start = '';
      $form_koniec = '';
      $przcisk_kup = '';
      $ilosc = '';
    }
  } else {
    if ( (STOCK_CHECK == 'true') && (STOCK_ALLOW_CHECKOUT != 'true') ) {
      $form_start = '';
      $form_koniec = '';
      $przcisk_kup = ' '.tep_image_button('button_sold.gif').'';
      $ilosc = '';
    } else {
      $form_start = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '<form name="buy_now_' . $new_products['products_id'] . '" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=buy_now', 'NONSSL') . '">');
      $form_koniec = ((USE_SHOP_AS_CATALOG == 'true') ? '' : '</form>');
      $przcisk_kup = '<input type="hidden" name="products_id" value="' . $new_products['products_id'] . '">'.((CZY_ZAMAWIANA_ILOSC == 1) ? '' : '<input type="hidden" name="quantity" value="1">') . tep_image_submit('button_buy_now.gif', IMAGE_BUTTON_IN_CART . ' ' . $new_products['products_name']);
      $ilosc = ENTRY_CANTIDAD.'&nbsp;&nbsp;<input type="text" name="quantity" value="1" maxlength="4" size="2">';
    }
  }

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

  //TotalB2B start
  if ($new_price = tep_get_products_special_price($new_products['products_id']) ) {
    $new_products_org['products_price'] = tep_xppp_getproductprice($new_products['products_id']);
    $new_products['products_price'] = $new_price;

    if ($new_products['products_price'] > 0) {
      if ($special_hide == 'false') {
        $query_price_to_guest_result = ALLOW_GUEST_TO_SEE_PRICES;
        if ((($query_price_to_guest_result=='true') && !(tep_session_is_registered('customer_id'))) || ((tep_session_is_registered('customer_id')))) {
          $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span>&nbsp;<span class="smallText"><s>' . $currencies->display_price($new_products['products_id'], $new_products_org['products_price'], tep_get_tax_rate($new_products['products_tax_class_id'])) . '</s></span><br><span class="productSpecialPrice">' . $currencies->display_price_nodiscount($new_products['products_id'], $new_products['products_price'],tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb) .'</span>';
        } else {
          $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . PRICES_LOGGED_IN_TEXT . '</span>';
        }
      } else {
        $cena_produktu = '<span class="Cena">' . $currencies->display_price($new_products['products_id'], $new_products_org['products_price'], tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb) .'</span>';
      }
    } else {
      $cena_produktu = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
    }
  } else {
    $new_products['products_price'] = tep_xppp_getproductprice($new_products['products_id']);
    if ($new_products['products_price'] > 0) {
      $cena_produktu = '<span class="smallText">'. TABLE_HEADING_PRICE . ':</span><br><span class="Cena">' . $currencies->display_price($new_products['products_id'],$new_products['products_price'],tep_get_tax_rate($new_products['products_tax_class_id']),1,$display_nb).'</span>';
    } else {
      $cena_produktu = '<span class="smallText"><b>'.TEMPORARY_NO_PRICE.'</b></span>';
    }
  }
  //TotalB2B end & TotalB2B end

  $ciag = $ciag . '
    <td width="'.$szer_tab.'px" align="center" valign="top" height="100%">'.$form_start.'
	   <div align="center" style="height:45px;padding:5px;width:'.$szer_tab.'px">
		  <a class="ProductTile" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']) . '">' . $new_products['products_name'] . '</a>
	   </div>
	   <div align="center">'.
	     (($new_products['products_image'] != '') ? tep_image(DIR_WS_IMAGES . $new_products['products_image'], $new_products['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT,'',$wysokosc,$szerokosc,$new_products['products_id'],tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products['products_id']),true) : '').'
	   </div>
	   <div align="center" style="padding:5px">'.$cena_produktu .'</div>';
	   if (CZY_ZAMAWIANA_ILOSC == 1 && USE_SHOP_AS_CATALOG != 'true') { $ciag = $ciag . '
 	     <div align="center" class="smallText"'.(($ilosc != '') ? ' style="padding:6px;"' : '').'>'.$ilosc.'</div>';
	   }
       $ciag = $ciag . '<div align="center">
	      <a class="ProductDescripion" href="' . tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $new_products["products_id"]) . '">'.tep_image_button('small_view.gif').'</a>&nbsp;&nbsp;' . ((USE_SHOP_AS_CATALOG == 'true') ? '' : $przcisk_kup) . '
	   </div>
    '.$form_koniec.'</td>';

	if ($licznik < $ile_rek) {
		$ciag = $ciag . '<td width="2px">'.tep_draw_separator('pixel_trans.gif', '2', '100%').'</td>';
	}
	$licznik++;
}

?>

<td align="center">

	<script type="text/javascript" language="javascript">

	var scroll;
	function scroll_fwd(s) {
		if(s) scroll = true;
		if (parseInt(document.getElementById('img_scroll').style.left) < 0) { document.getElementById('img_scroll').style.left = (parseInt(document.getElementById('img_scroll').style.left) + 8) +"px";
			} else { document.getElementById('img_scroll').style.left = "0px"; }
		wspolczynnik = (document.getElementById('scroller').offsetWidth/((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)));
		wspolczynnik_szerokosci = 1-(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
		document.getElementById('kwadrat').style.left = (((parseInt(document.getElementById('img_scroll').style.left)*-1)*wspolczynnik)*wspolczynnik_szerokosci) +"px";
		if(scroll) setTimeout("scroll_fwd()",10) }

	function scroll_rew(s) {
		if(s) scroll = true;
		if ((parseInt(document.getElementById('img_scroll').style.left)*-1) < (document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)) { document.getElementById('img_scroll').style.left = (parseInt(document.getElementById('img_scroll').style.left) - 8) +"px";
			} else { document.getElementById('img_scroll').style.left = ((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)*-1) +"px"; }
		wspolczynnik = (document.getElementById('scroller').offsetWidth/((document.getElementById('img_scroll').offsetWidth - document.getElementById('scroller').offsetWidth)));
		wspolczynnik_szerokosci = 1-(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
		document.getElementById('kwadrat').style.left = (((parseInt(document.getElementById('img_scroll').style.left)*-1)*wspolczynnik)*wspolczynnik_szerokosci) +"px";
		if(scroll) setTimeout("scroll_rew()",10)
	}

	var ie=document.all;
	var nn6=document.getElementById&&!document.all;
	var isdrag=false;
	var x;
	var dobj;
	//var szerokosc_suwaka = document.getElementById('kwadrat').offsetWidth;
	var szerokosc_suwaka = 50;

	function movemouse(e) {
	  if (isdrag) {
	    if (nn6) {
			    if (tx + e.clientX - x >= 0 && tx + e.clientX - x <= parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
					dobj.style.left = tx + e.clientX - x ;
					if (parseInt(dobj.style.left) == parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
						document.getElementById('img_scroll').style.left = (document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)*-1;
					  } else if (parseInt(dobj.style.left) == 0) {
							document.getElementById('img_scroll').style.left = 0;
					     } else {
						wspolczynnik_odchylenia = 1+(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
						ile = ((document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)/document.getElementById('scroller').offsetWidth)*(parseInt(dobj.style.left)*wspolczynnik_odchylenia);
						document.getElementById('img_scroll').style.left = (ile*-1) +"px";	} }
			} else {
				if (tx + event.clientX - x >= 0 && tx + event.clientX - x <= parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
					dobj.style.left = tx + event.clientX - x ;
					if (parseInt(dobj.style.left) == parseInt(document.getElementById('scroller').offsetWidth-szerokosc_suwaka)) {
						document.getElementById('img_scroll').style.left = (document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)*-1;
					  } else if (parseInt(dobj.style.left) == 0) {
							document.getElementById('img_scroll').style.left = 0;
					     } else {
						wspolczynnik_odchylenia = 1+(szerokosc_suwaka/document.getElementById('scroller').offsetWidth);
						ile = ((document.getElementById('img_scroll').offsetWidth-document.getElementById('scroller').offsetWidth)/document.getElementById('scroller').offsetWidth)*(parseInt(dobj.style.left)*wspolczynnik_odchylenia);
						document.getElementById('img_scroll').style.left = (ile*-1) +"px";	} }
		} return false; } }

	function selectmouse(e)  {
	  var fobj       = nn6 ? e.target : event.srcElement;
	  var topelement = nn6 ? "HTML" : "BODY";
	  while (fobj.tagName != topelement && fobj.className != "dragme") { fobj = nn6 ? fobj.parentNode : fobj.parentElement; }
	  if (fobj.className=="dragme") { isdrag = true;dobj = fobj;tx = parseInt(dobj.style.left+0);x = nn6 ? e.clientX : event.clientX;document.onmousemove=movemouse;return false; } }

	document.onmousedown=selectmouse;
	document.onmouseup=new Function("isdrag=false");

	</script>

	<div id="new_scroll" style="display:none">
	<table border="0" width="100%" cellspacing="2" cellpadding="0">
		<tr>
			<td>
				<?php
				$wysokosc = 250;
				if (CZY_ZAMAWIANA_ILOSC == 1) {
					$wysokosc = $wysokosc + 30;
				}
				if (USE_SHOP_AS_CATALOG == 'true') {
					$wysokosc = $wysokosc + 30;
				}
				?>
				<div id="scroller" style="position:relative;width:100%;height:<?php echo $wysokosc ?>px;overflow:hidden;">
					<div id="img_scroll" style="position:absolute;left:0px;top:0;white-space: nowrap;" align="center">
						<table border="0" width="100%" cellspacing="1" cellpadding="0" style="height:<?php echo $wysokosc ?>px;">
							<tr>
								<?php echo $ciag; ?>
							</tr>
						</table>
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td height="20px" valign="middle" align="center">
				<script type="text/javascript">
				ie=(document.all)?true:false
				ns=(document.getElementById&&!document.all)?true:false
				if (ns) {
				   var przegladarka = 'ff';
				} else {
				   var przegladarka = 'ie';
				}
				if (przegladarka == 'ie') {
					document.write('<div id="suwak" style="position:relative;width:100%;height:12px;overflow:hidden;background: url(<?php echo '' .DIR_WS_TEMPLATES; ?>/images/misc/pixel_silver.gif) repeat-x; background-position: center center; margin-left:-1px">');
				   } else {
					document.write('<div id="suwak" style="position:relative;width:100%;height:10px;overflow:hidden;background: url(<?php echo '' .DIR_WS_TEMPLATES; ?>/images/misc/pixel_silver.gif) repeat-x; background-position: center center; margin-left:-1px">');
				}
				</script>
				<div id="kwadrat" style="position:absolute;left:0px;top:0;white-space: nowrap;" align="center" class="dragme">
				<script type="text/javascript">
				if (przegladarka == 'ie') {
					document.write(unescape('<table border="0" cellspacing="0" cellpadding="0"><tr><td width="50px" align="center" valign="top" height="12px"><?php echo tep_image(DIR_WS_TEMPLATES . '/images/infobox/suwak.gif', 'suwak') ?><<?php echo '%2F' ?>td><<?php echo '%2F' ?>tr><<?php echo '%2F' ?>table>'));
				   } else {
					document.write(unescape('<table border="0" cellspacing="0" cellpadding="0"><tr><td width="50px" align="center" valign="top" height="10px"><?php echo tep_image(DIR_WS_TEMPLATES . '/images/infobox/suwak.gif', 'suwak') ?><<?php echo '%2F' ?>td><<?php echo '%2F' ?>tr><<?php echo '%2F' ?>table>'));
				}
				</script>
				</div>
				<script type="text/javascript">
				document.write(unescape('<<?php echo '%2F' ?>div>'));
				</script>
			</td>
		</tr>
		<tr>
			<td>
				<div id="img_scroller">
					<a href="javascript:void(0);" onmousedown="scroll_fwd(true);" onmouseup="scroll=false;" class="boxLink" style="float: left;font-weight:bold"><?php echo tep_image(DIR_WS_TEMPLATES . '/images/infobox/left.gif', 'suwak') ?></a>
					<a href="javascript:void(0);" onmousedown="scroll_rew(true);" onmouseup="scroll=false;" class="boxLink" style="float: right;font-weight:bold"><?php echo tep_image(DIR_WS_TEMPLATES . '/images/infobox/right.gif', 'suwak') ?></a>
				</div>
			</td>
		</tr>
	</table>
	</div>

    <script type="text/javascript" language="javascript">
	document.getElementById('new_scroll').style.display = 'block';
	</script>

	<noscript><br>
	<span class="smallText">Brak obslugi JavaScript</span>
	<br>&nbsp;</noscript>

</td>