commentComponent =
function (commentId, currentPage, _expanded, _loaded, toaster) {
  this.prototype =
  { toaster : null, 
    _loaded : null, 
    _expanded : null, 
    currentPage : null, 
    commentId : 'comments', 
    _saveComment : function (document, name, email, data) {
          return funcall
            ('?s=iwpQNyNR&k=act-JujJWiAM',
             { document : document, 
               name : name, 
               email : email, 
               data : data });
        }, 
    countComments : function (document) {
          return funcall
            ('?s=iwpQNyNR&k=act-KTOcQEOQ', { document : document });
        }, 
    getComments : function (document) {
          return funcall
            ('?s=iwpQNyNR&k=act-vLyYjZFX', { document : document });
        }, 
    loadComment : function (documentName) {
          this.currentPage = documentName;
          this._expanded = null;
          {
            var div = dojo.byId(this.commentId);
            div.innerHTML = '';
            {
              var a = document.createElement('A');
              var h3 = document.createElement('H3');
              var form = this.makeCommentForm2();
              a.innerHTML = '+ Post comment';
              a.onclick =
              dojo.hitch
              (this,
               function (c) {
                 form.style.display = 'block';
                 return false;
               });
              form.style.display = 'none';
              form.onsubmit =
              dojo.hitch
              (this,
               function (c) {
                 return this.saveComment();
               });
              h3.appendChild(a);
              div.appendChild(h3);
              div.appendChild(form);
            };
            var h3 = document.createElement('H3');
            var len = this.countComments(documentName);
            if (len > 0) {
              var a = document.createElement('A');
              a.onclick =
              dojo.hitch
              (this,
               function (c) {
                 this.expandComment();
               });
              a.innerHTML = '+ ' + len + ' Comments';
              h3.appendChild(a);
              div.appendChild(h3);
            } else {
              h3.innerHTML = '- No comments yet.';
              div.appendChild(h3);
            };
          };
          return false;
        }, 
    makeCommentForm2 : function () {
          var form = document.createElement('FORM');
          form.id = this.commentId + '-form';
          form.innerHTML =
          '<fieldset><legend>Comment Form</legend><div class="field-name">Name:</div><div class="field-value"><input id="comment-name" type="text" size="30"></input></div><div class="field-name">Email:</div><div class="field-value"><input id="comment-email" type="text" size="30"></input></div><div class="field-name">Comment:</div><div class="field-value"><textarea id="comment-data" rows="10" cols="50"></textarea></div><div><input type="submit" value="Post Comment"></input></div></fieldset>';
          return form;
        }, 
    expandComment : function () {
          if (this._expanded) {
            return false;
          };
          this.toast('Loading comments...');
          {
            var comments = this.getComments(this.currentPage);
            var commentsDiv = dojo.byId(this.commentId);
            if (comments) {
              dojo.map
              (comments,
               dojo.hitch
               (this,
                function (c) {
                  var div = this.makeComment(c);
                  commentsDiv.appendChild(div);
                }));
            };
          };
          this._expanded = true;
          return false;
        }, 
    saveComment : function () {
          if ('' == document.getElementById('comment-name').value
              || '' == document.getElementById('comment-email').value
              || '' == document.getElementById('comment-data').value) {
            this.toast('Please fill all the fields and re-submit.');
            return false;
          };
          this._saveComment
          (this.currentPage,
           document.getElementById('comment-name').value,
           document.getElementById('comment-email').value,
           document.getElementById('comment-data').value);
          this.toast('Your comment is saved. Thank you.');
          {
            var form = document.getElementById(this.commentId + '-form');
            form.reset();
            form.style.display = 'none';
          };
          this.loadComment(this.currentPage);
          this.expandComment();
          return false;
        }, 
    makeComment : function (comment) {
          console.debug(unescape(comment.data));
          var div = document.createElement('DIV');
          div.innerHTML =
          unescape
          ('<h3>' + comment.username + ' ( ' + comment.email
           + ' ) said on ' + comment.timestamp + '</h3>' + '<p>'
           + unescape(comment.data) + '</p>');
          return div;
        }, 
    setCommentId : function (value) {
          this.commentId = value;
          return this.commentId;
        }, 
    getCommentId : function () {
          return this.commentId;
        }, 
    setCurrentPage : function (value) {
          this.currentPage = value;
          return this.currentPage;
        }, 
    getCurrentPage : function () {
          return this.currentPage;
        }, 
    set_expanded : function (value) {
          this._expanded = value;
          return this._expanded;
        }, 
    get_expanded : function () {
          return this._expanded;
        }, 
    set_loaded : function (value) {
          this._loaded = value;
          return this._loaded;
        }, 
    get_loaded : function () {
          return this._loaded;
        }, 
    setToaster : function (value) {
          this.toaster = value;
          return this.toaster;
        }, 
    getToaster : function () {
          return this.toaster;
        }, 
    toast : function (message) {
          if (null == this.toaster) {
            dojo.require('dojox.widget.Toaster');
            var div = document.createElement('div');
            document.body.appendChild(div);
            this.toaster =
            new dojox.widget.Toaster
              ({ positionDirection : 'br-left', 
                 messageTopic : 'toasterTopic', 
                 duration : 1000 },
               div);
          };
          dojo.publish('toasterTopic', [ message ]);
        } };
  if ('undefined' != typeof commentId) {
    this.prototype.commentId = commentId;
  };
  if ('undefined' != typeof currentPage) {
    this.prototype.currentPage = currentPage;
  };
  if ('undefined' != typeof _expanded) {
    this.prototype._expanded = _expanded;
  };
  if ('undefined' != typeof _loaded) {
    this.prototype._loaded = _loaded;
  };
  if ('undefined' != typeof toaster) {
    this.prototype.toaster = toaster;
  };
  return this.prototype;
};
comment = new commentComponent();
var onPageLoad =
    function (page) {
      comment.loadComment(page);
    };
if ('function' == typeof coretal.onPageLoad) {
  var fun = coretal.onPageLoad;
  coretal.onPageLoad =
  function (page) {
    fun(page);
    onPageLoad(page);
  };
} else {
  coretal.onPageLoad = onPageLoad;
};
