<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Santhosh Thomas Alexander<santhosh.thomas@armiasystems.com> |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com � 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
include "includes/config.php";
include "includes/session.php";
include "includes/functions.php";

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

/*if (function_exists('session_register')) {
    session_register('SESS_card_id');
}*/

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

if ($productid == '') {
    header("Location:index.php");
    exit;
}

/*
 * Impression counter by Binu Chandran.E
*/
$impressionFound = false;
//Client IP Address
$ip = getClientIP();
//Check last visit for this product from same Ip address
//With in 24 hrs
$imQuery = "SELECT product_impression_id
              FROM " . $tableprefix . "product_impression
             WHERE product_id = '" . mysql_real_escape_string($productid) . "'
               AND ip = '" . mysql_real_escape_string($ip) . "'
               AND ADDDATE(visited_on, INTERVAL 24 HOUR) > NOW()";
$result = mysql_query($imQuery) or die(mysql_error());
if (mysql_num_rows($result) > 0) {
    $imRow = mysql_fetch_object($result);
    if ($imRow->product_impression_id > 0) {
        $impressionFound = true;
    }
}

if ($impressionFound === false) {
    //Add new visit
    $imQuery = "INSERT INTO " . $tableprefix . "product_impression
             SET product_id = '" . mysql_real_escape_string($productid) . "',
                ip = '" . mysql_real_escape_string($ip) . "'";
    mysql_query($imQuery) or die(mysql_error());
}

/*
 * Impression counter - End here
*/


/* -----------Multicart 2.0 Upgradation------------ */

$check_shipping_enable = checkShippingEnable();

$prodimagedir = "products/";


$sql = "SELECT
        p.product_id,p.product_name,p.product_description,p.product_name,p.product_code,
        po.product_option_id,po.image_small,po.image_big,po.product_stock,(p.product_price + po.additional_price) AS product_price,
        po.discount,po.discount_description,po.product_shipping_weight,
        ar.company,ar.storename,ap.artist_photo,ar.state,ar.city,ar.country,ar.artist_name,ar.first_name,ar.last_name,ar.artist_id,ap.artist_description,c.category_id
        FROM " . $tableprefix . "products p
        INNER JOIN " . $tableprefix . "product_options po ON po.product_id = p.product_id AND po.default_option = 'YES'
        INNER JOIN  " . $tableprefix . "artists ar ON ar.artist_id = p.product_artist_id
        INNER JOIN  " . $tableprefix . "categories  c ON c.category_id = p.product_category
        LEFT JOIN " . $tableprefix . "artist_portfolios ap ON ar.artist_id = ap.artist_id
        WHERE p.product_id = '" . addslashes($productid) . "' ";

// Select More Images
$sql_im = "select vimage_name from " . $tableprefix . "product_view_images  where nimage_productid ='" . $productid . "' ";
$result_im = mysql_query($sql_im) or die(mysql_error());
$numrows = mysql_num_rows($result_im);
$product_number = mysql_num_rows(mysql_query($sql));
$sess_back = $_SERVER["PHP_SELF"] . "?begin=" . $begin . "&num=" . $num . "&numBegin=" . $numBegin . "&cmbSearchType=" . $cmbSearchType . "&txtSearch=" . $txtSearch . "&catid=" . $catid;
//$_SESSION["gbackurl"] = $sess_back;
$rs = mysql_query($sql);
if (mysql_num_rows($rs) != 0) {
    $prow = mysql_fetch_array($rs);
    $artistid = $prow["artist_id"];
}
// Product Review Listings




$sql_review = " SELECT r.*,u.first_name,u.last_name,p.product_name FROM " . $tableprefix . "Review r LEFT JOIN " . $tableprefix . "users u ON r.nUserId=u.user_id
					LEFT JOIN " . $tableprefix . "products p ON r.nProdId=p.product_id WHERE r.nProdId='" . $productid . "' AND r.vActive='1' ORDER BY r.nRId DESC LIMIT 0,5 ";

$rs_review = mysql_query($sql_review) or die(mysql_error());

$ProductReviewCount = mysql_num_rows($rs_review);

if ($ProductReviewCount > 0) {

    $showProductReviewMoreLink = ' &nbsp;<a href=' . SITE_URL . '/product_review_lists.php?pid=' . $productid . '&pname=' . stripslashes($prow['product_name']) . '>'.PRODUCT_REVIEW_LIST_TEXT.' </a>';
} else {
    $showProductReviewMoreLink = '';
}

// Select Seller Feedback

$sql_seller_feedback = " SELECT f.*, u.first_name,u.last_name  FROM " . $tableprefix . "artist_feedbacks f
		INNER JOIN " . $tableprefix . "users u ON f.user_id = u.user_id
		WHERE f.artist_id = '" . addslashes($prow['artist_id']) . "' AND f.published='Y' order by date_added DESC  LIMIT 5   ";

$rs_seller_feedback = mysql_query($sql_seller_feedback) or die(mysql_error());

$totalsellerFeedbackRows = mysql_num_rows($rs_seller_feedback);
// End
// Fetching Product Details
if(!is_file("products/" . $prow["image_big"]) && strpos($prow["image_big"], "http") === false) {
    $product_image = SITE_URL . "/products/noimage.jpg";
    $imageurl = "<img width='283' height='269' src='" . $product_image . "' border='0' id='itemImage' onClick=PopWinbig('" . $product_image . "','MoreImages','width=400,height=400,resizable=1,scrollbars=1,toolbar=0,status=1'); style='cursor: pointer;'>";
}
else if(!is_file("products/" . $prow["image_small"]) && strpos($prow["image_big"], "http") === false) {
    $product_image = SITE_URL . "/products/noimage.jpg";
    $imageurl = "<img width='283' height='269' src='" . $product_image . "' border='0' id='itemImage' onClick=PopWinbig('" . $product_image . "','MoreImages','width=400,height=400,resizable=1,scrollbars=1,toolbar=0,status=1'); style='cursor: pointer;'>";
}
else if (($prow["image_big"] != "")) {
    $product_image = $prow["image_big"];
    if (strpos($product_image, "http") === false) {
        $product_image = SITE_URL . "/products/" . $product_image;
    } else {
        $product_image = $product_image;
    }

    $imageurl = "<img width='283' height='269' src='" . $product_image . "' border='0' id='itemImage' onClick=PopWinbig('" . $product_image . "','MoreImages','width=400,height=400,resizable=1,scrollbars=1,toolbar=0,status=1'); style='cursor: pointer;'>";
} else if ($prow["image_small"] != "") {
    $product_image = $prow["image_small"];
    if (strpos($product_image, "http") === false) {
        $product_image = SITE_URL . "/products/" . $product_image;
    } else {
        $product_image = $product_image;
    }

    $imageurl = "<img width='283' height='269' src='" . $product_image . "' border='0' id='itemImage' onClick=PopWinbig('" . $product_image . "','MoreImages','width=400,height=400,resizable=1,scrollbars=1,toolbar=0,status=1'); style='cursor: pointer;'>";
} else {
    if ($numrows > 0) { // product main image is not present take image from product_view_images
        $rr = mysql_fetch_array($result_im);
        $prodimagedir = "products/";
        $image_small = $rr['vimage_name'];

        $imageurl .= "<img width='183' height='191' src='products/bulk_images/" . $image_small . "' border='0' id='itemImage' width='120' height='150' onClick=PopWinlarge(this.src,'MoreImages','width=400,height=400,resizable=1,scrollbars=1,toolbar=0,status=1'); style='cursor: pointer;'>";
    } else { // if no images present display default iamge
        $product_image = '';
        $prodimagedir = "products/";

        $imageurl = "<img width='283' height='269' src='" . $prodimagedir . "noimage.jpg' width='191' height='183' border='0' id='itemImage'>";
    } // end else
}


if (intval($prow["product_stock"]) > 0) {
    $productinstock = true;
} else {
    $productinstock = false;
}
$artistname = getArtistName($artistid);
// End Details


/* $currency_attributes = displayCurrencyType();
  $conversionRate	= ConvertedCurrencyRate($currency_attributes[2]);
  $converted_price = $prow["product_price"] * $conversionRate;

  $display_product_price = $currency_attributes[0]."&nbsp;".number_format($converted_price,2,".",""); */


$price = $prow["product_price"];

$currency_attributes = displayCurrencyType();
$conversionRate = ConvertedCurrencyRate($currency_attributes[2]);
$converted_price = $price * $conversionRate;
$discountprice = 0;
if ($prow["discount"] != "0") {
    $discountprice = $converted_price - ($converted_price * $prow["discount"]) / 100;
    $discountprice = number_format($discountprice, 2, ".", "");
}


$display_product_price = number_format($converted_price, 2, ".", "");
// End Set Currency Value
// Item Description

$product_description_format = $prow["product_description"];
// End Item Description
// Setting Referer
if (strstr(basename($_SERVER['HTTP_REFERER']), "categorydetail.php") || strstr(basename($_SERVER['HTTP_REFERER']), "index.php")) {
    /*if (function_exists('session_unregister')) {
        (isset($_SESSION['SESS_url_back'])) ? session_unregister('SESS_url_back') : session_register('SESS_url_back');
    }//end if*/

    $_SESSION['SESS_url_back'] = basename($_SERVER['HTTP_REFERER']);
}

// End Setting Reffer

$check_array = array('more_images', 'ndisplay_stock');
$settings = getSiteGeneralSettings($check_array);


// Disply Sller Rating Details
$showSellerRating = '';
$showProductReviewLink = '';

//checking logged user buy the product atleast one
$prodStatus = mysql_query("select od.product_name from " . $tableprefix . "orders o left join " . $tableprefix . "order_details od
							on o.order_id=od.order_id where user_id='" . $_SESSION["sess_userid"] . "' and
							product_id='" . $_GET['productid'] . "'") or die(mysql_error());
if (mysql_num_rows($prodStatus) > 0) {

    $showProductReviewLink = '<a style="cursor:pointer" href="#">'.POST_PRODUCT_REVIEW_TEXT.'</a>';

    $showSellerRating = "<br><a style='cursor:pointer' onClick=";
    $showSellerRating.='"javascript:';
    $showSellerRating.="window.open('seller_rating.php?artist_id=" . $artistid . "', 'SellerRating','menubar=0,resizable=0,width=250,height=200');";
    $showSellerRating.='">Seller Rating</a>';



    $showProductReview = "&nbsp;&nbsp;|&nbsp;&nbsp;<a style='cursor:pointer' onClick=";
    $showProductReview.='"javascript:';
    $showProductReview.="window.open('product_review.php?pid=" . $_GET['productid'] . "', 'SellerRating','menubar=0,resizable=0,width=450,height=300');";
    $showProductReview.='">Post Product Review</a>';

    $showSellerRating = $showSellerRating . $showProductRating . $showProductReview . '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="product_review_lists.php?pid=' . $_GET['productid'] . '&pname=' . $prow["product_name"] . '">Product Review Listings</a>';
}//end if
else {
    $showSellerRating = '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="product_review_lists.php?pid=' . $_GET['productid'] . '&pname=' . $prow["product_name"] . '">Product Review Listings</a>';
    $showSellerRating2 = '&nbsp;&nbsp;|&nbsp;&nbsp;<a href="product_review_lists.php?pid=' . $_GET['productid'] . '&pname=' . $prow["product_name"] . '">Product Review Listings</a>';
}//end else
// End Seller rating Details


/* Report to display the number of times each product viewed */

if ($_SESSION["sess_userid"] != "") {
    productViewedReport(GetSQLValueString($productid, "text"), $_SESSION["sess_userid"]);
}

//Digital Product Flag Check 
$digitalFlag           = isDigital($productid);

/* 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 clickSearch()
    {
        document.frmCatalog.submit();
    }
    function addToCart()
    {       
        document.add_to_cart_areaFrm.submit();
    }
    function openWindow(id)
    {
        var url = "viewimage.php?id="+id;
        window.open(url,"Image","height=500,width=500,scrollbars=yes");
    }
    function CheckStock()
    {
        var txtStock=document.getElementById("txtstock").value;

        txtStock =parseInt(txtStock);

        var txtQty=document.getElementById("txtQty").value;

        txtQty	=parseInt(txtQty);

        if(!IsNumeric(document.getElementById("txtQty").value))
        {
            alert('<?php echo NUMERIC_VALUE_MSG;?>');
            return false;
        }
        if(txtStock==0)
        {
            alert('<?php echo STOCK_NOT_AVAILABLE_MSG;?>');

            return false;

        }
        if(txtQty>txtStock)
        {
            alert('<?php echo STOCK_NOT_AVAILABLE_MSG;?>');
            document.getElementById("txtQty").value=txtStock;
            return false;
        }
        else
        {
            return true;
        }
    }
    function adjustQty()
    {
        if(!IsNumeric(document.getElementById("txtQty").value))
        {
            alert('<?php echo NUMERIC_VALUE_MSG;?>');
            return false;
        }
        var txtStock=document.getElementById("txtstock").value;
        txtStock = parseInt(txtStock);
        var txtQty=document.getElementById("txtQty").value;
        txtQty	= parseInt(txtQty);
        if(txtQty>txtStock)
        {
            document.getElementById("txtQty").value=txtStock;
            alert('<?php echo NO_STOCK_QUANTITY_ADJUSTED_MSG;?>');
            return false;
        }
        else
        {
            return true;
        }

    }
    function IsNumeric(strString) //  check for valid numeric strings
    {
        if(!/\D/.test(strString)) return true;//IF NUMBER
        else return false;
    }
    function changeOption(obj)
    {
        //Santhosh Thomas Alexander wrote on 06/07/2011
        var productOptionID = $.trim($(obj).val());

        var postData = {product_option_id:productOptionID};

        $.ajax({url:'getProductOptionDetailsAjax.php',
            type:'post',
            dataType:'json',
            data:postData,
            beforeSend:function()
            {
                // showAjaxLoader($("#productDetailsTD"))
            },
            complete:function()
            {
                // hideAjaxLodaer();
            },
            success:function(reply)
            {
                if(reply.response)
                {
                    if(reply.response == 'success')
                    {
                        if(reply.value)
                        {
                            $("#bigImageDiv").html(unescape(reply.value.imageUrl));
                            $("#imgDynamicSrc").val(unescape(reply.value.image));

                            var currency = '<?php echo $currency_attributes[0];?>';

                            if(reply.value.show_item_status=='Y') {

                                $("#itemStatus").show();
                                var itemText = '';
                                if(reply.value.stock >0) {
                                    itemText = '<img src="images/in_stock.gif" align="absmiddle">';
                                }
                                itemText += '(&nbsp;'+(reply.value.stock)+'&nbsp;) Items';

                                $("#itemStatusDetail").html(itemText);
                            }
                            $("#txtstock").val(reply.value.stock);

                            if(reply.value.stock > 0)
                            {
                                $("#add_to_cart_areaFrm").attr("action","<?php echo SITE_URL ?>/homepage_addtocart.php?productid=<?php echo $productid ?>&product_option_id="+productOptionID);
                                $("#add_to_cart_area").show('slow');
                                $("#outOfStockArea").hide('slow');

                            }else {
                                $("#add_to_cart_area").hide('slow');
                                $("#outOfStockArea").show('slow');
                            }
                            var product_price = reply.value.price;
                           
                            var discount = reply.value.discount;
                            var product_price_actual = product_price;
                            var product_priceTxt = '';
                            if(reply.value.discount > 0)
                            {
                                $("#discountAmount").html('<b>'+reply.value.discount+'</b>%');
                                $("#discountArea").show('');

                                if(reply.value.discount_description !='')
                                {
                                    $("#discountDescription").html(reply.value.discount_description);
                                    $("#discount_descriptionArea").show();

                                }else {
                                    $("#discountDescription").html('');
                                    $("#discount_descriptionArea").hide();
                                }
                                product_price_actual = product_price - ((product_price*discount)/100);
                                product_price_actual  = product_price_actual.toFixed(2);
                               
                                product_priceTxt = reply.value.currency+product_price_actual+'  (<strike>'+ currency + '&nbsp;'+product_price.toFixed(2)+'</strike>)';

                            }else {
                                product_priceTxt = currency+'&nbsp;'+product_price_actual.toFixed(2);
                                $("#discountArea").hide();
                                $("#discount_descriptionArea").hide();
                            }
                            $("#product_price_val").html(product_priceTxt);
                            $("#shippingWeightVal").html(reply.value.product_shipping_weight+' LBS');


                        }
                    }

                }
            }


        });
    }

</script>
<script language="javascript">
    $(document).ready(function()
    {
        $(".jqReviewShowButton").click(function()
        {
            var myContainer = $(this).parents(".jqReview");
            var myDetails 	= myContainer.find(".jqReviewDetails");

            if(myDetails.is(":visible"))
            {
                myDetails.slideUp();
            }
            else
            {
                myDetails.slideDown();
            }

        });

        /**
         * Tabs
         **/
        $(".jqTabsDetails").hide();
        $(".jqTabsDetails:first").show();
        $(".tabs-nav li:first").addClass('tabs-selected');

        $(".jqTabLink").click(function()
        {

            $(".tabs-nav li").removeClass('tabs-selected');
            $(this).parent('li').addClass('tabs-selected');
            var dvId    = $(this).attr('rel');
            $(".jqTabsDetails").slideUp('slow');
            $("#"+dvId).slideDown('slow');

            /*
                $(".jqTabsDetails:visible").slideUp('slow', function(){
                $(".jqTabsDetails:eq("+ myIndex +")").slideDown();

        });*/
        });

    });
</script>

<?php
if(!empty($product_number)) {
    ?>
<div class="prdetails_container">

    <div class="brdcrumb_container"><?php
            $currentCategory_id = $prow['category_id'];
            echo getProductPageLink("categorydetail.php", $currentCategory_id, stripslashes($prow['product_name']))
            ?></div>
        <?php
        if ($_GET['msg'] == 'stock') {
            ?>

    <div
        style="clear: both; padding: 10px; background-color: #990000; color: #ffffff; margin-bottom: 10px;"><?php echo SELECT_OTHER_OPT_MSG;?> .</div>
                <?php } ?>
    <div class="prodetails_topsection"><!-- Image area-->
        <div class="prdetails_imagearea prdetails_position">
            <?php if($digitalFlag=='Y') {  ?><div class="digital_seal_inr"></div> <?php } ?>
            <div class="prdetails_row" id="bigImageDiv"><?php echo $imageurl; ?></div>
            <input type="hidden" name="imgDynamicSrc" id="imgDynamicSrc"
                   value="<?php echo $product_image ?>"> <?php
                       // Display More Images of Product
                       if (getSettingsValue('more_images') == 'Y') {
                           if ($numrows > 0) {
                               $k = 0;
                               while ($rr = mysql_fetch_array($result_im)) {
                                   $pimage = $rr["vimage_name"];
                                   $productImageDetails[] = $pimage;
                               }

                               if (count($productImageDetails) > 0) {
                                   $productImageDetails[] = $product_image;
                               }
                               ?>
            <div class="prdetails_thumbrow"><?php
                            if (count($productImageDetails) > 0) {
                                foreach ($productImageDetails as $pKey => $pvals) {
                                    if (strstr($pvals, "http://")) {
                                        $imgOpt = $pvals;
                                    } else
                                    if (file_exists('products/' . $pvals) && is_file('products/' . $pvals)) { // check file exists in directory or not
                                        $imgOpt = 'products/' . $pvals;
                                    }
                                    ?> <a onMouseOver="movepic('<?php echo $imgOpt; ?>');"
                   style="cursor: pointer;"> <img src="<?php echo $imgOpt; ?>"
                                               class="prdetails_imgthumb"></a> <?php
                                        // end image exists check
                                    }//end while
                                }
                                ?>
                </table>
            </div>
                        <?php
                    }
                }
                ?></div>
        <!-- Image area ends--> <!-- Product information area-->
        <div class="prdetails_infoarea">

            <div class="prdetails_productname"><?php echo htmlentities(stripslashes($prow["product_name"])); ?>
            </div>

            <div class="prdetails_productinfo">
                <table width="100%" cellpadding="0" cellspacing="0" border="0"
                       class="prdetails_tbl">
                    <?php if($prow["product_code"]!='') { ?>
                    <tr>
                        <td align="left" valign="top" width="26%"><?php echo PRODUCT_ID_TEXT;?></td>
                        <td align="left" valign="top" width="2%">:&nbsp;&nbsp;</td>
                        <td align="left" valign="top" colspan="2"><?php echo htmlentities(stripslashes($prow["product_code"])); ?></td>
                    </tr>
                    <?php } ?>
                    <tr>
                        <td align="left" valign="top" width="26%"><?php echo str_replace(":", "", SELLER_TEXT1);?></td>
                        <td align="left" valign="top" width="2%">:&nbsp;&nbsp;</td>
                        <td align="left" valign="top" colspan="2"><?php echo stripslashes($prow['first_name'])." ".stripslashes($prow['last_name']); ?></td>
                    </tr>
                    <?php
                    if(!empty($prow['storename'])){

                    ?>
                    <tr>
                        <td align="left" valign="top" width="26%"><?php echo TEXT_STORENAME;?></td>
                        <td align="left" valign="top" width="2%">:&nbsp;&nbsp;</td>
                        <td align="left" valign="top" colspan="2">
                            <?php 
                        if ($enable_seller_friendly == "Y") {
                                    $sellerLink = (!empty($prow['storename'])) ? SITE_URL . "/stores/" . $prow['storename'] : SITE_URL . "/store/" . $prow['artist_name'];

                                    } else {
                                   $sellerLink = (!empty($prow['storename'])) ? SITE_URL."/showportfolio.php?storename=" . $prow['storename'] : SITE_URL."/showportfolio.php?artistid=" . $prow['artist_id'];
                                    
                                    }
                                    ?>
                                    <a href="<?php echo $sellerLink; ?>" target="_blank" style="color:#FFFFFF;"><?php echo stripslashes($prow['storename']); ?></a>
                        </td>
                    </tr>
                    <?php
                    }
                    ?>
                    <tr>
                        <td align="left" valign="top" width="26%"></td>
                        <td align="left" valign="top" width="2%">&nbsp;&nbsp;</td>
                        <td align="left" valign="top" colspan="2"><?php
                                echo getProductOptions($prow['product_id'], $prow['product_option_id'], array(), 'product_option');
                                ?></td>
                    </tr>

                        <?php
                        if ($settings[1] == "Y") {
                            $hideStock = "";
                        } else {
                            $hideStock = "style='display:none;'";
                        }
                        ?>
                    <tr id="itemStatus" <?php echo $hideStock; ?>>
                        <td align="left" valign="middle" width="26%"><?php echo ITEM_STATUS_TEXT;?></td>
                        <td align="left" valign="top" width="2%">:&nbsp;&nbsp;</td>
                        <td align="left" valign="middle" colspan="2" id="itemStatusDetail"><?php
                                // Check if product stock exists
                                if ($productinstock) {
                                    ?> <span class="Stock_in_icon"><?php echo TEXT_IN_STOCK; ?></span> <span style="float:left; padding:5px 0 0 0 ; "><?php } ?> ( <?php echo $prow['product_stock'] ?>
		) Items</span></td>
                    </tr>

                        <?php
                        if ($prow["discount"] != 0) {
                            $hidediscount = '';
                        } else {
                            $hidediscount = 'style="display:none;"';
                        }
                        ?>

                    <tr id="discountArea" <?php echo $hidediscount; ?>>
                        <td align="left" valign="middle"><?php echo DISCOUNT_TEXT;?></td>
                        <td align="left" valign="top">:&nbsp;&nbsp;</td>
                        <td align="left" valign="middle" colspan="2" id="discountAmount"><b><?php echo htmlentities($prow["discount"]); ?></b>
		%</td>
                    </tr>




                        <?php
                        if ($prow["discount"] != 0 && $prow["discount_description"] != "") {
                            ?>

                    <tr id="discount_descriptionArea">
                        <td align="left" valign="middle">&nbsp;</td>
                        <td align="left" valign="top">&nbsp;</td>
                        <td align="left" valign="top" colspan="2" id="discountDescription"><?php echo stripslashes($prow["discount_description"]); ?></td>
                    </tr>

                            <?php } ?>

                    <tr>
                        <td align="left" valign="middle" width="20%"><?php echo PRODUCT_RATING_TEXT;?></td>
                        <td align="left" valign="top" width="2%">:&nbsp;&nbsp; <?php $productRating = ProductRatingStar($productid); ?></td>
                        
                         <td align="left" valign="top" width="14%"><?php if ($productRating > 0) {
 ?> <div class="rating_<?php echo $productRating; ?>" id="rating_<?php echo $productRating; ?>"></div> <?php } else {?>
                    <div id="jqNewComment"><?php echo NO_PRODUCT_RATING_TEXT;?></div>
 <?php 
                                
                            } ?> </td>
                        
                        <td width="64%" align="left" valign="middle"><?php if ($_SESSION["sess_userid"] != '' && checkProductRatingStatus($_SESSION["sess_userid"], $productid) == 0) {
                                    ?>
                            <div id="jqRateProduct"><a href="#" class="prdetails_link1"><?php echo RATE_NOW_TEXT;?></a></div>
                                    <?php } ?></td>
                    </tr>

                </table>
            </div>


            <div class="prdetails_productprice"><?php echo PRICE_TEXT;?> &nbsp;:&nbsp;<span
                    id="product_price_val"><?php if ($discountprice != 0) {
                                ?> <?php echo $currency_attributes[0] ?> <?php echo $discountprice; ?>
                    (<strike><?php echo $currency_attributes[0] ?> <?php echo $display_product_price; ?>
                    </strike>) <?php } else {
                            ?> <?php echo $currency_attributes[0] ?> <?php echo $display_product_price; ?>
                            <?php } ?></span></div>
                <?php
                if ($productinstock) {
                    $hideCartArea = '';
                    $hideOutOfStockArea = 'style="display:none;"';
                } else {
                    $hideCartArea = 'style="display:none;"';
                    $hideOutOfStockArea = '';
                }
                ?>

            <div class="prdetails_cartgroup" id="add_to_cart_area"
                     <?php echo $hideCartArea; ?>>
                <form id="add_to_cart_areaFrm" name="add_to_cart_areaFrm" action="<?php echo SITE_URL ?>/homepage_addtocart.php?productid=<?php echo $prow["product_id"] ?>&product_option_id=<?php echo $prow["product_option_id"] ?>" method="post" onSubmit="return CheckStock();">
                    <div class="prdetails_qantity">
                        <div class="txt"><?php echo QUANTITY_TEXT;?></div>
                        <div class="inputbox"><input type="hidden" name="txtstock"
                                                     value="<?php echo $prow['product_stock']; ?>" id="txtstock"> <input
                                                     type="text" class="qantity_input" size="5" value="1" name="txtQty"
                                                     id="txtQty" onChange="return adjustQty();"></div>
                    </div>


                    <div class="left"><a href="javascript:void(0);" onclick="addToCart()" class="add_to_cart_main_button"><?php echo ADD_TO_CART_TEXT; ?></a></div>
                </form>




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


            <div class="prdetails_cartgroup" id="outOfStockArea"
                     <?php echo $hideOutOfStockArea; ?>>
                <div>&nbsp;</div>
                <div class="left"><span class="outOfStock_icon"><?php echo TEXT_OUT_OF_STOCK; ?></span></div>
            </div>



        </div>


        <!-- Product information area ends-->

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

    <div class="prdetails_row">

        <div id="container-8">
            <ul class="tabs-nav">
                <li><a rel="productinfo" href="javascript:;" title="<?php echo TITLE_PRODUCT_INFO; ?>"
                       class="jqTabLink"><span><?php echo PRODUCT_INFO_TEXT;?></span></a></li>
                <li><a rel="manufacturer" href="javascript:;"
                       title="<?php echo TITLE_MANUFACTUREER_DETAILS; ?>" class="jqTabLink"><span><?php echo SELLER_PORTFOLIO_TEXT; ?></span></a></li>
                <li><a rel="ProductReviews" href="javascript:;" title="<?php echo TITLE_PRODUCT_REVIEWS; ?>"
                       class="jqTabLink"><span><?php echo PRODUCT_REVIEWS_TEXT;?></span></a></li>
                <li><a rel="reviews" href="javascript:;" title="<?php echo TITLE_REVIEWS; ?>"
                       class="jqTabLink"><span><?php echo SELLER_FEEDBACK_TEXT;?></span></a></li>
            </ul>

            <div>
                <div id="productinfo" class="tabs-container jqTabsDetails">

                    <table border="0" cellpadding="3" cellspacing="1" width="100%">
                        <tr class="tab_tblbg">
                            <td style="width: 190px;"><strong><?php echo PRODUCT_NAME_TEXT;?></strong></td>
                            <td><span> <?php echo htmlentities(stripslashes($prow["product_name"])); ?></span></td>
                        </tr>


                        <tr class="tab_tblbg">
                            <td><strong><?php echo WEIGHT_TEXT;?></strong></td>
                            <td><span class="prd_dtls" id="shippingWeightVal"> <?php echo $prow['product_shipping_weight'] . ' LBS'; ?>
                                </span></td>
                        </tr>

                        <tr class="tab_tblbg">
                            <td valign="top"><strong><?php echo PRODUCT_DESCRIPTION_TEXT;?></strong></td>
                            <td><span><?php echo html_entity_decode(stripslashes($product_description_format)); ?>
                                </span></td>
                        </tr>

                        <tr class="tab_tblbg">
                            <td ><strong><?php echo SELLER_TEXT1;?>  </strong></td>
                            <td><span class="prd_dtls">  <?php echo stripslashes($prow['first_name'])." ".stripslashes($prow['last_name']); ?></span></td>
                        </tr>

                        <tr class="tab_tblbg">
                            <td ><strong><?php echo SELLER_COMPANY_TEXT1;?> </strong></td>
                            <td><span class="prd_dtls">  <?php echo stripslashes($prow['company']); ?></span></td>
                        </tr>
                    </table>

                </div>
            </div>

            <div id="manufacturer" style="clear: both"
                 class="tabs-container jqTabsDetails"><?php
                         $portfoliodir = SITE_URL . "/portfolios/";
                         $txtArtistPhoto = $prow["artist_photo"];
                         if ($txtArtistPhoto == "") {
                             $sellerimageurl = "<img src='" . $portfoliodir . "noimage.jpg' width='120' height='100' border='0' >";
                         } else {
                             $sellerimageurl = "<img src='" . $portfoliodir . $txtArtistPhoto . "' border='0' width='120' height='100' >";
                         }
                         ?>

                <table width="100%" cellpadding="0" cellspacing="0">
                    <tr class="tab_tblbg">
                        <td width="190" style="width: 190px;"><?php echo COMPANY_NAME_TEXT;?></td>
                        <td width="503"><span> <?php echo stripslashes($prow['company']); ?></span></td>

                        <td width="619" rowspan="3" align="left" valign="top"><?php echo $sellerimageurl ?></td>
                    </tr>
                    <tr class="tab_tblbg">
                        <td style="width: 190px;"><?php echo STATE_TEXT;?></td>
                        <td><span> <?php echo stripslashes($prow['state']) ?> &nbsp; <?php echo stripslashes($prow['city']) ?>
                            </span></td>
                    </tr>
                    <tr class="tab_tblbg">
                        <td style="width: 190px;"><?php echo COUNTRY_TEXT;?></td>
                        <td><span><?php echo stripslashes($prow['country']) ?> </span></td>
                    </tr>
                    <tr class="tab_tblbg">
                        <td colspan="3"><span><?php echo stripslashes($prow['artist_description']) ?>
                            </span></td>
                    </tr>


                    <tr class="tab_tblbg">
                        <td colspan="3" style="width: 190px;"><?php
                                if ($enable_seller_friendly == "Y") {
                                    $sellerLink = (!empty($prow['storename'])) ? SITE_URL . "/stores/" . $prow['storename'] : SITE_URL . "/store/" . $prow['artist_name'];
                                   
                                    } else {
                                   $sellerLink = (!empty($prow['storename'])) ? SITE_URL."/showportfolio.php?storename=" . $prow['storename'] : SITE_URL."/showportfolio.php?artistid=" . $prow['artist_id'];
                                                              
                                    }
                                    ?>
                                    <a href="<?php echo $sellerLink; ?>" target="_blank"><?php echo SELLER_PORTFOLIO_LINK;?></a>
                                </td>
                        <td align="left" valign="top">&nbsp;</td>
                    </tr>
                </table>
            </div>

            <div id="ProductReviews" style="clear: both"
            class="tabs-container jqTabsDetails">
                <script language="javascript">
                    
                // Constants for product-rating.js script

                var msgReviewPostedSuccess = '<?php echo MSG_REVIEW_POSTED_SUCCESSFULLY; ?>';
                var msgReviewNotUpdated = '<?php echo MSG_REVIEW_NOT_UPDATED; ?>';
                var msgReviewPosted = '<?php echo MSG_REVIEW_POSTED; ?>';
                var msgReviewProduct = '<?php echo MSG_REVIEW_PRODUCT; ?>';

                var msgRateProduct = '<?php echo MSG_RATE_PRODUCT; ?>';
                var msgRateNotUpdated = '<?php echo MSG_RATE_NOT_UPDATED; ?>';
                var msgRatePosted = '<?php echo MSG_RATE_POSTED; ?>';
                var msgRatePostedSuccess = '<?php echo MSG_RATE_POSTED_SUCCESSFULLY; ?>';

                var msgRateSeller = '<?php echo MSG_RATE_SELLER; ?>';
                var msgSellerFeedback = '<?php echo MSG_GIVE_SELLER_FEEDBACK; ?>';
                var msgFeedbackNotUpdated = '<?php echo MSG_FEEDBACK_NOT_UPDATED; ?>';
                var msgFeedbackPosted = '<?php echo MSG_FEEDBACK_POSTED; ?>';
                var msgFeedbackPostedSuccess = '<?php echo MSG_FEEDBACK_POSTED_SUCCESSFULLY; ?>';

                var msgHideDetails = '<?php echo MSG_HIDE_DETAILS; ?>';
                var msgClickForMore = '<?php echo MSG_CLICK_FOR_MORE; ?>';


                </script>
                <script language="javascript" src="<?php echo SITE_URL ?>/js/product-rating.js"></script>
                <div id="jqRateImage" class="postproduct_rev"
                     style="font: Verdana, Arial, Helvetica, sans-serif;"><?php echo $showProductReviewLink; ?></div>

<div id="jqNewComment1" class="revcmntsdiv"><p> </p></div>
    <?php
                    if ($ProductReviewCount > 0) {

                        while ($reviewObj = mysql_fetch_object($rs_review)) {
                            ?>
                <div class="reviecontents jqReview">
                    <div class="clientname">
                        <h5><?php echo $reviewObj->first_name; ?> &nbsp; <?php echo $reviewObj->last_name; ?></h5>
                    </div>
                    <div class="subsec"><a href="javascript:;" class="jqReviewShowButton"
                                           title="View comment">
                            <div class="commens_icon ">&nbsp;</div>
                        </a>
                        <div class="clear"></div>
                    </div>
                    <div class="revcmntsdiv jqReviewDetails" style="display: none">
                        <p><?php echo stripslashes($reviewObj->vDes); ?></p>
                    </div>
                    <div class="clear"></div>
                </div>
                            <?php
                        }
                        ?>
                <div class="feedbklnk"><br>
                            <?php echo $showProductReviewMoreLink; ?></div>

                        <?php
                    } else {
                        echo "&nbsp;".AWAITING_REVIEWS_TEXT;
                    }
                    ?></div>

            <div id="reviews" style="clear: both"
                 class="tabs-container jqTabsDetails">
                <div class="reviews_section"><?php
                        if (checkSellerRatingStatus($prow['artist_id'], $_SESSION["sess_userid"], $productid) == 0 && $_SESSION["sess_userid"] != '') {
                            ?>
                    <div id="jqSellerRating"><a href="#"><?php echo POST_SELLER_FEEDBACK_TEXT;?> </a></div>

                            <?php
                        }
                        ?>

                    <div class="review_div1"
                         style="font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
                 <!--<div id="jqNewSellerComment" class="revcmntsdiv"><p></p></div>--> <?php
                            if ($totalsellerFeedbackRows > 0) {
                                while ($feedbackObj = mysql_fetch_object($rs_seller_feedback)) {
                                    ?>
                        <div class="reviecontents jqReview">
                            <div class="clientname">
                                <h5><?php echo $feedbackObj->first_name; ?>&nbsp;<?php echo $feedbackObj->last_name; ?>&nbsp;&nbsp;<span
                                        style="float: right; padding: 0;"><strong><?php echo ON_TEXT;?></strong>&nbsp;<?php echo dateFormat($feedbackObj->date_added, "Y-m-d", "m/d/Y"); ?></span></h5>
                            </div>
                            <div class="subsec"><a href="javascript:;" class="jqReviewShowButton"
                                                   title="View comment">
                                    <div class="commens_icon ">&nbsp;</div>
                                </a>
                                <div class="clear"></div>
                            </div>

                            <div class="revcmntsdiv jqReviewDetails" style="display: none">
                                <p><?php echo stripslashes($feedbackObj->feedback_content); ?></p>

                                <div class="ratings">
                                    <div
                                        class="rating_<?php echo GetSellerRatingStar($feedbackObj->artist_feedback_id) ?>"></div>
                                </div>

                            </div>
                            <div class="clear"></div>
                        </div>
                                    <?php
                                }
                                ?>

                        <div class="viewmorefdback"><a
                                href="<?php echo SITE_URL ?>/artistfeedbacks.php?artistid=<?php echo $prow['artist_id'] ?>&productid=<?php echo $productid ?>"><?php echo MORE_SELLER_FEEDBACK_TEXT;?> </a></div>

                                <?php
                            } else {
                                echo "<br/>&nbsp;&nbsp;".AWAITING_FEEDBACK_TEXT;
                            }
                            ?>
                        <div class="clear"></div>
                    </div>
                        <?php }  else  echo "<strong>Sorry! The product is not available</strong>";?>

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


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

        </div>


    </div>


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

<script language="javascript" src="<?php echo SITE_URL ?>/js/jquery-rating.js"></script>

<!-- Product Review Posting  Box -PopUp HTML Start Here-->
<div id="jqStarRatingPop" style="display:none; height:250px;">
    <div style="width:380px;"><h1 style="font-size:19px; "><?php echo POST_REVIEW_ON_TEXT;?> <?php echo stripslashes($prow['product_name']); ?></h1></div>
    <div id="jqLoader" style="display:none;"><img src="images/rating/loading.gif" border="0" class="loader" alt="" /></div>
    <div id="ReviewArea">
        <form name="frmReview" method="post" action="#" >
            <table cellpadding="1" cellspacing="1" width="100%" border="0" class="ratingBox">

                <tr>
                    <td colspan="2" align="left" class="ratingReview">
                        <textarea rows="6" cols="53" name="txtReview" id="txtReview"></textarea>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="hidden" name="hidPostId" id="hidPostId" value="<?php echo $productid ?>" />
                        <input type="button" value="<?php echo SUBMIT_BUTTON;?>" class="jqPostRating" id="comn_button_blue"/>
                        <input type="button" value="<?php echo CANCEL_BUTTON;?>" class="jqRatingCancel" id="comn_button_blue"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<!-- Product Review Light Box -PopUp HTML End  Here-->

<!-- Product Rating Popup  HTML Start Here-->

<div id="jqRatingPop" style="display:none;">
    <div style="width:280px;"><h1><?php echo RATE_PRODUCT_TEXT;?>  (<?php echo stripslashes($prow['product_name']); ?>)</h1></div>
    <div id="jqLoader" style="display:none;"><img src="images/loading.gif" border="0" class="loader" alt="" /></div>
    <div id="ratingArea">
        <form name="frmRate" method="post" action="#" >
            <table cellpadding="1" cellspacing="1" width="100%" border="0" class="ratingBox">

                <tr><td colspan="2">&nbsp;</td></tr>
                <tr>
                    <td class="emailStoryStyle"><strong><?php echo RATE_LABEL;?></strong></td>
                    <td>
                        <input name="star1" type="radio" class="star" value="1" />
                        <input name="star1" type="radio" class="star" value="2" />
                        <input name="star1" type="radio" class="star" value="3" />
                        <input name="star1" type="radio" class="star" value="4" />
                        <input name="star1" type="radio" class="star" value="5" />
                    </td>
                </tr>

                <tr><td colspan="2">&nbsp;</td></tr>
                <tr><td colspan="2">&nbsp; </td></tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="hidden" name="hidProductid" id="hidProductid" value="<?php echo $productid; ?>" />

                        <input type="hidden" name="hidProductSellerid" id="hidProductSellerid" value="<?php echo $prow['artist_id']; ?>" />
                        <input type="button" value="<?php echo RATE_PRODUCT_BUTTON;?>" style="background-color:#333333; font-weight: bold; color:#FFFFFF; padding: 5px 8px; border:1px solid #333333; " class="jqPostProductRating" id="comn_button_blue1"/>
                        <input type="button" value="<?php echo CANCEL_BUTTON;?>"  style="background-color:#333333; font-weight: bold; color:#FFFFFF; padding: 5px 8px; border:1px solid #333333; " class="jqProductRatingCancel" id="comn_button_blue2"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<!-- Product Rating Popup  HTML End  Here-->


<!--- Seller Rating Popup Start Here--->

<!-- Product Review Posting  Box -PopUp HTML Start Here-->
<div id="jqSellerRatingPop" style="display:none;">
    <div style="width:380px;"><h1><?php echo POST_SELLER_FEEDBACK_TEXT1;?> </h1></div>
    <div id="jqLoader" style="display:none;"><img src="images/rating/loading.gif" border="0" class="loader" alt="" /></div>
    <div id="ReviewArea">
        <form name="frmSellerRating" method="post" action="#" >
            <table cellpadding="1" cellspacing="1" width="100%" border="0" class="ratingBox">

                <tr>
                    <td colspan="2" align="left" class="ratingReview">
                        <textarea rows="6" cols="40" name="txtSellerReview" id="txtSellerReview"></textarea>
                    </td>
                </tr>
                <tr><td colspan="2">&nbsp; </td></tr>
                <tr>
                    <td class="emailStoryStyle"><strong><?php echo RATE_LABEL?></strong></td>
                    <td>
                        <input name="star2" type="radio" class="star" value="1" />
                        <input name="star2" type="radio" class="star" value="2" />
                        <input name="star2" type="radio" class="star" value="3" />
                        <input name="star2" type="radio" class="star" value="4" />
                        <input name="star2" type="radio" class="star" value="5" />
                    </td>
                </tr>
                <tr><td colspan="2">&nbsp; </td></tr>
                <tr>
                    <td align="center" colspan="2">
                        <input type="hidden" name="hidSellerPostId" id="hidSellerPostId" value="<?php echo $prow['artist_id']; ?>" />
                        <input type="button" value="<?php echo SUBMIT_BUTTON;?>" class="jqSellerRating" id="comn_button_blue"/>
                        <input type="button" value="<?php echo CANCEL_BUTTON;?>" class="jqSellerRatingCancel" id="comn_button_blue"/>
                    </td>
                </tr>
            </table>
        </form>
    </div>
</div>

<!-- End Seller RAting PopUp-->

<?php
include "includes/" . $active_template[2]; /* Bottom File Name */
?>
</body>
</html>
<script language="javascript" type="text/javascript">
    function movepic(img_src)
    {
        document.getElementById('itemImage').src=img_src;
        document.getElementById('imgDynamicSrc').value = img_src;
    }

    function PopWin(url,name,options){
        var ContextWindow = window.open(url,name,options);
        ContextWindow.opener = this;
        ContextWindow.focus();
    }
    function PopWinlarge(url,name,options){

        var mySplitResult = url.replace("thumb_","");
        var ContextWindow = window.open(mySplitResult,name,options);
        ContextWindow.opener = this;
        ContextWindow.focus();
    }
    function PopWinbig(url,name,options){
        var url  = document.getElementById('imgDynamicSrc').value;
        var url = url.replace("thumb_","");
        var ContextWindow = window.open(url,name,options);
        ContextWindow.opener = this;
        ContextWindow.focus();

    }

</script>
<style>
    .tableborder
    {
        border:1px solid #333333;
    }
</style>
