﻿var videoId = null;
var commentId = null;
var commentAction = null;
var commentPageIdx = 0;
var commentText = null;
var commentFilter = null;
var commentSort = null;
var commentType = null;
var filterCommentType = null;
var vipVideoId = 0;

function OnGeneralCommentsBeginCallback(s, e) {
 
  e.customArgs["pageIdx"] = this.commentPageIdx; // for posting comments
  e.customArgs["action"] = this.commentAction;
  e.customArgs["commentId"] = this.commentId;
  e.customArgs["filter"] = this.commentFilter;
  e.customArgs["sort"] = this.commentSort;
  e.customArgs["videoId"] = this.videoId;
  e.customArgs["commentType"] = this.commentType;
  e.customArgs["filterCommentType"] = this.filterCommentType;
  if (this.commentAction == "post") {
    e.customArgs["commentText"] = $('#commentField').val();
  } else {
    e.customArgs["commentText"] = this.commentText;
  }
  this.commentAction = null;
  this.commentId = null;
  this.commentFilter = null;
  this.commentSort = null;
  this.commentType = null;
  this.filterCommentType = null;
}
function OnGeneralCommentsEndCallback(s, e) {

}

// ***************************************************************
// Load comments --  
// ***************************************************************
function OnLoadComments(videoId, vipVideoId) {
  this.videoId = videoId;
  this.vipVideoId = vipVideoId;
  this.commentType = null;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Post comments --  
// ***************************************************************

function OnPostComments(id, filterCommentType, filter, sort) {
  //alert(id);
  this.videoId = id;
  this.commentAction = "post";
  this.commentType = $('#comment_type').val();
  this.filterCommentType = filterCommentType;
  this.commentFilter = filter;
  this.commentSort = sort;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}
function OnPostCommentsBeginCallback(s, e) {
  e.customArgs["tabIndex"] = this.tabIndex;
  e.customArgs["tab"] = this.tab;
  e.customArgs["videoId"] = this.videoId;
  if (this.commentAction == "post") {
    e.customArgs["commentText"] = $('#commentField').val();
  } else {
    e.customArgs["commentText"] = this.commentText;
  }
  e.customArgs["pageIdx"] = this.commentPageIdx; // for posting comments
  e.customArgs["action"] = this.commentAction;
  e.customArgs["commentId"] = this.commentId;
  e.customArgs["filter"] = this.commentFilter;
  e.customArgs["sort"] = this.commentSort;
  e.customArgs["commentType"] = this.commentType;
  e.customArgs["filterCommentType"] = this.filterCommentType;
  e.customArgs["vipVideoId"] = this.vipVideoId;
  this.tabIndex = null;
  this.tab = null;
  this.videoId = null;
  this.commentAction = null;
  this.commentId = null;
  this.commentFilter = null;
  this.commentSort = null;
  this.commentType = null;
  this.filterCommentType = null;
}
function OnPostCommentsEndCallback(s, e) {
  $('#commentField').val(''); //reset the comment field when done
  if ($('#commentField').length) { $('#commentField').autoGrow(); }
  //show registration
  //alert(CommentsCallback.cpShowRegistrationPanel);
  if (CommentsCallback.cpShowRegistrationPanel && CommentsCallback.cpShowRegistrationPanel == true) {
    commentsView.showRegistration();
  }

 
}


// ***************************************************************
// Like comments -- 
// ***************************************************************
function OnLikeComment(commentId, videoid, cType, filter, sort) {

  this.commentAction = "like";
  this.videoId = videoid;
  this.commentId = commentId;
  this.commentType = cType;
  this.commentFilter = filter;
  this.commentSort = sort;
  this.filterCommentType = cType;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}


// ***************************************************************
// Hide comments -- 
// ***************************************************************
function OnHideComment(commentId, videoId, cType, filter, sort) {

  this.commentAction = "hide";
  this.commentId = commentId;
  this.videoId = videoId;
  this.commentType = cType;
  this.commentFilter = filter;
  this.commentSort = sort;
  this.filterCommentType = cType;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Show comments -- 
// ***************************************************************
function OnShowComment(commentId, videoId, cType, filter, sort) {

  this.commentAction = "show";
  this.commentId = commentId;
  this.videoId = videoId;
  this.commentType = cType;
  this.commentFilter = filter;
  this.commentSort = sort;
  this.filterCommentType = cType;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Reply comments -- 
// ***************************************************************
function OnReplyComment(commentId, text, videoid, cmtype, filter, sort) {
   
  this.commentAction = "reply";
  this.commentId = commentId;
  this.commentText = text;
  this.commentType = cmtype;
  this.videoId = videoid;
  this.commentFilter = filter;
  this.commentSort = sort;
  this.filterCommentType = cmtype;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Edit comments -- 
// ***************************************************************
function OnEditComment(commentId, text, videoid, commentType, filterCommentType, filter, sort) {

  this.commentAction = "edit";
  this.commentId = commentId;
  this.commentText = text;
  this.videoId = videoid;
  this.commentType = commentType;
  this.commentFilter = filter;
  this.commentSort = sort;
  this.filterCommentType = filterCommentType;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

//OnHilightComment
// ***************************************************************
// Hide comments -- 
// ***************************************************************
function OnHilightComment(commentId, videoId, cType, filter, sort) {

  this.commentAction = "highlight";
  this.commentId = commentId;
  this.videoId = videoId;
  this.commentType = cType;
  this.filterCommentType = cType;
  this.commentFilter = filter;
  this.commentSort = sort;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Paging comments -- 
// ***************************************************************
function OnPagingComment(pageIdx, vidId, cType, filter, sort) {

  this.commentAction = null;
  this.commentPageIdx = pageIdx;
  this.videoId = vidId;
  this.commentType = cType;
  this.filterCommentType = cType;
  this.commentFilter = filter;
  this.commentSort = sort;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}

// ***************************************************************
// Filter comments -- 
// ***************************************************************
function OnFilterComment(filter, type, sort, videoid) {
  
  this.commentAction = 'filter';
  this.commentPageIdx = 0;
  this.videoId = videoid;
  this.commentFilter = filter;
  this.commentType = type;
  this.filterCommentType = type;
  this.commentSort = sort;
  if (!CommentsCallback.InCallback())
    CommentsCallback.PerformCallback();
}
 

