<table width="645"  border="0" cellpadding="0" cellspacing="0" bgcolor="#EFEFEF">
            <tr>
              <td align="left"><img src="images/jiao1.gif" width="10" height="10"></td>
              <td align="right"><img src="images/jiao2.gif" width="10" height="10"></td>
            </tr>
</table>
<table width="645" border="0" cellpadding="0" cellspacing="0" bgcolor="#EFEFEF">
<tr><td>
		<?php

//echo "sql===".$listing_sql;
  $listing_split = new splitPageResults($listing_sql, 32, 'p.products_id');
  $listing_query = tep_db_query($listing_split->sql_query);

  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>

<table border="0" width="645" cellspacing="0" cellpadding="2"  align="center">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?
$lines=7;
$lines=ceil(tep_db_num_rows($listing_query)/4);

	for($i = 1; $i <= $lines; $i++)
	{
?>
<table border="0" width="645" cellspacing="0" cellpadding="2"  align="center">
<tr>
<?
		for($j = 1; $j <= 4; $j++)
		{
			$listing = tep_db_fetch_array($listing_query);
			
			if (isset($listing['products_name']))
			{
			
	$tepproducts_name=str_replace('+',' + ',$listing['products_name']);
	$tepproducts_name=str_replace('/',' / ',$tepproducts_name);
	$tepproducts_name=str_replace('  /  ',' / ',$tepproducts_name);
	$tepproducts_name=str_replace('  +  ',' + ',$tepproducts_name);
	
	if(strlen($tepproducts_name)>45){
	//echo "yes<br>";
	$tep_proname=substr($tepproducts_name,0,45);
	//echo $tep_proname;
	$pos=strrpos($tep_proname,' ');
	if ($pos)
	{
		$str_product_name=substr_replace($tep_proname," ...",$pos);
	}
	else
	{
		$str_product_name=$tep_proname;
	}
}
else{
	$str_product_name=$tepproducts_name;
}

?>
            <td width="25%" height="165" >
					<table  border="0" align="center" cellpadding="0" cellspacing="0" class="spa_table" >
                      <tr>
                        <td valign="top"onmouseover="this.style.background='url(images/pro_tb_bg_yellow2.gif)'" onmouseout="this.style.background='url(images/pro_tb_bg2.gif)'" style="text-align:center" >
						<div class="pro_pic"><a href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']);?>"><img src="images/products_images/<?=$listing['products_image']?>"  alt="<? echo $listing[products_name];?>" width="90" height="90" vspace="7" border="0" /></a></div>
                            <div style="width:158px;word-wrap: break-word;overflow:hidden !important; text-align:center;"><a class="spa_namea" href="<? echo tep_href_link(FILENAME_PRODUCT_INFO, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'products_id=' . $listing['products_id']);?>" title="<?=$listing[products_name]?>"><? echo $str_product_name;?></a></div>
                          <div>
						  <span class="spa_oldprice"><?=BOX_SPECIALS_RRP?><s><?php echo $currencies->display_price($listing['products_price'], tep_get_tax_rate($listing['products_tax_class_id']));?></s></span><br />
<span class="spa_newprice"><?php echo $currencies->display_price($listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id']));?></span><br />
<span class="spa_saveprice">
<?=BOX_SPECIALS_SAVE_F?><?php echo $currencies->display_price($listing[products_price]-$listing['specials_new_products_price'], tep_get_tax_rate($listing['products_tax_class_id']));?>&nbsp;<?=BOX_SPECIALS_SAVE_B?></span></div>
                          <div class="pro_addtocart" style="text-align:right; margin:6px;"><a href="<? echo tep_href_link(FILENAME_DEFAULT, ($cPath ? 'cPath=' . $cPath . '&' : '') . 'sort=2a&action=buy_now&products_id=' . $row['products_id']);?>"><img src="<?=DIR_WS_LANGUAGES.$language?>/images/addtocart.gif" border="0" /></a></div>					    </td>
						 </tr>
						 </table>
		  </td>
                
<?
}
 else
{
?>
<td width="25%" height="165" >&nbsp;</td>
<?
}
}
?>
          </tr>
        </table>
<?
	}
}else {

    $list_box_contents = array();

    $list_box_contents[0] = array('params' => 'class="productListing-odd"');
    $list_box_contents[0][] = array('params' => 'class="productListing-data"',
                                   'text' => TEXT_NO_PRODUCTS);

    new productListingBox($list_box_contents);

  }
?>
 </tr>
</table>
<table width="645"  border="0" cellpadding="0" cellspacing="0" bgcolor="#EFEFEF">
            <tr>
              <td align="left"><img src="images/jiao3.gif" width="10" height="10"></td>
              <td align="right"><img src="images/jiao4.gif" width="10" height="10"></td>
            </tr>
</table>
<?
  if ( ($listing_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3')) ) {
?>
<table border="0" width="645" cellspacing="0" cellpadding="2" align="center">
  <tr>
    <td class="smallText"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></td>
    <td class="smallText" align="right"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, tep_get_all_get_params(array('page', 'info', 'x', 'y'))); ?></td>
  </tr>
</table>
<?php
  }
?>
</td>
</tr>
</table>
