// ???
function Cartshuma()
{
	var cart = getCookie("newcart")
	this.product = new Array()
	this.classid = new Array()
	this.price = new Array()
	this.quantity = new Array()
	this.count = new Array()
	if (cart !="")
	{
		var pairs = cart.split(":")
		for (var i=0;i<pairs.length ;i++ )
		{
			var pairSplit = pairs[i].split("-")
			this.product[i]=pairSplit[0]
			this.classid[i]=pairSplit[1]
			this.price[i]=pairSplit[2]
			this.quantity[i]=pairSplit[3]
			this.count[i]=pairSplit[4]
		}
	}
	this.saveshuma=Cart_saveshuma
	this.addProductshuma=Cart_addProductshuma
	this.deleteProduct = Cart_deleteProduct
	this.cart_inshuma = Cart_inshuma
	this.cart_update = Cart_update
}
// 
function Cart_saveshuma()
{
	var cart = "";
	for (var i=0;i<this.product.length ;i++ )
	{
		cart += this.product[i]+"-"+this.classid[i]+"-"+this.price[i]+"-"+this.quantity[i]+"-"+this.count[i]
		if (i!=this.product.length-1)
		{
			cart +=":"
		}
	}
	setCookie("newcart",cart)
}
function Cart_addProductshuma(n,c,p,q,s)
{
	for (var i=0;i<this.product.length;i++ )
	{
		if (this.product[i]==n && this.quantity[i]==q)
		{
			this.count[i]++;
			return
		}
	}
	var last = this.product.length
	this.product[last]=n
	this.classid[last]=c
	this.price[last]=p
	this.quantity[last]=q
	this.count[last]=s
}
function Cart_deleteProduct(n)
{
	var p = n.split(",")
	for (var j=0;j<p.length-1;j++){
		for (var i=0;i<this.product.length ;i++ )
		{
			if (this.product[i]==p[j])
			{
				this.product.splice(i,1)
				this.classid.splice(i,1)
				this.price.splice(i,1)
				this.quantity.splice(i,1)
				this.count.splice(i,1)
				break
			}
		}
	}
}

function Cart_update(n,c)
{
	var p = n.split(",")
	var count = c.split(",")
	for (var j=0;j<p.length-1;j++){
		for (var i=0;i<this.product.length ;i++ )
		{
			if (this.product[i]==p[j])
			{
				this.count[i]=count[j]
				break
			}
		}
	}
}

function Cart_inshuma(){
	var i = getCookie("AIGOMUSICLGTOKEN");
	if (i!=""){
		alert("您选择的商品已加入购物车！");
	}else{
		alert("您选择的商品已加入购物车！请您登陆网站！");
		window.open("http://passport.aigomusic.com/cn/login.shtml");
	}
}