﻿     
 var xmlHttp = false;

//microsoft 浏览器
try 
{
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} 
catch (e) 
{
  try 
  {
     xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
  } 
  catch (e2) 
  {
    xmlHttp = false;
  }
}


//非Microsoft 浏览器
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') 
{
  xmlHttp = new XMLHttpRequest();
}


//--------------------------------------------------------------------------------------------------
//分类中，当大类改变时，传送大类ID
function ChangeLargeCate(largeID)
{
       alert(largeID);
    var url="Ajax_GetSmallCate.aspx?largeID="+largeID;  
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=GetClickNum;
    xmlHttp.send(null);
    
}

//分类中，当大类改变时，返回的小类的值
function GetSmallCateByLarge()
{
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {   
            var smallControl=document.getElementById("search1$ddlSmall");
            smallControl.length=0;
            
            var newOption1 = document.createElement("OPTION");　
            newOption1.text = "-请选择小类-";　
            newOption1.value = "0";
            smallControl.options.add(newOption1);　

        
            var request=xmlHttp.responseText.split(",");
            for(var i=0;i<request.length;i+2)
            {
                if(request[i]==null || request[i+1]==null)
                {
                    break;
                }
                var newOption = document.createElement("OPTION");　
                newOption.text = request[i+1];　
                newOption.value = request[i];　     
                smallControl.options.add(newOption);　       

            }
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }
      }

}
//--------------------------分类收藏----------------------------------------------------------

function InfoShouCang(infoID,userID,currentUrl)
{
    
    if(userID==0)
    {
        alert('您还没有登录或注册，请先登录或注册！');
        window.location.href="/Member/login.aspx?preURL="+currentUrl;
    }
    else
    {

        
        var url="/shop/addFavorit.aspx?id="+infoID+"&cateType=1";    
        xmlHttp.open("GET",url,true);

        xmlHttp.onreadystatechange=InfoIsShouCang;
        xmlHttp.send(null);


    }
}

function InfoIsShouCang()
{
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var returnStr=xmlHttp.responseText;
            if(returnStr!="")
            {
                alert(returnStr);
            }          
            else
            {
                alert("Error!");
            }
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }

    }   

}

//------------------------------------------------------------------------------------

