<!--#include file="htmlhead.html"-->
<!--#include file="header.html"-->
<div class="wbox">
	<ul class="flow-steps">
    	<li class="on"><b class="f"></b><span>1、查看購物車</span><s></s></li>
        <li><b></b><span>2、確認訂單信息</span><s></s></li>
        <li><b></b><span>3、為訂單付款</span><s></s></li>
		<li><b></b><span>4、確認收貨</span><s></s></li>
        <li><b></b><span>5、評價</span><s></s></li>
    </ul>
</div>

<div class="wbox">
	<br/>
	<div class="grid-container grid-ttl-tr fn-clear">
		<div class="grid2 gcenter gridnomargin">圖片</div>
		<div class="grid7 gleft">商品名稱</div>
		<div class="grid3 gright">單價(元)</div>
		<div class="grid3 gright">優惠價(元)</div>
		<div class="grid3 gright">數量(件)</div>
		<div class="grid3 gright">小計(元)</div>
		<div class="grid3">&nbsp;</div>
	</div>
	<% dim carttotalmoney:carttotalmoney=0 %>
	<% do while not rs.eof %>
		<%
		dim cartaucbuyprice
		cartaucbuyprice=rs("aucbuyprice")
		if chknum(rs("msaucdiscountprice")) then
			cartaucbuyprice=rs("msaucdiscountprice")
		end if
		cartaucbuyprice=formatNumber(cartaucbuyprice,2,-1,0,0)
		%>
		<div class="grid-container grid-cnt-tr fn-clear" J-cart-list="item">
			<div class="grid2 gcenter gridnomargin"><img src="<%=SYS_HTTP_WEBURL & rs("aucimageurl")%>" width="60" height="60" border="0" alt="" style="border:1px #eee solid;"/></div>
			<div class="grid7 gleft">
				<a href="<%=SYS_HTTP_WEBURL%>item.asp?aucid=<%=rs("aucid")%>" target="_blank"><%=rs("aucitemtitle")%></a><br/>
				賣家：<%=rs("bbruname")%> &nbsp; <%=Disp_UserCredit(rs("aucitemowner"),rs("creditseller"),0)%><br/>
				可購數量：<%=rs("aucnum")%>件 &nbsp; 所在地：<%=rs("BBR_AucProv")%><%=rs("BBR_AucCity")%>
			</div>
			<div class="grid3 gright">
				<% if chknum(rs("msaucdiscountprice")) then %>
					<s><%=formatNumber(rs("aucbuyprice"),2,-1,0,0)%></s>
				<% else %>
					<span id="cartitemprice<%=rs("cartid")%>"><%=formatNumber(rs("aucbuyprice"),2,-1,0,0)%></span>
				<% end if %>
			</div>
			<div class="grid3 gright">
				<% if chknum(rs("msaucdiscountprice")) then %>
					<span id="cartitemprice<%=rs("cartid")%>" class="CurrentPrice_ex"><%=formatNumber(rs("msaucdiscountprice"),2,-1,0,0)%></span>
				<% end if %>
			</div>
			<div id="cartitemquantity<%=rs("cartid")%>" class="grid3 gright"><input name="cartgoodsquantity" type="text" value="<%=rs("cartgoodsquantity")%>" cartid="<%=rs("cartid")%>" J-bbrcartgoodsid="<%=rs("aucid")%>" J-bbrcartgoodsownerid="<%=rs("aucitemowner")%>" size="3" style="text-align:center" /></div>
			<div id="cartitemmoney<%=rs("cartid")%>" class="grid3 gright" J-bbr-cart="itemmoney"><%=formatNumber(cartaucbuyprice*rs("cartgoodsquantity"),2,-1,0,0)%></div>
			<div class="grid3"><a href="<%=SYS_HTTP_WEBURL%>bbr_ajaxaddtocart.asp?act=del&cartid=<%=rs("cartid")%>">刪除</a></div>
		</div>
		<% carttotalmoney=carttotalmoney+formatNumber(cartaucbuyprice*rs("cartgoodsquantity"),2,-1,0,0) %>
		<% rs.movenext %>
	<% loop %>
	<div class="grid-container grid-ttl-tr fn-clear">
		<div class="grid24 gright gridnomargin">商品總價(不含運費)：<span class="carttotalmoney"><%=formatNumber(carttotalmoney,2,-1,0,0)%></span> 元</div>
	</div>
	<div class="grid-container fn-clear">
		<div class="grid6 gleft gridnomargin"><br/><br/>
			<a href="<%=SYS_HTTP_WEBURL%>">繼續購物</a> &nbsp; | &nbsp;
			<a href="<%=SYS_HTTP_WEBURL%>bbr_ajaxaddtocart.asp?act=clearall">清空購物車</a>
		</div>
		<div class="grid18 gright">
			<br/>
			<a class="bbr-button"><input id="bbr-form-fill-submitbtn" type="button" value="下一步，確認訂單" onclick="javascript: location.href='confirmorder.asp';" /></a>
			<br/><br/>
		</div>
	</div>
</div>
<!--#include file="footer.html"-->
<script type="text/javascript">
<!--
	//cart
	$(document).ready(function(){
		$("input[name=cartgoodsquantity]").each(function(){
			$(this).change(function(){
				var $thistrogger=$(this);
				var buyquantity=$thistrogger.val();
				if(isNaN(buyquantity)){
					alert('購買數量必須填寫整數數字！');
					return false;
				}
				buyquantity=parseInt(buyquantity);
				var bbrcartgoodsid=$thistrogger.attr("J-bbrcartgoodsid");
				if(isNaN(bbrcartgoodsid)){
					alert('商品屬性錯誤，無法更新購物車！');
					return false;
				}
				var bbrcartgoodsownerid=$thistrogger.attr("J-bbrcartgoodsownerid");
				if(isNaN(bbrcartgoodsownerid)){
					alert('商品屬性錯誤，無法更新購物車！');
					return false;
				}
				$.ajax({
					type: "post",
					url: $("#J_BBRWEBURL").val()+"bbr_ajaxaddtocart.asp",
					data: {act:'update',goodsid:bbrcartgoodsid,goodsownerid:bbrcartgoodsownerid,goodsquantity:buyquantity},
					beforeSend: function(XMLHttpRequest){
						$thistrogger.css("background","orange");
					},
					success: function(data, textStatus){
						if(data=='[success]'){
							//alert('成功更新購物車！');
							var thiscartid=$thistrogger.attr("cartid");
							var $cartitemprice=$("#cartitemprice"+thiscartid.toString());
							var $cartitemquantity=$("#cartitemquantity"+thiscartid.toString());
							var $cartitemmoney=$("#cartitemmoney"+thiscartid.toString());
							var cartitemmoney=parseFloat(($cartitemprice.text())*parseInt($thistrogger.val()));
							cartitemmoney=Math.round(cartitemmoney*Math.pow(10, 2))/Math.pow(10, 2);
							cartitemmoney=cartitemmoney.toString();
							if(cartitemmoney.indexOf(".")>0){cartitemmoney=cartitemmoney.substr(0,cartitemmoney.indexOf(".")+3);}
							$cartitemmoney.text(cartitemmoney);
							var carttotalmoney=0;
							$("div[J-bbr-cart=itemmoney]").each(function(){
								carttotalmoney=carttotalmoney + parseFloat($(this).text());
							});
							$(".carttotalmoney").text(carttotalmoney);
							return false;
						}else{
							alert('更新購物車操作失敗！');
							return false;
						}
					},
					complete: function(XMLHttpRequest, textStatus){
						$thistrogger.css("background","white");
					},
					error: function(){
						//請求出錯處理
					}
				});
			});
		});
	});
//-->
</script>