// ???
function Cart()
{
	var cart = getCookie("newcart")
	this.product = new Array()
	this.classid = new Array()
	this.price = new Array()
	this.quantity = 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.save=Cart_save
	this.addProduct=Cart_addProduct
	this.deleteProduct = Cart_deleteProduct
	this.cart_in = Cart_in
}
// 
function Cart_save()
{
	var cart = "";
	for (var i=0;i<this.product.length ;i++ )
	{
		cart += this.product[i]+"-"+this.classid[i]+"-"+this.price[i]+"-"+this.quantity[i]
		if (i!=this.product.length-1)
		{
			cart +=":"
		}
	}
	setCookie("newcart",cart)
}
function Cart_addProduct(n,c,p,q)
{
	for (var i=0;i<this.product.length;i++ )
	{
		if (this.product[i]==n && this.quantity[i]==q)
		{
			return
		}
	}
	var last = this.product.length
	this.product[last]=n
	this.classid[last]=c
	this.price[last]=p
	this.quantity[last]=q
}
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)
				break
			}
		}
	}
}
function Cart_in(){
	var i = getCookie("AIGOMUSICLGTOKEN");
	if (i!=""){
		alert("您选择的音乐已加入购物车！");
	}else{
		alert("您选择的音乐已加入购物车！请您登陆网站！");
		window.open("http://passport.aigomusic.com/cn/login.shtml");
	}
}