﻿// JScript 购物车操作

window.onload = function()
  {
      //alert("当window.onload时");
      if(window.name!="MyCart")
      {
          window.name="MyCart";
          this.location.href="Cart.aspx";
          //window.open(this.location.href,"MyCart");
       }
       else
       {        
          window.focus();//当运行购物车页面时,当前页获取焦点
          InitCart();//初始化购物车
      }
  }	

//删除购物车中的商品
function DelProductOfCart(ProductID,ProductColorID)
{
  if(ClaCart.DelProductOfCart(ProductID,ProductColorID).value)
  {     
     //alert("删除成功");
   }
   InitCart();//更新购物车显示信息
}

//更新购物车中商品的数量
function UpdateProductOfCart(ProductID,ProductColorID,txtTotalName)
{
 var strTotal=getElementObjByID(txtTotalName).value;
 if(isNaN(strTotal))
    {
      alert("商品数量必须为数字");
      return false;
     }
     else if(parseInt(strTotal)<=0)
     {
         alert("商品数量必须为大于0的数字");
         return false;
     }
  var Result=ClaCart.UpdateProductOfCart(ProductID,ProductColorID,strTotal).value;
  if(Result)
  {    
    //alert("更改成功");
   }
  InitCart();//更新购物车显示信息
}

function InitCart()//初始化购购车信息
{   		
	getElementObjByID("MyCart").innerHTML = ClaCart.GetSessionProductOfCart("/Template/Cart.html").value;
}//end function InitCart()

