﻿// JScript 文件
var xmlHttp;
    
    function createXmlHttpRequest()
    {
        if(window.XMLHttpRequest)
        {
            xmlHttp=new XMLHttpRequest();
        
            if(xmlHttp.overrideMimeType)
                {
                    xmlHttp.overrideMimeType("text/xml");
                }
        }
        else if(window.ActiveXObject)
        {
            try
            {
                xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");   
            }
            catch(e)
            {
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");   
            }
        }
        if(!xmlHttp)
        {
            window.alert("你的浏览器不支持创建XMLhttpRequest对象");
        }
        return xmlHttp;
    }

    
function CheckUserName(name)
{
   
        createXmlHttpRequest();
    
        var url="../products/shouchang.aspx?pid="+name+"&type=store";
    
        xmlHttp.open("post",url,true);
    
        xmlHttp.onreadystatechange=CheckUserNameResult;
    
        xmlHttp.send(null);

}


function CheckUserNameResult()
{
    if(xmlHttp.readyState==4)//服务器响应状态
    {
        if(xmlHttp.status==200)//代码执行状态
        {
            if(xmlHttp.responseText=="1")
            {
                   window.alert("请先登录!才能收藏商品");
                   window.location="../user/login.aspx?pageurl="+window.location.href;
            }
            else
            {
                  if(xmlHttp.responseText=="true")
                  {
                       window.alert("收藏成功!");
                
                  }
                  else
                  {
                       window.alert("该产品已在您的收藏夹!");
                  }
            }
        }
    }
}

