﻿// JScript 文件
var oldMsg="";

//修改问题
function UpdateRemark(obj,sQuestionid,type)
{
  
    var divObj=obj.parentElement;
    var ht=divObj.innerText;

   
     if(type==1)
     {
      ht=ht.substr(0,ht.length-11);
      oldMsg=ht;
     }
     else
     {
      ht=ht.substr(0,ht.length-4);
       oldMsg=ht;
     }

    divObj.innerHTML="<textarea id='info' style='margin-left:3px;width: 800px; height: 80px; border:1px #ccc solid;'>"+ht+"</textarea><br />"
         +"<input type='button' value='更新' style='width:50px;border 1px #333333 solid;margin-left:3px;' onclick=\"javascript:submitRemark(this,'" + sQuestionid + "',0);\">"+
        "&nbsp;&nbsp;"+
       "<input type='button' value='取消' style='width:50px;border 1px #333333 solid;margin-left:3px;' onclick=\"javascript:cancelRemark(this,'" + sQuestionid + "',"+type+");\">";
}
//提交修改问题
function submitRemark(me,sQuestionid,type)
{  
    var obj=document.getElementById("info");
    var divViewA=me.parentElement;
    
    //将obj.value以ajax方式发送到服务器
    if(obj.value.length>600||obj.value.length<5)
    {
    alert("回答长度不能小于5且不能超过600个汉字！");
    return;
    }   

     dopage("ajaxExpertsAnswer.aspx?id="+sQuestionid,obj.value);
     divViewA.innerHTML=obj.value+"&nbsp;&nbsp;[<a href='#' onclick=\"javascript:UpdateRemark(this,"+sQuestionid+","+type+")\"><span style='color:#ff0000'>修改</span></a>]";;
   //divViewA.innerHTML=obj.value+"&nbsp;&nbsp;[<a href=# onclick=\"UpdateRemark(this,,'" + sQuestionid + "')\"><span style='color:#ff0000'>修改</span></a>]";
    
}
//取消修改备注
function cancelRemark(me,sQuestionid,type)
{   
    var divViewA=me.parentElement;
 
    if(type==1)
    {
        divViewA.innerHTML=oldMsg+"&nbsp;&nbsp;[<a href=# onclick=\"UpdateRemark(this,"+sQuestionid+","+type+")\"><span style='color:#ff0000'>专家请点击这里回答</span></a>]";
  
    }
    else
    {
    divViewA.innerHTML=oldMsg+"&nbsp;&nbsp;[<a href=# onclick=\"UpdateRemark(this,"+sQuestionid+","+type+")\"><span style='color:#ff0000'>修改</span></a>]";
    }
}