<style>
	.boxItem{
		box-shadow: 5px 5px 10px #888888;
		width:150px; 
		height:150px;
	}
	
	.btnLRclick{
		width: 100px;
		box-shadow: inset 5px 5px 5px #888888;
		border-image: 0;
	}
</style>

<div>
  <?php
	$myproduct = new PRODUCT();
	$arrProduct0 = $myproduct->getProducts(" WHERE pstatus=1 ORDER BY tb_order, id");
	$i=0;
	foreach($arrProduct0 as $tid=>$tproduct){
		$arrProdIDS[$i] = $tid;
		$i++;
	}
  ?>
  <?php
	$itempage = 4;
	$countidx = ceil(count($arrProdIDS)/$itempage);
	
	if( empty($_GET["idx"]) ){
		$idx = 1;
	}else{
		$idx = $_GET["idx"];
	}
	
	if($idx>1){
		$pidx = $idx-1;
	}else{
		$pidx = $countidx;
	}
	
	if($idx==$countidx){
		$nidx = 1;
	}else{
		$nidx = $idx+1;
	}
	
  ?>
  <div style="float: left; width: 100%;">
	<table style="width: 95%">
		<tr align="center">
			<td><a href="main.php?idx=<?= $pidx ?>"><img src="img/ico_larrow.png" class="btnLRclick"></a></td>
			<td><a href="main.php?idx=<?= $nidx ?>"><img src="img/ico_rarrow.png" class="btnLRclick"></a></td>
		</tr>
	</table>
  </div>
	
  <?php
  $arrProduct = $myproduct->getProducts(" WHERE pstatus=1 ORDER BY tb_order, id LIMIT ".(($idx-1)*$itempage).", $itempage");
  foreach($arrProduct as $tid=>$tproduct){
    ?>
	<div style="float:left">
	<table style="margin:20px 30px 10px 30px">
	  <tr>
	    <td align="center"><?= $tproduct["name"] ?><br /><?= $tproduct["ename"] ?></td>
	  </tr>
	  <tr>
	    <td><a href="main.php?pid=<?= $tid ?>"><img class="boxItem" src="img/<?= $tproduct["photo"] ?>"></a></td>
	  </tr>
	</table>
	</div>
	<?php
  }
  ?>
  
</div>