﻿// JScript 文件
function AddToMyCollection(username,articleid,classid)
{
try {
    xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
    try{
       xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch(e2){
       xmlHttp=false;
    }
}
//判断XMLHTTP是否创建成功
if(!xmlHttp && typeof XMLHTTPRequest !='undefined'){
       xmlHttp=new XMLHTTPRequest();
}
   var url="../AddToMyCollection.aspx?username="+username+"&id="+articleid+"&classid="+classid+"&seed="+rand(999999);
   xmlHttp.open("GET",url,true);
   xmlHttp.onreadystatechange=callBack_GetAddResult;
   xmlHttp.send(null);
}
function callBack_GetAddResult(){
   if (xmlHttp.readyState == 4){
   var isValid=xmlHttp.responseText;
   var str=isValid.toLowerCase();
   p1=str.indexOf("<body>");
   p2=str.indexOf("</body>");
   str2=str.substring(p1+6,p2);
   p3=str2.indexOf("<span id='result'>");
   p4=str2.indexOf("</span>");
   isValid=str2.substring(p3+25,p4);
   if(isValid=="0")
   {
   alert("操作成功！");
   }
   else if(isValid=="1"){
   alert("对不起，您还没有登录！");
   }
   else if(isValid=="2"){
   alert("对不起，您还没有注册");
   }
   else if(isValid=="3"){
   alert("对不起，您要收藏的文章不存在");
   }
   else if(isValid=="4"){
   alert("对不起，您已收藏过该篇文章");
   }
   else
   {
   alert("参数错误！");
   }
}
}
