
function GetId(id){return document.getElementById(id);}
function ShowCart(){
var re=Cart.ShowCart().value;
GetId('CartTb').innerHTML=re;}
ShowCart();
function RemoveProductFromCart(productId){
if(confirm('确定不购买该商品？')){
Cart.RemoveProductFromCart(productId);
alert('已将该商品从购物车中移除！');}
ShowCart();}
function UpdateProductQuantity(productId,obj){
var newCount=obj.value;
if(obj.value==GetId('txtQuantity_hid_'+productId).value){
return false;}
if(!checkNumber(newCount)){
alert('商品数量应填正整数！');
obj.value=GetId('txtQuantity_hid_'+productId).value
return false;}
Cart.UpdateProductQuantity(productId,newCount);
ShowCart();
alert('商品数量已更新！');}
function ChangeProductQuantity(productId,doType){
var txtObj=GetId('txtQuantity_'+productId);
var oldValue=parseInt(txtObj.value);
if(doType=='+'){
txtObj.value=oldValue+1;}
if(doType=='-'){
txtObj.value=oldValue-1;}
UpdateProductQuantity(productId,txtObj);}
function checkNumber(value){
var re=/^[1-9]+[0-9]*]*$/;
if(!re.test(value)){
return false;}
return true;}
function gotoReceiptInfo(){
var re=Cart.CheckCartHasAny().value;
if(re){
location.href='receiptInfo.aspx';}
else{
alert('当前购物车为空，请先选择商品！');}}
function continueShopping(){
var from=document.referrer;
if(from.indexOf("/Product/")>-1){
location.href=from;}
else{
location.href='/product';}}

