﻿     
 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();
}


 //------------------------------------------------店铺图片显示--------------------------------------------------------------

   
//店铺图片显示＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝显示不同的图片
   function ChangeImg(imgPath,imgID,foodName)
{
	
    if(imgPath=="")
    {
        document.getElementById("bigImg").src="images/img_no_big.gif";
    }
    else
    {
        //document.getElementById("bigImg").src=imgPath;
//		var ImgObj=new Image(); 
//        ImgObj.src=imgPath; 
//		if(ImgObj.width>680)
//		{
//			document.getelementById("bigImg").width=680;
//		}
		document.getElementById("bigImg").src=imgPath;
    }
    document.getElementById("labFoodName").innerText=foodName;
    document.getElementById("hfImgID").value=imgID;  
     
    
    //更新图片的点击率

    
    var replyNum=document.getElementById("hfReplyCount").value;
       
    var hfContentRowsC = document.getElementById("hfContentRowsClass").value; 
    var hfuserhfC = document.getElementById("hfUserhfClass").value;
    var hfUserRowC = document.getElementById("hfUserRowsClass").value;
    
    var cStr=hfContentRowsC+","+hfuserhfC+","+hfUserRowC;

    var url="shopImgClickAdd.aspx?imgID="+imgID+"&replyNum="+replyNum+"&cstr="+cStr;    
    xmlHttp.open("GET",url,true);
    xmlHttp.onreadystatechange=GetClickNum;
    xmlHttp.send(null);
    
}
    
//店铺图片显示＝＝＝＝＝＝＝＝＝＝＝＝＝＝＝显示不同的图片时调用的函数
function GetClickNum()
{
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {


	    var request=xmlHttp.responseText;
            var reStr=request.split(',');
            document.getElementById("labClickNum").innerText=reStr[1];

            document.getElementById("div_ReplyList").innerHTML=reStr[0];

        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }
      }

}


//店铺图片显示===================保存该图片的评论
function saveReply() 
{
    
    var content=document.getElementById("txtContent").value;

    if(content=="")
    {
        return;
    }    
  
    var imgID=document.getElementById("hfImgID").value;
    var replyNum=document.getElementById("hfReplyCount").value;

    var hfContentRowsC = document.getElementById("hfContentRowsClass").value; 
    var hfuserhfC = document.getElementById("hfUserhfClass").value;
    var hfUserRowC = document.getElementById("hfUserRowsClass").value;
    
    var cStr=hfContentRowsC+","+hfuserhfC+","+hfUserRowC;
   var url="shopImgReplyAdd.aspx?imgID="+imgID+"&content="+encodeURI(content)+"&replyNum="+replyNum+"&cstr="+cStr;    
    
    xmlHttp.open("GET",url,true);

    xmlHttp.onreadystatechange=displayReply;


    xmlHttp.send(null);
    
 }
 
 
//店铺图片显示===================显示该图片的评论
 function displayReply()
 {
 
   
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
             var request=xmlHttp.responseText;
            document.getElementById("div_ReplyList").innerHTML=request;
            document.getElementById("txtContent").value="";
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }
     } 
 
 }
 
  //------------------------------------------------end--------------------------------------------------------------

 
 
 
 
 
 //评论回复----------------------------------------------------------------------------------------------------------
 
function display_Reply(divID)
{
    if(document.getElementById("div_CommentReply"+divID).className=="NoDis")
    {

        document.getElementById("div_CommentReply"+divID).className="Dis";
		document.getElementById("txtContent"+divID).value="";
		document.getElementById("txtContent"+divID).focus();
    }
    else
    {
        document.getElementById("div_CommentReply"+divID).className="NoDis";
    }
}


 
function getReply(commentID)
{

    var content=document.getElementById("txtContent"+commentID).value;
    
    if(content=="")
    {
        return;
    }
    
    var url="commentReply.aspx?action=add&replyID=0&commentID="+commentID+"&content="+encodeURI(content);
    
    xmlHttp.open("GET",url,true);

    xmlHttp.onreadystatechange=getContent;
    xmlHttp.send(null);
}

function getContent()
{ 
    
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var request=xmlHttp.responseText.split("|");
            var commentID=request[0];
            var re=request[1];

            var old=document.getElementById("div_replyList"+commentID).innerHTML;
            

            document.getElementById("div_replyList"+commentID).innerHTML=old+re;
 
            document.getElementById("div_replyList"+commentID).className="Dis";
            document.getElementById("div_CommentReply"+commentID).className="NoDis";  
            
            getNum(commentID);
            
            
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }

    }
}

//改变回复数
function getNum(commentID)
{
        var num=document.getElementById("btnReplyNum"+commentID).value;
        document.getElementById("btnReplyNum"+commentID).value=parseInt(num)+1;

}

function dispalyModifyText(replyID)
{
   if(document.getElementById("div_Modify"+replyID).className=="NoDis")
   {
        document.getElementById("div_Modify"+replyID).className="Dis";
   }
   else
   {
        document.getElementById("div_Modify"+replyID).className="NoDis";
   }
}

function modifyReply(ID)
{
    
    var content=document.getElementById("txtModify"+ID).value;
    
    
    if(content=="")
    {
        return;
    }
    
    var url="commentReply.aspx?action=update&replyID="+ID+"&content="+encodeURI(content);
    
    xmlHttp.open("GET",url,true);

    xmlHttp.onreadystatechange=getModifyContent;
    xmlHttp.send(null);  

}


function getModifyContent()
{
   if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var request=xmlHttp.responseText.split("|");
            var replyID=request[0];
            var re=request[1];

           document.getElementById("span_"+replyID).innerHTML=re;
           
           document.getElementById("div_Modify"+replyID).className="NoDis";      
            
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }

    }
}


function display_replyList(div_replyListID)
{
    if(document.getElementById(div_replyListID).className=="NoDis")
    {
        document.getElementById(div_replyListID).className="Dis";
    }
    else
    {
        document.getElementById(div_replyListID).className="NoDis";        
    }

}


function commentError(commentID)
{
    window.open("commentError.aspx?commentID="+commentID,"","width=500,height=400");

}

 //评论回复---------------------------------------------end-------------------------------------------------------------
 
 
 
 
 
 
 
  //------------------------------------------------想去某店的用户--------------------------------------------------------------
 
 //想去某店的用户＝＝＝＝＝＝＝＝＝＝＝＝＝添加用户
 function addUser() 
{
    var userName=document.getElementById("ToGoShop1_hdUserName").value;
    
    if(userName=="")
    {
        window.location.href="/member/login.aspx";
        return;
    }
    
    var shopID=document.getElementById("ToGoShop1_hdShopID").value;
    
    var url="addToGoUser.aspx?shopID="+shopID+"&userName="+encodeURI(userName)+"&isGoTo=0";    
    xmlHttp.open("GET",url,true);

    xmlHttp.onreadystatechange=getToGoContent;
    xmlHttp.send(null);
        
}


 //想去某店的用户＝＝＝＝＝＝＝＝＝＝＝＝＝添加用户后显示用户
function getToGoContent()
{
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var returnStr=xmlHttp.responseText;

            if(returnStr=="true")
            {
                var trStrat=document.getElementById("ToGoShop1_hdTrStart").value;
                var trEnd=document.getElementById("ToGoShop1_hfTrEnd").value;
                var userName=document.getElementById("ToGoShop1_hdUserName").value;
                var userID=document.getElementById("ToGoShop1_hdUserID").value;

                
                var div_content=document.getElementById("ToGoShop1_div_ToGoUser").innerHTML;
                var div_con=div_content.replace("</TBODY></TABLE>","");
                
                document.getElementById("ToGoShop1_div_ToGoUser").innerHTML=div_con+ trStrat+"<a href=\"/member/userInfo/default.aspx?userID="+userID +"\" class=\"nLink\" >"+userName+"</a>" +trEnd+"</TBODY></TABLE>";
                getToGoNum();
            }   
     
            
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }

    }   
}


function getToGoNum()
{
    var num=document.getElementById("ToGoShop1_labToGoUserNum").innerText;
    document.getElementById("ToGoShop1_labToGoUserNum").innerText=parseInt(num)+1;
}


 //------------------------------------------------end--------------------------------------------------------------

 
 
 
 
 
 
 
 
  //------------------------------------------------去过某店的用户--------------------------------------------------------------
 
 //去过某店的用户＝＝＝＝＝＝＝＝＝＝＝＝＝添加用户
 function goToAddUser() 
{
    var userName=document.getElementById("GoToShop1_hdUserName").value;
    
    if(userName=="")
    {
        window.location.href="/member/login.aspx";
        return;
    }
    
    var shopID=document.getElementById("GoToShop1_hdShopID").value;
    
    var url="addToGoUser.aspx?shopID="+shopID+"&userName="+encodeURI(userName)+"&isGoTo=1";    
    xmlHttp.open("GET",url,true);

    xmlHttp.onreadystatechange=getGoToContent;
    xmlHttp.send(null);
        
}


 //去过某店的用户＝＝＝＝＝＝＝＝＝＝＝＝＝添加用户后显示用户
function getGoToContent()
{
    if(xmlHttp.readyState == 4)
    {
        if (xmlHttp.status == 200)
        {
            var returnStr=xmlHttp.responseText;

            if(returnStr=="true")
            {
                var trStrat=document.getElementById("GoToShop1_hdTrStart").value;
                var trEnd=document.getElementById("GoToShop1_hfTrEnd").value;
                var userName=document.getElementById("GoToShop1_hdUserName").value;
                var userID=document.getElementById("GoToShop1_hdUserID").value;

                
                var div_content=document.getElementById("GoToShop1_div_ToGoUser").innerHTML;
                var div_con=div_content.replace("</TBODY></TABLE>","");
                
                document.getElementById("GoToShop1_div_ToGoUser").innerHTML=div_con+ trStrat+"<a href=\"/member/userInfo/default.aspx?userID="+userID +"\" class=\"nLink\" >"+userName+"</a>" +trEnd+"</TBODY></TABLE>";
                
                getGoToNum();
            
            }   
     
            
        }
        else if (xmlHttp.status == 404)
        {
            alert("Request URL does not exist");
        }
        else
        {
            alert("Error: status code is " + xmlHttp.status);
        }

    }   
}

function getGoToNum()
{
    var num=document.getElementById("GoToShop1_labToGoUserNum").innerText;

    document.getElementById("GoToShop1_labToGoUserNum").innerText=parseInt(num)+1;
}



//--------------------------收藏----------------------------------------------------------

//收藏店铺
function ShouCang(shopID,userID,currentUrl)
{
    
    if(userID==0)
    {
        alert('您还没有登录或注册，请先登录或注册！');
        window.location.href="/Member/login.aspx?preURL="+currentUrl;
    }
    else
    {

        
        var url="addFavorit.aspx?id="+shopID+"&cateType=0";       
        xmlHttp.open("GET",url,true);

        xmlHttp.onreadystatechange=IsShouCang;
        xmlHttp.send(null);


    }
}

//收藏店铺产品
function ShouCangPro(proID,userID,currentUrl)
{
    
    if(userID==0)
    {
        alert('您还没有登录或注册，请先登录或注册！');
        window.location.href="/Member/login.aspx?preURL="+currentUrl;
    }
    else
    {

        
        var url="addFavorit.aspx?id="+proID+"&cateType=2";       
        xmlHttp.open("GET",url,true);

        xmlHttp.onreadystatechange=IsShouCang;
        xmlHttp.send(null);


    }
}


function IsShouCang()
{
    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);
        }

    }   

}

//------------------------------------------------------------------------------------

//-----------------------放入购物车----------------------------------------------------------------
function InputCart(url)
{
   var features="width=700,height=500,scrollbars=yes,resizable=yes"
   window.open(url,"购物车",features);

}


//-----------------------放入购物车-----------End-----------------------------------------------------

