<?php
ob_start();
session_start();
include_once("dbconnect.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome to Ideal Fengling Group... I FEEL GOOD</title>
<link href="docstyle/css.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function changeclass(key){
key.className = "boxhover";
}
function changeagain(key){
key.className = "box";
}
</script>
<SCRIPT src="jquery-1.4.4.min.js" type="text/javascript"></SCRIPT>
<SCRIPT  src="jquery.orbit.min.js" type="text/javascript"></SCRIPT>
<SCRIPT type=text/javascript>
		$(window).load(function() {
			$('#featured').orbit({
				"animation" : "horizontal-push"
			});
		});
	</SCRIPT>
<link href="home.css" rel="stylesheet" type="text/css" />


<link rel="stylesheet" type="text/css" href="docstyle/ddsmoothmenu.css" />

<!--<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>-->
<script type="text/javascript" src="ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>

<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "smoothmenu1", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

ddsmoothmenu.init({
	mainmenuid: "smoothmenu2", //Menu DIV id
	orientation: 'v', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu-v', //class added to menu's outer DIV
	//customtheme: ["#804000", "#482400"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" valign="top" id="table"><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="228" align="left" valign="bottom"><?php include_once("header.php"); ?></td>
          </tr>
          <tr>
            <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="9" align="left" valign="top" style="background:url(images/shodow_left.png) repeat-y top left;">&nbsp;</td>
                <td height="500" align="left" valign="top" id="cont"><table width="100%" border="0" cellspacing="0" cellpadding="0" summary="
">
                  <tr>
                    <td width="216" align="left" valign="top"><?php include_once("leftlink.php"); ?></td>
                    <td align="left" valign="top"><table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
                      <tr>
                        <td align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                          
                          <tr>
                            <td height="10"></td>
                            </tr>
                          
                          <tr>
                            <td align="left" valign="top" class="brand"></td>
                            </tr>
                          <tr>
                            <td align="left" valign="top" class="products">
      <?php $subname=mysql_fetch_array(mysql_query("select * from tblsubcategories where subcat_id='".$_GET['subcatid']."'")); ?>
                              <h1><?php echo $subname['subcat_name']; ?></h1>
                              </td></tr>
                              <tr>
                               <td align="center" valign="top" class="products">
                                <table align="left">
                         
                                <tr valign="top">
                                   <?php include_once("dbconnect.php");

         $adjacents=4;

 $query="SELECT COUNT(*) as num from products where subcat_id=".$_GET['subcatid']."  and status=1"; 
		 

	$total_pages = mysql_fetch_array(mysql_query($query)); 

	$total_pages = $total_pages[num]; 
	/* Setup vars for query. */

	$targetpage = "products.php?subcatid=".$_GET['subcatid'].""; 	//your file name  (the name of this file)

	$limit = 15; 

	/*echo $_GET['page'];

	exit();	*/							//how many items to show per page

	$page = $_GET['page'];

	if($page) 

		$start = ($page - 1) * $limit; 			//first item to display on this page

	else

		$start = 0;								//if no page var is given, set start to 0
	
	/* Get data. */
  	   

		  $DisplayQuery="select * from  products where subcat_id=".$_GET['subcatid']." and status=1  LIMIT $start, $limit";  

      	$result=mysql_query($DisplayQuery);

			/* Setup page vars for display. */

	if ($page == 0) $page = 1;					//if no page var is given, default to 1.

	$prev = $page - 1;							//previous page is page - 1

	$next = $page + 1;							//next page is page + 1

	$lastpage = ceil($total_pages/$limit);		//lastpage is = total pages / items per page, rounded up.

	$lpm1 = $lastpage - 1;						//last page minus 1

	

	$pagination = "";

	if($lastpage > 1)

	{	

		$pagination .= "<div class=\"pagination\">";

		//previous button

		if ($page > 1) 

			$pagination.= "<a href=\"$targetpage&page=$prev\">« previous&nbsp;</a>";

		else

			$pagination.= "<span class=\"disabled\">« previous&nbsp;</span>";	

		

		//pages	

		if ($lastpage < 7 + ($adjacents * 2))	//not enough pages to bother breaking it up

		{	

			for ($counter = 1; $counter <= $lastpage; $counter++)

			{

				if ($counter == $page)

					$pagination.= "<span class=\"current\">$counter</span>";

				else

					$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";					

			}

		}

		elseif($lastpage > 5 + ($adjacents * 2))	//enough pages to hide some

		{

			//close to beginning; only hide later pages

			if($page < 1 + ($adjacents * 2))		

			{

				for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)

				{

					if ($counter == $page)

						$pagination.= "<span class=\"current\">$counter</span>";

						$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</

					elsea>";					

				}

				$pagination.= "...";

				$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";

				$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";		

			}

			//in middle; hide some front and some back

			elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))

			{

				$pagination.= "<a href=\"$targetpage&page=1\">1</a>";

				$pagination.= "<a href=\"$targetpage&page=2\">2</a>";

				$pagination.= "...";

				for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)

				{

					if ($counter == $page)

						$pagination.= "<span class=\"current\">$counter</span>";

					else

						$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";					

				}

				$pagination.= "...";

				$pagination.= "<a href=\"$targetpage&page=$lpm1\">$lpm1</a>";

				$pagination.= "<a href=\"$targetpage&page=$lastpage\">$lastpage</a>";		

			}

			//close to end; only hide early pages

			else

			{

				$pagination.= "<a href=\"$targetpage&page=1\">1</a>";

				$pagination.= "<a href=\"$targetpage&page=2\">2</a>";

				$pagination.= "...";

				for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)

				{

					if ($counter == $page)


						$pagination.= "<span class=\"current\">$counter</span>";

					else

						$pagination.= "<a href=\"$targetpage&page=$counter\">$counter</a>";					

				}

			}

		}
	

		//next button

		if ($page < $counter - 1) 


			$pagination.= "<a href=\"$targetpage&page=$next\">&nbsp;next »</a>";

		else

			$pagination.= "<span class=\"disabled\">&nbsp;next »</span>";

		$pagination.= "</div>\n";		

	}

		 $cnt=0;
					 

			 if($total_pages>0) {

				 			 

						   while($prod=mysql_fetch_array($result))

						  { 

									 
				                   

					  $cnt++;	

					if($cnt%1==1)

{  

	echo "<tr>";

}

if($cnt%4==1)

{  



	echo '</tr>	</tr>';

}

						  ?> 
                           
               <td>
                              <div align="center"><a href="details.php?pid=<?php echo $prod['pid']; ?>"><img src="products/thumb/<?php echo $prod['pid']; ?>-1.jpg" width="170" height="240" alt="" /></a>
                                <strong><?php echo stripslashes($prod['pname']); ?></strong><span>$<?php echo number_format($prod['price'],2); ?></span>
                <form action="addtocart.php" name="cart" method="post">
                                                      <input type="hidden" name="prodid" value="<?php echo $prod['pid']; ?>" />
                                                       <input type="hidden" name="price" value="<?php echo $prod['price']; ?>" />
                                                  <input type="hidden" name="weight" value="<?php echo $prod['weight']; ?>" />
                                                     <input type="hidden" name="pname" value="<?php echo $prod['pname']; ?>" />
                                                      <input type="hidden" name="color" value="<?php echo $prod['color']; ?>" />
                                                        <input type="hidden" name="qty" value="1" />
                                <input type="image" src="images/addtocart.gif" width="131" height="23" alt="" />
                                </form>
                                <br />
                                
                           <a href="details.php?pid=<?php echo $prod['pid']; ?>"><img src="images/details.gif" width="131" height="23" alt="" /></a></div></td>
                           
                           <? } } ?>
                           
                            </tr>
                          </table>
                        </td>
                        </tr>
                          
                          <tr>
                            <td align="left" valign="top">&nbsp;</td>
                            </tr>
                          </table></td>
                        </tr>
                      </table></td>
                    </tr>
                  </table></td>
                <td width="9" align="left" valign="top" style="background:url(images/shodow_right.png) repeat-y top left;">&nbsp;</td>
                </tr>
              </table></td>
          </tr>
          </table></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="100" align="center" valign="top" style="background:url(images/bottom_bg.gif) repeat-x">
	<?php include_once("footer.php"); ?></td>
          </tr>
        </table></td>
      </tr>
    </table></td>
  </tr>
</table>

<map name="Map" id="Map">
  <area shape="rect" coords="69,274,206,318" href="#" alt="" />
</map>

<map name="Map2" id="Map2">
  <area shape="rect" coords="87,255,204,295" href="#" alt="" />
</map>
</body>
</html>
