

<?php
if (!defined('IN_CONTEXT')) die('access violation error!');
$cols = $p_cols;

?>

		<div class="newprod">
				<div class="newprod_top"></div>
				<div class="newprod_con">

            <script type="text/javascript" language="javascript">
            <!--
                function updatecartstate(response) {
                    var o_result = _eval_json(response);
                    if (!o_result) {
                        return addprodfailed(response);
                    }
                    
                    if (o_result.result == "ERROR") {
                        alert(o_result.errmsg);
                        return false;
                    } else if (o_result.result == "OK") {
                        $("#disp_n_prds").html(o_result.n_prds);
                        alert("<?php _e('The product has been added to cart!'); ?>");
                        return true;
                    } else {
                        return on_failure(response);
                    }
                }
                
                function addprodfailed(response) {
                    alert("<?php _e('Request failed!'); ?>");
                    return false;
                }
                
                function add2cart(p_id) {
                    var p_num = document.getElementById("prod_num_" + p_id).value;
                    _ajax_request("mod_cart", "addtocart", 
                        { p_id: p_id, p_num: p_num }, updatecartstate, addprodfailed);
                }
            //-->
            </script>
			
<?php
$n_prd = sizeof($products);
if ($n_prd > 0){
?>
	<table class="media_grid" cellspacing="4" width="100%">
		<?php
		for ($i = 0; $i < $n_prd; $i++) {
			if ($i % $cols == 0) {
				echo '<tr>';
			}
		?>
			<td>
            <div class="newprod_list">
				<div class="newprod_pic"><a href="<?php echo $products[$i]->feature_img; ?>" class="thickbox" title="<?php echo $products[$i]->name;?>"><img name="picautozoom" border="0" src="<?php echo $products[$i]->feature_smallimg;?>" class="prodthumb" /></a></div>
                <div class="newprod_name"><a href="index.php?<?php echo Html::xuriquery('mod_product', 'view', array('p_id' => $products[$i]->id)); ?>" ><?php echo $products[$i]->name;?></a></div>
                <div class="newprod_price">￥<?php echo $products[$i]->price;?></div>
				<div class="newprod_intr"><?php echo Toolkit::substr_MB($products[$i]->introduction, 0, 26);?>...</div>
				<?php if(1>2){?><div class="newprod_intr1"><div class="newprod_xx" onclick="location.href='index.php?<?php echo Html::xuriquery('mod_product', 'view', array('p_id' => $products[$i]->id)); ?>'"></div><div class="newprod_gg" onclick="add2cart('<?php echo $products[$i]->id; ?>');return false;"><input type="hidden" name="prod_num_<?php echo $products[$i]->id; ?>" id="prod_num_<?php echo $products[$i]->id; ?>" value="1" /></div></div><?php }?>
                <div class="blankbar1"></div>
            </div>
            
			</td>
		<?php
			if (($i % $cols) == ($cols - 1)) {
				echo '</tr>';
			}
		}
		if ($i % $cols != 0) {
			for ($j = 0; $j < ($cols - $i); $j++) {
				echo '<td width="'.intval(100 / $cols).'%">&nbsp;</td>';
			}
			echo '</tr>';
		}
		?>
	</table>
<?php } ?>

	
			</div>
				<div class="list_bot"></div>
			</div>
			<div class="blankbar"></div>


