﻿// JScript 文件
    rnd.today=new Date(); 
    rnd.seed=rnd.today.getTime(); 
    function rnd() { 
　　　　rnd.seed = (rnd.seed*9301+49297) % 233280; 
　　　　return rnd.seed/(233280.0); 
    }
    function rand(number) { 
　　　　return Math.ceil(rnd()*number); 
    }

function EditorArticle(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();
}
   if(classid==1){
   url="EditorArticle.aspx?username="+username+"&id="+articleid+"&seed="+rand(9999999);
   }
   else if(classid==2){
   url="EditorBookReView.aspx?username="+username+"&id="+articleid+"&seed="+rand(9999999);
   }
   else if(classid==3){
   url="EditorAmazon.aspx?username="+username+"&id="+articleid+"&seed="+rand(9999999);
   }
   else if(classid==4){
   url="EditorGoodMap.aspx?username="+username+"&id="+articleid+"&seed="+rand(9999999);
   }
   else if(classid==7){
   url="EditorBbspick.aspx?username="+username+"&id="+articleid+"&seed="+rand(9999999);
   }
   xmlHttp.open("GET",url,true);
   xmlHttp.onreadystatechange=callBack_GetEditorResult;
   xmlHttp.send(null);
}
function callBack_GetEditorResult(){
   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("操作失败！\n您还不是编辑");
   }
   else if(isValid=="2"){
   alert("操作失败！\n您没有足够权限编辑此篇文章");
   }
   else if(isValid=="3"){
   alert("操作失败！\n您已经编辑过此篇文章");
   }
   else if(isValid=="4"){
   alert("操作失败！\n您要编辑的文章不存在");
   }
   else if(isValid=="5" || isValid=="6"){
   alert("操作失败！\n非法用户名");
   }
   else{
   alert("操作失败！");
   }
}
}
