<?php

include "includes/config.php";
include "includes/session.php";  
include "includes/functions.php";
include_once "classes/cls_products.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;
}	
//$limit=3;

$page=$_GET['page'];
if(empty($page))
	{
		$page = 1;
	}
//End pagination settings
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]); 

?> 
<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 filterFavorites()
{
    if($('#fav_type').val()=='seller'){
        $('#fav_products_div').hide();
        $('#fav_sellers_div').show();   
        $('#seller_sort').show();
        $('#product_sort').hide();
    }else if($('#fav_type').val()=='product'){
        $('#fav_sellers_div').hide();
        $('#fav_products_div').show();
        $('#seller_sort').hide();
        $('#product_sort').show();        
    }
	//document.frmCatalog.submit();
}
function confirmDelete(){
	if(confirm('<?php echo CONFIRM_DELETE_RECORDS_TEXT;?>') ){
		return true;
	}
	return false;
}
//-->
</script>
<!--mainbody area start -->
<div class="featuredproduct_list main_body">
    <div class="container">
        <form name="frmCatalog" action="<?php echo $_SERVER["PHP_SELF"] ?>" method="POST" enctype="multipart/form-data">
            <div class="row">
                <section class="sec_marg">
                    <div class="col-sm-12 col-lg-6 col-md-6 ">
                        <div class="brdcrumb_container">
                            <h4> <?php echo MY_FAVORITES; ?></h4>
                        </div>
                    </div>

                    <div class="col-sm-12 col-lg-6 col-md-6 ">                       
                        <!--- Sort/search by --->
                        <div class="favorite_sortdiv pull-right">
                            <select onchange="sort_sellers()" class="topsearch_fld f_right_marg" name="seller_sort" id="seller_sort" style="display:none;">                                        
                               <option value="recent" <?php if ($_REQUEST['seller_sort'] == "recent") {   echo "selected";  } ?>><?php echo RECENTLY_ADDED; ?></option>
                               <option value="seller_asc" <?php if ($_REQUEST['seller_sort'] == "seller_asc") {echo "selected";} ?>><?php echo SELLER_ASC; ?></option>
                               <option value="seller_desc" <?php if ($_REQUEST['seller_sort'] == "seller_desc") {echo "selected";} ?>><?php echo SELLER_DES; ?></option>                                                                    
                             </select>  
                            
                            <select onchange="sort_products()" class="topsearch_fld f_right_marg" name="product_sort" id="product_sort" style="display:none;">                                       
                               <option value="recent" <?php if ($_REQUEST['product_sort'] == "recent") {echo "selected";} ?>><?php echo RECENTLY_ADDED; ?></option>
                               <option value="product_asc" <?php if ($_REQUEST['product_sort'] == "product_asc") {echo "selected";} ?>><?php echo PRODUCT_ASC; ?></option>
                               <option value="product_desc" <?php if ($_REQUEST['product_sort'] == "product_desc") {echo "selected";} ?>><?php echo PRODUCT_DES; ?></option>
                               <option value="price_asc" <?php if ($_REQUEST['product_sort'] == "price_asc") {echo "selected";} ?>><?php echo PRICE_ASC; ?></option>
                               <option value="price_desc" <?php if ($_REQUEST['product_sort'] == "price_desc") {echo "selected";} ?>><?php echo PRICE_DES; ?></option>                               
                             </select>
                            
                            <select onchange="filterFavorites()" class="topsearch_fld f_right_marg" name="fav_type" id="fav_type">
                                        <option value=""><?php echo SELECT_FAVORITE; ?></option>
                                        <option value="seller" <?php if ($_REQUEST['fav_type'] == "seller") {
                                    echo "selected";
                                } ?>><?php echo FAV_SELLER; ?></option>
                                        <option value="product" <?php if ($_REQUEST['fav_type'] == "product") {
                                    echo "selected";
                                } ?>><?php echo FAV_PRODUCTS; ?></option>
                             </select>                                
                        </div>
                        <!--- Sort by --->
                    </div>
                   
                    <div class="clear"></div>
                </section>  

                <div class="clear"></div>
                    
                <div class="clear"></div>
                    
                <section class="sec_marg">
                        <?php        
                            include_once("includes/favoritelist.php");                            
                        ?>
                    <div class="clear"></div>
                </section>
            </div>								
            <!--items display area end -->
        </form>
    </div>
</div>
</div>
<?php
include "includes/".$active_template[2];	/* Bottom File Name */
?>																		