﻿	var xmlHttp;				
	function createXMLHttpRequest()
	{
		if(window.ActiveXObject)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		else if(window.XMLHttpRequest)
		{
			xmlHttp=new XMLHttpRequest();
			xmlHttp.overrideMimeType("text/xml");
		}
		else if(Msxml2.ActiveXObject)
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	}
	
	function Buy(goodId)
	{
		createXMLHttpRequest();
		BuyServer(goodId);				
	}
	
	function BuyCallback()
	{
		if(xmlHttp.readyState==4)
		{
			if(xmlHttp.status==200)
			{
				var result=new String(xmlHttp.responseText);
				if(result.indexOf("|")<0)
				{
					alert(result);
				}
				else
				{
					//Reply();
					alert("恭喜，操作成功啦！");
					//document.open('/userManage/plaza/cue.htm','提示','width=205,height=105');
					//var array=result.split("|");
					//document.getElementById("lblCount").innerHTML=array[0];
					//document.getElementById("lblTotal").innerHTML=array[1];
				}
			}
		}
	}
	
	function Reply()
	{
		Gradually();
	}
	function Gradually()
	{
		setTimeout("ChangeColor('#FFF9F2')",200);
		//setTimeout("ChangeColor('#FFE3C8')",200*1);
		//setTimeout("ChangeColor('#FFD9B3')",200*2);
		//setTimeout("ChangeColor('#FFCE9D')",200*3);
		setTimeout("ChangeColor('#FFC488')",200*4);
		//setTimeout("ChangeColor('#FFB973')",200*5);
		//setTimeout("ChangeColor('#FFAE5E')",200*6);
		//setTimeout("ChangeColor('#FFA448')",200*7);

		setTimeout("ChangeColor('#ff9933')",200*8);
		//setTimeout("ChangeColor('#FFA448')",200*9);
		//setTimeout("ChangeColor('#FFAE5E')",200*10);
		//setTimeout("ChangeColor('#FFB973')",200*11);
		setTimeout("ChangeColor('#FFC488')",200*12);
		//setTimeout("ChangeColor('#FFCE9D')",200*13);
		//setTimeout("ChangeColor('#FFD9B3')",200*14);
		//setTimeout("ChangeColor('#FFE3C8')",200*15);
		//setTimeout("ChangeColor('#FFF9F2')",200*16);
		setTimeout("ChangeColor('#FFFFFF')",200*17);
	}
	function ChangeColor(color)
	{
		document.getElementById("selfBody").setAttribute("bgColor",color);	
	}

	
	function BuyServer(goodId)
	{
		//var hostName=document.location.hostname;
		var url="/userManage/plaza/cartStore.aspx?type=buy&goodId="+goodId+"&timeSpan="+new Date().getTime();
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=BuyCallback;
		xmlHttp.send(null);
	}
	function Store(goodId)
	{
		createXMLHttpRequest();
		storeServer(goodId);				
	}
	function storeServer(goodId)
	{
		//var hostName=document.location.hostname;
		var url="/userManage/plaza/cartStore.aspx?type=store&goodId="+goodId+"&timeSpan="+new Date().getTime();
		xmlHttp.open("GET",url,true);
		xmlHttp.onreadystatechange=BuyCallback;
		xmlHttp.send(null);
	}
