/**
 * @author gsandrigo
 */
// Requires ajaxbas.js
var mcsHandle = null;
 
DynamicStatsServices.prototype = new Ajax();
 
 function DynamicStatsServices() {
	this.method = "POST";
	this.headerName = "Content-Type";
	this.headerValue = "application/x-www-form-urlencoded; charset=UTF-8";
	this.url="";
	this.content="";
	this.registry = new Array();
	mcsHandle = this;
 }
 
 DynamicStatsServices.prototype.handlePostGetDynamicStats = function() {
	if(mcsHandle.xmlHttp.readyState == 4) {
		//if (mcs.xmlHttp.status != 200)
		//	alert(mcs.xmlHttp.status );
		mcsHandle.registry[0](mcsHandle.xmlHttp.responseXML, mcsHandle.xmlHttp.status == 200);
		mcsHandle.registry[0] = null;
	}
};

DynamicStatsServices.prototype.handlePostContentComment = function() {
	if(mcsHandle.xmlHttp.readyState == 4) {
		mcsHandle.registry[1](mcsHandle.xmlHttp.responseXML, mcsHandle.xmlHttp.status == 200);
		mcsHandle.registry[1] = null;
	}
};

DynamicStatsServices.prototype.postGetDynamicStats = function(contentId, callback) {
	this.registry[0] = callback;
	this.url = "/WebAPI/InvokeCMS/CMSWebDynamicStatsAPI/GetDynamicStats";
	this.content = "rType=JSON";
	this.content += "&siteKey=break";
	this.content += "&contentId=" + contentId;
	this.send(this.method, this.url, this.headerName, this.headerValue, null, null, this.content, this.handlePostGetDynamicStats);
};

DynamicStatsServices.prototype.postContentComment = function(siteId, encryptedMemberId, encryptedContentId, commentId, title, comment, callback) {
	this.registry[1] = callback;
	this.url = "/WebAPI/InvokeCMS/CMSWebCommentsAPI/PostContentComment";
	this.content = "siteId=1&encryptedMemberId=" + encryptedMemberId + "&encryptedContentId=" + encryptedContentId + "&commentId=" + escape(commentId) + "&title=" + encodeURIComponent(title) + "&comment=" + encodeURIComponent(comment);
	this.send(this.method, this.url, this.headerName, this.headerValue, null, null, this.content, this.handlePostContentComment);
};