﻿var CommentList = {
	_currentPage:'',
	ChangePage:function(name,topicID,currentPage) {
		this._currentPage='/scripts/UserControlLoader/UserControlLoader.do?SubPage='+name+'&TopicID='+topicID+'&CurrentPage='+currentPage+'&time='+new Date().getDate()+'&'; 
		var divCommentListElement = _$('divCommentListID').value;
		var divPagerElement = _$('divPagerID').value;
		new Ajax.Request (
            this._currentPage,{ parameters:{action:"pagechange"}, onSuccess:function(xh){
                var arry = new Array(); 
                arry = xh.responseText.split("<%split%>");
                _$(divCommentListElement).update(arry[0]);
                _$(divPagerElement).update(arry[1]);
            }
        });
    },
    Quote:function(floor,commentID){
        var divQuoteElement = _$('divQuote'); 
        var commentIDElement = _$('commentID');
        var cancelQuoteElement = _$('cancelQuote');

        if($("#commentRef").css("display")!="none"){
            $("#commentRef").fadeTo(300,.3,function(){$(this).fadeTo(300,1);});
        }
        else $("#commentRef").show(1000);
        divQuoteElement.innerHTML = "引用了" + floor + "楼的留言";
        commentIDElement.value = "[quote]CommentID=" + commentID + "[/quote]";
        $("#btnSubmitComments").focus();
    },
    CancelQuote:function(){
        var divQuoteElement = _$('divQuote'); 
        var commentIDElement = _$('commentID');
        var cancelQuoteElement = _$('cancelQuote');

        divQuoteElement.innerText = "";
        commentIDElement.value = "";
        $("#commentRef").hide(1000);
    },
	     
    SaveCardComment:function(){
        this._currentPage='/scripts/UserControlLoader/UserControlLoader.do?SubPage=CardCommentEdite&CardID='+CardID+'&time='+new Date().getDate()+'&'; 
        var elementID = _$('hdCardComment').value;
        var postData={ action:'save',cardComment:FCKeditorAPI.GetInstance(elementID).GetXHTML(true)} ;
        new Ajax.Request(
        this._currentPage,{parameters:postData, onSuccess:function(xh){
	        _$('EditComment').update(xh.responseText);CardExchange.RequestCardCommentContent(CardID);} } 
        );
    },
    RequestCardCommentContent:function(){
        this._currentPage='/scripts/UserControlLoader/UserControlLoader.do?SubPage=CardExchange&CardID='+CardID+'&time='+new Date().getDate()+'&'; 
        new Ajax.Request(
            this._currentPage,{ parameters:'', onSuccess:function(xh){ _$('CardComment').update(xh.responseText);} } 
        );
    }   
}
