<?php
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";

if (get_magic_quotes_gpc()) {
    $_POST = array_map('stripslashes_deep', $_POST);
    $_GET = array_map('stripslashes_deep', $_GET);
    $_COOKIE = array_map('stripslashes_deep', $_COOKIE);
}

$currency_attributes = displayCurrencyType();
// setting pagination limit From Admin settings

$limit=getPaginationLimit();

if($limit==0)
{
	$limit=10;
}	
if($_GET["doIt"])
{
	$id          = base64_decode($_GET["doIt"]);
    $unsql       = "update ".$tableprefix."users set newsLetter = \"N\" where user_id = \"$id\"";
	$unrs        = mysql_query($unsql);
	$message     = UNSUBSCRIBE_NEWSLETTER_SUCCESS_TEXT;
}

$page=$_GET['page'];

if(empty($page))
	{
		$page = 1;
	}

//End pagination settings


/*if(!isset( $_SESSION["sess_userid"]) or $_SESSION["sess_userid"]!= ""){
	header("Location:login.php");
	exit;
}*/

if (isset($_GET["catid"]) and $_GET["catid"] !="") {
    $catid = $_GET["catid"];
} else if (isset($_POST["catid"]) and $_POST["catid"] !="") {
    $catid = $_POST["catid"];
}


if(isset($_GET["txtSearch"]) and $_GET["txtSearch"]!=""){
	$txtSearch = $_GET["txtSearch"];
	$cmbSearchType = $_GET["cmbSearchType"];
}else if(isset($_POST["txtSearch"]) and $_POST["txtSearch"]!=""){
	$txtSearch = $_POST["txtSearch"];
	$cmbSearchType = $_POST["cmbSearchType"];
}


$giftCategoryFlag=CheckGiftCertificateCategory($catid);

if(!isset($catid) && $catid =="" && $txtSearch=="")
			{
				$showproductlisting="false";
				
			}
			if((isset($catid) && $catid!="")  ||  $txtSearch!="" || $giftCategoryFlag=='Y')
			{
				$showproductlisting="true";
			}

/*display the active template*/

$active_template = displayTemplate();


include "includes/htmltop.php";

/* Top File Name */

include_once ("includes/".$active_template[0]);

// Check Category is a Gift Certificate Category 


?>
<script language="javascript" type="text/JavaScript"><!--
function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')
}


function clickSearch()
{
	document.frmCatalog.submit();
}
function confirmDelete(){
	if(confirm('<?php echo CONFIRM_DELETE_RECORDS_TEXT;?>') ){
		return true;
	}
	return false;
}
//-->
</script>

				<div align="left" class="main_body">
							<!--mainbody area start -->
			
						<div align="left" id="body_left_area">
							<!--body left area start -->
							
							<!--categories area start -->
			
			<?php
			$limit=getPaginationLimit();

				if($limit==0)
				{
					$limit=12;
				}	
			$sql_category = " SELECT * FROM ".$tableprefix."categories WHERE parent_id LIKE ".GetSQLValueString($catid,"text")." ORDER BY category_name ";	
			
			$sql_qr=dopaging($sql_category,'',$limit);	
			
			$totalrows=mysql_num_rows(mysql_query($sql_category));
			
			$result_category = mysql_query($sql_qr) or die(mysql_error());

			?>			
			
			<!--categories area end -->	
			
			<!--body left area end -->
						</div>
 
		   <!--center content area start-->		

		 <form name="frmCatalog" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST" enctype="multipart/form-data">
		 <input type="hidden" name="catid" value="<?php echo htmlentities($catid);?>" >
		 <div align="left" id="item_details">
	
               <!--items display area start -->

	              <div align="left" id="items_top_area">
                    <div align="left" id="items_top_area_ttl"><?php echo UNSUBSCRIBE_NEWSLETTER_TEXT;?> </div>
			                      
           </div>


				
<div class="category_searchdiv">
<table cellpadding="0" cellspacing="0" width="100%">
					<tr>
					<td align="right">
					<label></label>
					  </td>
		  </tr>
					  <tr><td>&nbsp;</td></tr>
					  <?php
					  
					   if($_GET['catid']=='' && $txtSearch=='')
					        {
					  ?>
					  <tr><td align="center">	
					  <div class="category_listings">
				<div align="left" id="category_list">
						<table cellspacing="1" cellpadding="5" border="0" width="100%">
						 <tbody><tr>						
					     <td align="left" width="50%" style="text-align:center "><strong><?php echo $message;?></strong></td>
						
					</tr>
</tbody></table>
				
				</div>

				
				<div class="clear"></div>
				</div>
					  </td>
					  </tr>

			            </td>
				</tr>
					    		
		</table>
		   </div>
							
				
		
		
<?php
 
 if($showproductlisting=="true")
 
 { // display products
 		
	include_once("includes/productlist.php");
	
 } 

} // end if show products
?>

	
		<div align="left" class="float_clear1"></div>
			

		</div>
								
	<!--items display area end -->
	</form>
	<!--center content area end-->		
		<!--mainbody area end -->
        </div>
<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>																		