<?php require_once('Connections/config.php'); ?>
<?php require_once('Connections/config.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

mysql_select_db($database_config, $config);
$query_cats_menu = "SELECT * FROM cat ORDER BY id ASC";
$cats_menu = mysql_query($query_cats_menu, $config) or die(mysql_error());
$row_cats_menu = mysql_fetch_assoc($cats_menu);
$totalRows_cats_menu = mysql_num_rows($cats_menu);

mysql_select_db($database_config, $config);
$query_cats_menu2 = "SELECT * FROM menu ORDER BY id ASC";
$cats_menu2 = mysql_query($query_cats_menu2, $config) or die(mysql_error());
$row_cats_menu2 = mysql_fetch_assoc($cats_menu2);
$totalRows_cats_menu2 = mysql_num_rows($cats_menu2);

mysql_select_db($database_config, $config);
$query_stats = "SELECT * FROM setting";
$stats = mysql_query($query_stats, $config) or die(mysql_error());
$row_stats = mysql_fetch_assoc($stats);
$totalRows_stats = mysql_num_rows($stats);

$maxRows_stock = $row_stats['stock'];
$pageNum_stock = 0;
if (isset($_GET['pageNum_stock'])) {
  $pageNum_stock = $_GET['pageNum_stock'];
}
$startRow_stock = $pageNum_stock * $maxRows_stock;

mysql_select_db($database_config, $config);
$query_stock = "SELECT * FROM stocksub WHERE stock='1' ORDER BY id DESC";
$query_limit_stock = sprintf("%s LIMIT %d, %d", $query_stock, $startRow_stock, $maxRows_stock);
$stock = mysql_query($query_limit_stock, $config) or die(mysql_error());
$row_stock = mysql_fetch_assoc($stock);

if (isset($_GET['totalRows_stock'])) {
  $totalRows_stock = $_GET['totalRows_stock'];
} else {
  $all_stock = mysql_query($query_stock);
  $totalRows_stock = mysql_num_rows($all_stock);
}
$totalPages_stock = ceil($totalRows_stock/$maxRows_stock)-1;

mysql_select_db($database_config, $config);
$query_cats = "SELECT * FROM cat ORDER BY id ASC";
$cats = mysql_query($query_cats, $config) or die(mysql_error());
$row_cats = mysql_fetch_assoc($cats);
$totalRows_cats = mysql_num_rows($cats);

mysql_select_db($database_config, $config);
$query_stocks = "SELECT * FROM cat";
$stocks = mysql_query($query_stocks, $config) or die(mysql_error());
$row_stocks = mysql_fetch_assoc($stocks);
$totalRows_stocks = mysql_num_rows($stocks);
?>

<?php if($row_stats[state]==2){include'msg_close.php';}else{?>

  
<?php 		  			mysql_select_db($database_config, $config);
$query_cat23 = "SELECT * FROM cat";
$cat23 = mysql_query($query_cat23, $config) or die(mysql_error());
$row_cat23 = mysql_fetch_assoc($cat23);
$totalRows_cat23 = mysql_num_rows($cat23);

mysql_select_db($database_config, $config);
$query_blocks = "SELECT * FROM block ORDER BY id ASC";
$blocks = mysql_query($query_blocks, $config) or die(mysql_error());
$row_blocks = mysql_fetch_assoc($blocks);
$totalRows_blocks = mysql_num_rows($blocks);
mysql_select_db($database_config, $config);
$query_catss = "SELECT * FROM cat ORDER BY id ASC";
$catss = mysql_query($query_catss, $config) or die(mysql_error());
$row_catss = mysql_fetch_assoc($catss);
$totalRows_catss = mysql_num_rows($catss);

?>

<meta name="robots" content="index, follow">


<style>
.tw4host{
	background-image:url('style/top_background.jpg');
	border:1px black solid;
	text-decoration:none;
	color:#FFF;
	

}
.tw4host:hover{
	background-image:url('style/cont_bg.gif');
	border:0px;
}

</style>

<script>
loaded = 0;

function imageProgress() {

totalindex = document.images.length-1;

for (i=0;i<=totalindex;i=i+1) {

document.images[i].onload = doProgress;

}

}

function doProgress() {

loaded = loaded+1;
percent = ((loaded / document.images.length)*100);

parent.document.getElementById('progressloaded').style.width = percent+'%';

}

if (document.addEventListener) {

document.addEventListener("DOMContentLoaded", imageProgress, false);

} else {

window.onload = imageProgress

}
</script>
	<link rel="stylesheet" href="style/css/lightbox.css" type="text/css" media="screen" />
	
	<script src="style/js/prototype.js" type="text/javascript"></script>
	<script src="style/js/scriptaculous.js?load=effects,builder" type="text/javascript"></script>
	<script src="style/js/lightbox.js" type="text/javascript"></script>
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="950" dir="rtl" height="40" align="center" background="style/menu.jpg" style="font-family: Tahoma, Geneva, sans-serif; font-size: 16px; font-weight: bold; color: #FFF;"><?php do { ?>
      <a href="<?php echo $row_cats_menu2['url']; ?>" style="text-decoration:none; color:#FFF;"><?php echo $row_cats_menu2['name']; ?></a> -
      <?php } while ($row_cats_menu2 = mysql_fetch_assoc($cats_menu2)); ?></td>
  </tr>
</table><br />
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="950" dir="rtl" height="40" align="center" background="style/menu.jpg" style="font-family: Tahoma, Geneva, sans-serif; font-size: 16px; font-weight: bold; color: #FFF;">
    <?php do { ?>
   <a href="cat.php?id=<?php echo $row_cats_menu['id']; ?>" style="text-decoration:none; color:#FFF;"><?php echo $row_cats_menu['name']; ?></a> - 
<?php } while ($row_cats_menu = mysql_fetch_assoc($cats_menu)); ?></td>
  </tr>
</table><br />
<br /><table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td  align="center">
	<img src="style/medium-bar-stinky-topics.jpg" width="950" height="40" />
	</td>
  </tr>
</table><br />
<table width="964" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="964" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <?php do { ?>
          <td><table id="Table_2" width="232" height="309" border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td><img src="style/images/ar1111111111_01.gif" width="28" height="33" alt="" /></td>
                <td colspan="3" background="style/images/ar1111111111_02.gif" width="178" height="33" align="center"><a  style="text-align: center; font-weight: bold; font-size: 12px; color: #000; font-family: Tahoma, Geneva, sans-serif; text-decoration:none" href="redicter.php?id=<?php echo $row_stock['id'] ; ?>" ><?php echo substr($row_stock['name'],0,50);?></a></td>
                <td colspan="2" align="center" background="style/images/ar1111111111_03.gif" width="26" height="33"><a href="<?php echo $row_stock['img'] ; ?>"  rel="lightbox"><img src="style/b_search.png" width="16" height="16" border="0" /></a></td>
              </tr>
              <tr>
                <td colspan="6" background="style/images/ar1111111111_04.gif" width="232" height="161" align="center"><a href="redicter.php?id=<?php echo $row_stock['id'] ; ?>" ><img  src="<?php echo $row_stock['img'] ; ?>" width="230" style="border:dotted 1px #000" height="161" /></a></td>
              </tr>
              <tr>
                <td colspan="6" align="center" background="style/images/ar1111111111_05.gif" width="232" height="77" valign="top">
                  <textarea  rows="4"   dir="rtl"name="textarea3" cols="26"  readonly="readonly" id="textarea3"><?php echo $row_stock['text'] ; ?></textarea></td>
              </tr>
              <tr>
                <td colspan="2" rowspan="2"><a href="redicter.php?id=<?php echo $row_stock['id'] ; ?>"><img src="style/images/ar1111111111_06.gif" alt="" width="57" height="37" border="0" /></a></td>
                <td><img src="style/images/ar1111111111_07.gif" width="9" height="17" alt="" /></td>
                <td colspan="2" align="center" background="style/images/ar1111111111_08.gif" width="154" height="17" valign="bottom"><span style="font-family: Tahoma, Geneva, sans-serif; font-size: 12px; font-weight: bold; color: #FFF;">
                  <?php 
				mysql_select_db($database_config, $config);
$query_cat23 = "SELECT * FROM cat WHERE id=".addslashes($row_stock['cat'])."";
$cat23 = mysql_query($query_cat23, $config) or die(mysql_error());
$row_cat23 = mysql_fetch_assoc($cat23);?>
                  <a href="cat.php?id=<?php echo $row_cat23['id'];?>" style="text-decoration:none; color:#FFF"><?php echo $row_cat23['name'];?></a></span></td>
                <td rowspan="2"><img src="style/images/ar1111111111_09.gif" width="12" height="37" alt="" /></td>
              </tr>
              <tr>
                <td colspan="3" align="center" background="style/images/ar1111111111_10.gif" width="163" height="20" valign="bottom"><span style="text-align: center; font-weight: bold; font-size: 12px; color: #FFCC00; font-family: Tahoma, Geneva, sans-serif;"> : <?php echo $row_stock['count'] ; ?></span></td>
              </tr>
              <tr>
                <td><img src="style/images/spacer.gif" width="28" height="1" alt="" /></td>
                <td><img src="style/images/spacer.gif" width="29" height="1" alt="" /></td>
                <td><img src="style/images/spacer.gif" width="9" height="1" alt="" /></td>
                <td><img src="style/images/spacer.gif" width="140" height="1" alt="" /></td>
                <td><img src="style/images/spacer.gif" width="14" height="1" alt="" /></td>
                <td><img src="style/images/spacer.gif" width="12" height="1" alt="" /></td>
              </tr>
            </table>
            <p>&nbsp;</p>
            <p><br />
            </p></td>
          
          <?php
$tablesTd++;
if($tablesTd == 4){
echo "</TR>";
$tablesTd = 0;
}
?>
          <?php } while ($row_stock = mysql_fetch_assoc($stock)); ?>
      </tr>
      </table>
      <table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td background="#00000" align="center">
		
			<img src="style/medium-bar-index.jpg" width="950" height="40" />

        </tr>
      </table><br>
      <table width="964" border="0" align="center" cellpadding="2" cellspacing="2">

          <tr>
            <?php 
		$maxRows_stocks = 40;
$pageNum_stocks = 0;
if (isset($_GET['pageNum_stocks'])) {
  $pageNum_stocks = $_GET['pageNum_stocks'];
}
$startRow_stocks = $pageNum_stocks * $maxRows_stocks;

mysql_select_db($database_config, $config);
$query_stocks = "SELECT * FROM stocksub WHERE stock='0' ORDER BY id DESC";
$query_limit_stocks = sprintf("%s LIMIT %d, %d", $query_stocks, $startRow_stocks, $maxRows_stocks);
$stocks = mysql_query($query_limit_stocks, $config) or die(mysql_error());
$row_stocks = mysql_fetch_assoc($stocks);

if (isset($_GET['totalRows_stocks'])) {
  $totalRows_stocks = $_GET['totalRows_stocks'];
} else {
  $all_stocks = mysql_query($query_stocks);
  $totalRows_stocks = mysql_num_rows($all_stocks);
}
$totalPages_stocks = ceil($totalRows_stocks/$maxRows_stocks)-1;




?>
            <?php do { ?>
<td><table id="Table_" width="232" height="309" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td><img src="style/images/ar1111111111_01.gif" width="28" height="33" alt="" /></td>
    <td colspan="3" background="style/images/ar1111111111_02.gif" width="178" height="33" align="center"><a  style="text-align: center; font-weight: bold; font-size: 12px; color: #000; font-family: Tahoma, Geneva, sans-serif; text-decoration:none" href="redicter.php?id=<?php echo $row_stocks['id'] ; ?>" ><?php echo substr($row_stocks['name'],0,40);?></a></td>
    <td colspan="2" align="center" background="style/images/ar1111111111_03.gif" width="26" height="33"><a href="<?php echo $row_stocks['img'] ; ?>"  rel="lightbox"><img src="style/b_search.png" width="16" height="16" border="0" /></a></td>
  </tr>
  <tr>
    <td colspan="6" background="style/images/ar1111111111_04.gif" width="232" height="161" align="center"><a href="redicter.php?id=<?php echo $row_stocks['id'] ; ?>" ><img  src="<?php echo $row_stocks['img'] ; ?>" width="230" style="border:dotted 1px #000" height="161" /></a></td>
  </tr>
  <tr>
    <td colspan="6" align="center" background="style/images/ar1111111111_05.gif" width="232" height="77" valign="top"><textarea  rows="4"   dir="rtl"name="textarea" cols="26"  readonly="readonly" id="textarea"><?php echo $row_stocks['text'] ; ?></textarea></td>
  </tr>
  <tr>
    <td colspan="2" rowspan="2"><a href="redicter.php?id=<?php echo $row_stocks['id'] ; ?>"><img src="style/images/ar1111111111_06.gif" alt="" width="57" height="37" border="0" /></a></td>
    <td><img src="style/images/ar1111111111_07.gif" width="9" height="17" alt="" /></td>
    <td colspan="2" valign="bottom" align="center" background="style/images/ar1111111111_08.gif" width="154" height="17"><span style="font-family: Tahoma, Geneva, sans-serif; font-size: 12px; font-weight: bold; color: #FFF;">
      <?php 
				mysql_select_db($database_config, $config);
$query_cat23 = "SELECT * FROM cat WHERE id=".addslashes($row_stocks['cat'])."";
$cat23 = mysql_query($query_cat23, $config) or die(mysql_error());
$row_cat23 = mysql_fetch_assoc($cat23);?>
      <a href="cat.php?id=<?php echo $row_cat23['id'];?>" style="text-decoration:none; color:#FFF"><?php echo $row_cat23['name'];?></a></span></td>
    <td rowspan="2"><img src="style/images/ar1111111111_09.gif" width="12" height="37" alt="" /></td>
  </tr>
  <tr>
    <td colspan="3" valign="bottom" align="center" background="style/images/ar1111111111_10.gif" width="163" height="20"><span style="text-align: center; font-weight: bold; font-size: 12px; color: #FFCC00; font-family: Tahoma, Geneva, sans-serif;"> : <?php echo $row_stocks['count'] ; ?></span></td>
  </tr>
  <tr>
    <td><img src="style/images/spacer.gif" width="28" height="1" alt="" /></td>
    <td><img src="style/images/spacer.gif" width="29" height="1" alt="" /></td>
    <td><img src="style/images/spacer.gif" width="9" height="1" alt="" /></td>
    <td><img src="style/images/spacer.gif" width="140" height="1" alt="" /></td>
    <td><img src="style/images/spacer.gif" width="14" height="1" alt="" /></td>
    <td><img src="style/images/spacer.gif" width="12" height="1" alt="" /></td>
  </tr>
</table>
<br />
</td>
              <?php
$tablesTd++;
if($tablesTd == 4){
echo "</TR>";
$tablesTd = 0;
}
?>
              <?php } while ($row_stocks = mysql_fetch_assoc($stocks)); ?>
        </tr>
      </table>
      
      <table border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          
          <strong>
            <?php 
	$page=$_REQUEST['pageNum_Recordset1'];
	$pagesnum = @ceil(mysql_num_rows(mysql_query("select `id` from `stocksub` WHERE stock=0")) / 30);
for ($i=0; $i<=$pagesnum; $i++) {

if ($i != $page) {
$z = "<a style='text-decoration:none; color:#fff;' href='". $_SERVER['PHP_SELF'] ."?pageNum_stocks=$i&id=".$_REQUEST['id']."'>$i</a>";
} else {
$z = "$i";
}

echo "<td width='30' align=center  height='30'class='tw4host'>[$z]</td>";

}?>
         </strong>
       
        </tr>
      </table>
      <p>&nbsp;</p>
      <p><br />
    </p></td>
  </tr>
</table>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" id="table2">
  <tr>
    <td  class="td" background="arabseed/bg2.jpg"><form action="search.php" id="form1" name="form1" method="post" >
      <label>
        <input type="text" name="textfield" id="textfield" />
        <select name="select" id="select">
         <?php 
				mysql_select_db($database_config, $config);
$query_cat23 = "SELECT * FROM cat";
$cat23 = mysql_query($query_cat23, $config) or die(mysql_error());
$row_cat23 = mysql_fetch_assoc($cat23);

?>
          <?php
do {  
?>
          <option value="<?php echo $row_cat23['id']?>"><?php echo $row_cat23['name']?></option>
          <?php
} while ($row_cat23 = mysql_fetch_assoc($cat23));
  $rows = mysql_num_rows($cat23);
  if($rows > 0) {
      mysql_data_seek($cat23, 0);
	  $row_cat23 = mysql_fetch_assoc($cat23);
  }
?>
        </select>
      </label>
      <input type="submit" name="button" id="button" value="" />
    </form></td>
  </tr>
</table>
<?php }
mysql_free_result($cats_menu);
?>
