
function AddToCart()
{
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
        alert ("您的浏览器不支持AJAX！");
        return;
    }
    var url="AddToCart.aspx";
    url = url+"?Action=Add";
    url=url+"&ID="+document.getElementById("ID").value;
    url=url+"&HuiboStyle="+document.getElementById("HuiboProduct$Color").value + "," + document.getElementById("HuiboProduct$Size").value;
    url=url+"&ProductNum="+document.getElementById("ProductNum").value;
    url = url+"&sid="+Math.random();
    alert(url);
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
	xmlDoc.async=false;
        
	xmlDoc.load(url)
       
    if(xmlDoc.childNodes(1).childNodes(0).childNodes(0).text == "添加成功")
    {
        //window.close();
        //alert("成功！");
        
        //location.href="UserCenter.aspx?Action=addtocart";
        //return true;
        window.opener=null;
        window.open("","_self");
        window.close();
        window.open("UserCenter.aspx?Action=addtocart");
        return;
    }
    else if(xmlDoc.childNodes(1).childNodes(0).childNodes(0).text == "已有")
    {
        alert("此商品已在购物车中,请勿重复添加！");
    }
    else
    {
        window.opener=null;
        window.open("","_self");
        window.close();
        window.open("login.aspx");
        //alert("请登录！");
    }
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}