$txtSearch = $_POST["txtSearch"];
        $cmbSearchType = $_POST["cmbSearchType"];
    }
}
//echo "aaaaaaaaaaaaaaaaaa";
$txtCategoryName = trim($_POST["txtCategoryName"]);
$txtProductName = $_POST["txtProductName"];
$txtDescription = $_POST["txtDescription"];
$txtPrice = $_POST["txtPrice"];
$ddlArtist = $_POST["ddlArtist"];
$productlist = $_POST["chkproducts"];
$catid = $_GET['catid'];
$artistlist = makeArtistList();
$productListingFee = getSettingsValue('product_listing_fee');
//$madetoorder_opt = ($madetorderflag == 1) ? "AND p.eMadetoOrder = 'Y'" : '';
if (CheckGiftCertificateCategory($_GET['catid']) == 'Y') {
    $sql = "SELECT p.product_id,p.product_name,(p.product_price + po.additional_price) AS product_price,po.image_small,po.product_option_id,po.product_stock,po.discount,s.artist_name,\n                      (SELECT pm.vimage_name FROM " . $tableprefix . "product_view_images pm where pm.nimage_productid=p.product_id LIMIT 0,1)AS smallimage\n                      FROM " . $tableprefix . "products p\n                      INNER JOIN " . $tableprefix . "product_options po ON po.product_id = p.product_id AND po.default_option = 'YES'\n                      INNER JOIN " . $tableprefix . "giftcoupon_master gm oN gm.ngift_product_id=p.product_id\n                      LEFT JOIN " . $tableprefix . "artists s on p.product_artist_id=s.artist_id\n                      WHERE p.vapproved='Y' AND p.deleted ='N'  AND po.product_stock > 0 ";
    if ($productListingFee > 0) {
        $sql .= " AND p.payment_status='COMPLETED' ";
    }
    $sql .= "AND s.vapproved='Y' AND s.deleted = 'N' AND s.plan_expired='N' AND s.vacationmode = 'N' ";
} else {
    $sql = "SELECT p.product_id,p.product_name,(p.product_price + po.additional_price) AS product_price,po.image_small,po.product_option_id,po.product_stock,po.discount,s.artist_name, p.eMadetoOrder,\n                      (SELECT pm.vimage_name FROM " . $tableprefix . "product_view_images pm where pm.nimage_productid=p.product_id LIMIT 0,1)AS smallimage\n                      FROM " . $tableprefix . "products p\n                      INNER JOIN " . $tableprefix . "product_options po ON po.product_id = p.product_id AND po.default_option = 'YES'\n                      LEFT JOIN " . $tableprefix . "artists s on p.product_artist_id=s.artist_id\n\t\t      WHERE p.vapproved='Y' AND p.deleted ='N' AND s.vacationmode = 'N' AND po.product_stock > 0 ";
    if ($productListingFee > 0) {
        $sql .= " AND p.payment_status='COMPLETED' ";
    }
    $sql .= "\n                AND s.vapproved='Y' AND s.deleted = 'N' AND s.plan_expired='N' AND s.vacationmode = 'N' ";
}
$qrystring = " ";
if ($txtSearch != "" || $catid != '') {
    // check for searching
    $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) {