﻿var Name,EditorID,TopicID;

 
var CommentCreator={
	_currentPage:'',
        SaveTopicComment:function()
        {
             this._currentPage='/scripts/UserControlLoader/UserControlLoader.do?SubPage='+Name+'&EditorID='+EditorID+'&TopicID='+TopicID+'&time='+new Date().getDate()+'&';
             if ( CommentCreator.GetLength(EditorID)==true)
             {
                var postData={action:'save',CommentTitle:_$('txtCommentsTitle').value,ValiCode:_$('txtValiCode').value,topicCommentContent:FCKeditorAPI.GetInstance(EditorID).GetXHTML(true),TopicID:_$('HdTopicID').value,commentIDContent:_$('commentID').value};
                new Ajax.Request(
                this._currentPage,{parameters:postData, onSuccess:function(xh)
                      { _$('TopicCommentCreator').update(xh.responseText);CommentCreator.ReloadCommentList(TopicID);CommentCreator.RefurbishVliCode(); }} 
                   );
              }
         },
         
         ReloadCommentList:function(TopicID) 
         {    
		      this._currentPage='/scripts/UserControlLoader/UserControlLoader.do?SubPage=CommentList&TopicID='+TopicID+'&time='+new Date().getDate()+'&'; 
		      var divCommentListElement = _$('divCommentListID').value;
		      var divPagerElement = _$('divPagerID').value;
		      new Ajax.Request (
			  this._currentPage,{ parameters:{action:"save"}, onSuccess:function(xh){ var arry = new Array(); 
		                                                                              arry = xh.responseText.split("<%split%>");
		                                                                              _$(divCommentListElement).update(arry[0]);
		                                                                              _$(divPagerElement).update(arry[1]);
		                                                                             }
		                        } 
			     );
	     },
  
        
        RefurbishVliCode:function()
        {
           _$("imgpwd").src='/DesktopModules/Ezcom.RMQ/RMQ.View/ImageValiCode.aspx?t='+Math.random();
        },
         
        GetLength:function(EditorID)
        { 
           var oEditor = FCKeditorAPI.GetInstance(EditorID); 
           var oDOM = oEditor.EditorDocument; 
           var iLength ; 
           if(document.all)
           { 
               iLength = oDOM.body.innerText.length; 
           }
           else
           { 
             var r = oDOM.createRange(); 
             r.selectNodeContents(oDOM.body); 
             iLength = r.toString().length; 
           } 
           if(iLength<=0)
           {
           alert('内容不能为空！');
           Loader.HideLoader();
           return false;
           }
           else
           {
              return true;
           
           }
        } 
                    
}

var Loader = new AjaxLoader();
function ShowAjaxLoader()
    {   
        Loader.imageUrl="/DesktopModules/Ezcom.WebControls/Ezcom.WebControls/images/load.gif";
        Loader.locationName=PictureSite;
        Loader.elementName=DivID;
        Loader.ShowLoader();
        
    }
    
    
function ShowAjax(name,topicID,editorID,pictureSite,divId)
    {
       PictureSite = pictureSite;
       DivID = divId;
       Name=name;
       EditorID=editorID;
       TopicID=topicID;
       ShowAjaxLoader();
       setTimeout("CommentCreator.SaveTopicComment()",500);  
    }
