﻿function CmfuAjax() {
 this.xml = false;

 this.GetXmlHttp = function() {
 /*@cc_on@*/
 /*@if (@_jscript_version >= 5)
 try {
 this.xml = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
 try {
 this.xml = new ActiveXObject("Microsoft.XMLHTTP");
 } catch (e2) {
 this.xml = false;
 }
 }
 @end@*/

 if (!this.xml && typeof XMLHttpRequest != 'undefined') {
 this.xml = new XMLHttpRequest();
 }
 }
 this.GetXmlHttp();
 var xmlHttp = this.xml;
 var ajax = this;

 var callBack = null;

 this.updatePage = function() {

 if (xmlHttp.readyState == 4) {
 var response = eval('(' + xmlHttp.responseText + ')');

 if (callBack != null && typeof callBack == "function") {
 callBack(response);
 }
 }
 }

 this.toQueryString = function(json) {
 var query = "";
 if (json != null) {
 for (var param in json) {
 query += param + "=" + escape(json[param]) + "&"
 }
 }

 return query;
 }

 this.invoke = function(opName, params, pageCallBack, method) {
 if (xmlHttp) {
 var query = "";
 query += this.toQueryString(params);
 query = query.substring(0, query.length - 1);
 callBack = pageCallBack;

 if (method != null && method.toUpperCase() == "GET") {
 var url = "/ajax.aspx?opName=" + opName + "&" + query;

 xmlHttp.onreadystatechange = ajax.updatePage;
 xmlHttp.open("GET", url, true);
 xmlHttp.setRequestHeader("CMFUAJAX-Ver", "ver1.0");
 xmlHttp.send(null);
 } else {

 var url = "";
 if (opName != null && (opName.toLowerCase() == "addreview" || opName.toLowerCase() == "addforumreview" || opName.toLowerCase() == "addclubreview")) {
 url = "/ajax.aspx?opName=" + opName;
 }
 else if (opName.toLowerCase() == "getuserip") {
 url = "/userip.aspx";
 }
 else {
 url = "/ajax.aspx?opName=" + opName;
 }

 xmlHttp.onreadystatechange = ajax.updatePage;
 xmlHttp.open("POST", url, true);
 xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
 xmlHttp.setRequestHeader("CMFUAJAX-Ver", "ver1.0");
 xmlHttp.send(query);
 }
 }
 }
}


var MyAjax = {
 AddReview: function(bookId, content, postType, validCode,reviewtype,chapterId) {
 var validateHdd=document.getElementById("hddValidateCode");
 var validateString="";
 if (validateHdd!=null) validateString = validateHdd.value;
		new CmfuAjax().invoke("AddReview", {"bookId":bookId, "content":content, "postType":postType, "validCode":validCode,"validateString":validateString,"reviewtype":reviewtype,"chapterId":chapterId}, arguments[6]);
	},
	AddReview2: function(bookId, content, postType, validCode,reviewtype,chapterId,threadId) {
 var validateHdd=document.getElementById("hddValidateCode");
 var validateString="";
 if (validateHdd!=null) validateString = validateHdd.value;
		new CmfuAjax().invoke("AddReview2", {"bookId":bookId, "content":content, "postType":postType, "validCode":validCode,"validateString":validateString,"reviewtype":reviewtype,"chapterId":chapterId,"threadId":threadId}, arguments[7]);
	},
 LoginUserWithInfo: function(ptId, password, token, challenge, saveCookie) {
 new CmfuAjax().invoke("LoginUserWithInfo", { "ptId": ptId, "password": password, "token": token, "challenge": challenge, "saveCookie": saveCookie }, arguments[5]);
 },
 CheckLoginWithInfo: function() {
 new CmfuAjax().invoke("CheckLoginWithInfo", {}, arguments[0]);
 },
 SignOut: function() {
 new CmfuAjax().invoke("SignOut", {}, arguments[0]);
 },
 AddBookCase: function(bookId) {
 new CmfuAjax().invoke("AddBookCase", { "bookId": bookId }, arguments[1]);
 },
 RecomBook: function(bookId) {
 new CmfuAjax().invoke("RecomBook", { "bookId": bookId }, arguments[1]);
 },
 SetFavoriteThread: function(forumId, Id) {
 new CmfuAjax().invoke("SetFavoriteThread", { "bookId": forumId, "Id": Id }, arguments[2]);
 },
 UpdateReviewAmount: function(forumId) {//更新讨论区主题数、回复数
 new CmfuAjax().invoke("UpdateReviewAmount", { "bookId": forumId }, arguments[1]);
 },
 UpdateThreadPostAmount: function(threadId) {//更新讨论区主题数、回复数
 new CmfuAjax().invoke("UpdateThreadPostAmount", { "bookId": threadId }, arguments[1]);
 },
 AddReviewSupport: function(reviewId) {//增加评论感动指数 updated by tang 080519
 new CmfuAjax().invoke("AddReviewSupport", { "reviewId": reviewId }, arguments[1]);
 },
 GetUserIP: function() {
 new CmfuAjax().invoke("GetUserIP", {}, arguments[0]);
 },
 AddSNSReviewSupport: function(forumId, reviewId, supportType, voteYes) {
 new CmfuAjax().invoke("AddSNSReviewSupport", { "forumId": forumId, "reviewId": reviewId, "supportType": supportType, "voteYes": voteYes }, arguments[4]);
 },
 VoteThread: function(forumId, reviewid, type, forumName, bodyLength, bookType) {
 new CmfuAjax().invoke("VoteThread", { "forumId": forumId, "reviewId": reviewid, "type": type, "forumName": forumName, "bodyLength": bodyLength, "bookType": bookType }, arguments[6]);
 },
 GetGradeInfo: function(curCommentUserId, FansExperienceValue, bookId) {
 new CmfuAjax().invoke("GetGradeInfo", { "curCommentUserId": curCommentUserId, "FansExperienceValue": FansExperienceValue, "bookId": bookId }, arguments[3]);
 },
 GetFansInfo: function(bookCategoryId, ForumId) {
 new CmfuAjax().invoke("GetFansInfo", { "BookCategoryId": bookCategoryId, "ForumId": ForumId }, arguments[2]);
 },
 CheckAddHotThread: function(voteYes, voteAgainst, forumId, forumName, reviewId, reviewtitle, userId, nickName, bodylength, tp) {
 new CmfuAjax().invoke("CheckAddHotThread", { "voteYes": voteYes, "voteAgainst": voteAgainst, "forumId": forumId, "forumName": forumName, "reviewId": reviewId, "reviewtitle": reviewtitle, "userId": userId, "nickName": nickName, "bodylength": bodylength, "tp": tp }, arguments[10]);
 },
 VotePost: function(forumId, reviewid, type, forumName, bodyLength) {
 new CmfuAjax().invoke("VotePost", { "forumId": forumId, "reviewId": reviewid, "type": type, "forumName": forumName, "bodyLength": bodyLength }, arguments[5]);
 },
 AddSNSReview: function(forumId, content, validCode, refReviewIds, isAnonymous) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddSNSReview", { "forumId": forumId, "content": content, "validCode": validCode, "refReviewIds": refReviewIds, "isAnonymous": isAnonymous, "validateString": validateString }, arguments[5]);
 },
 ReviewComplaint: function(content, validCode) {
 new CmfuAjax().invoke("ReviewComplaint", { "content": content, "validCode": validCode }, arguments[2]);
 },
 ExpandReview: function(forumId, reviewId) {
 new CmfuAjax().invoke("ExpandReview", { "forumId": forumId, "reviewId": reviewId }, arguments[2]);
 },
 GetValidateCode: function() {
 new CmfuAjax().invoke("GetValidateCode", {}, arguments[0]);
 },
 LoginUserWithValidate: function(ptId, password, token, challenge, saveCookie, input, validateString) {
 var newPtId = ptId;
 newPtId = newPtId.replace(/\·/g, "%A1%A4");
 new CmfuAjax().invoke("LoginUserWithValidate", { "ptId": newPtId, "password": password, "token": token, "challenge": challenge, "saveCookie": saveCookie, "input": input, "validateString": validateString }, arguments[7]);
 },
 AddForumReviewLogin: function(bookId, title, content, postType, validCode, ptId, password) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddForumReviewLogin", { "bookId": bookId, "title": title, "content": content, "postType": postType, "validCode": validCode, "ptId": ptId, "password": password, "validateString": validateString }, arguments[7]);
 },
 AddForumReview: function(bookId, title, content, postType, validCode, isAnonymous) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddForumReview", { "bookId": bookId, "title": title, "content": content, "postType": postType, "validCode": validCode, "validateString": validateString, "isAnonymous": isAnonymous }, arguments[6]);
 },
 AddForumReview2: function(bookId,chapterId,title, content, postType, validCode, isAnonymous) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddForumReview2", { "bookId": bookId,"chapterId":chapterId,"title": title, "content": content, "postType": postType, "validCode": validCode, "validateString": validateString, "isAnonymous": isAnonymous }, arguments[7]);
 },
 AddPostLogin: function(forumId, threadId, title, content,
 validCode, ptId, password) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddPostLogin",
 {
 "forumId": forumId,
 "threadId": threadId,
 "title": title,
 "content": content,
 "validCode": validCode,
 "ptId": ptId,
 "password": password,
 "validateString": validateString
 }, arguments[7]);
 },
 AddPostLogin2: function(forumId, threadId, title, content,
 validCode, ptId, password, refPostIds) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddPostLogin",
 {
 "forumId": forumId,
 "threadId": threadId,
 "title": title,
 "content": content,
 "validCode": validCode,
 "ptId": ptId,
 "password": password,
 "validateString": validateString,
 "refPostIds": refPostIds
 }, arguments[8]);
 },
 AddPost: function(forumId, threadId, title, content,
 validCode, isAnonymous) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddPost", {
 "forumId": forumId,
 "threadId": threadId,
 "title": title,
 "content": content,
 "validCode": validCode,
 "validateString": validateString,
 "isAnonymous": isAnonymous
 }, arguments[6]);
 },
 AddPost2: function(forumId, threadId, title, content,
 validCode, isAnonymous, refPostIds) {
 var validateHdd = document.getElementById("hddValidateCode");
 var validateString = "";
 if (validateHdd != null) validateString = validateHdd.value;
 new CmfuAjax().invoke("AddPost", {
 "forumId": forumId,
 "threadId": threadId,
 "title": title,
 "content": content,
 "validCode": validCode,
 "validateString": validateString,
 "isAnonymous": isAnonymous,
 "refPostIds": refPostIds
 }, arguments[7]);
 },
 CheckForumAdmin: function(forumId) {
 new CmfuAjax().invoke("CheckForumAdmin", { "forumId": forumId }, arguments[1]);
 },
 GoReaderChapter: function(bookId,chapterId){
 new CmfuAjax().invoke("GoReaderChapter", { "bookId": bookId,"chapterId":chapterId }, arguments[2]);
 },
 BindRcmReview: function(bookId) {
 new CmfuAjax().invoke("BindRcmReview", { "bookId": bookId }, arguments[1]);
 },
 BindBehindData: function(type, bookId) {
 new CmfuAjax().invoke("BindBehindData", { "type": type, "bookId": bookId }, arguments[2]);
 },
 BindSNSReviewList: function(forumId) {
 new CmfuAjax().invoke("BindSNSReviewList", { "forumId": forumId }, arguments[1]);
 },
 SearchBookId: function(bookName) {
 new CmfuAjax().invoke("SearchBookId", { "bookName": bookName }, arguments[1]);
 },
 AddHotReviewByPost: function(forumId, forumName, threadId, freeType) {
 new CmfuAjax().invoke("AddHotReviewByPost", { "forumId": forumId, "forumName": forumName, "threadId": threadId, "freeType": freeType }, arguments[4]);
 },
 GradedToThreader: function(userId, threaderId, point) {
 new CmfuAjax().invoke("GradedToThreader", { "userId": userId, "threaderId": threaderId, "point": point }, arguments[3]);
 },
 GradedToThread: function(threadId, userId, point) {
 new CmfuAjax().invoke("GradedToThread", { "threadId": threadId, "userId": userId, "point": point }, arguments[3]);
 },
 AjaxDeleteAdmin: function(forumId) {
 new CmfuAjax().invoke("AjaxDeleteAdmin", { "forumId": forumId }, arguments[1]);
 },
 CheckForumRequisition: function(forumId) {
 new CmfuAjax().invoke("CheckForumRequisition", { "forumId": forumId }, arguments[1]);
 },
 AddScoreByAdmin: function(forumId, operationObj, userId, amount, threadName, operationName,operation,threadID) {
 new CmfuAjax().invoke("AddScoreByAdmin", { "forumId": forumId, "operationObj": operationObj, "userId": userId, "amount": amount, "threadName": threadName, "operationName": operationName,"operation":operation ,"threadID":threadID}, arguments[8]);
 },
 ShangHandler: function(bookId, chapterId, threadId,getUserId, getUserNickName,postId,operateType,operatorId,operatorName,threadSubject,isVipBook,shangCiGetUserId) {
 new CmfuAjax().invoke("ShangHandler", { "bookId": bookId, "chapterId": chapterId, "threadId": threadId, "getUserId": getUserId, "getUserNickName": getUserNickName, "postId": postId,"operateType":operateType ,"operatorId":operatorId,"operatorName":operatorName,"threadSubject":threadSubject,"isVipBook":isVipBook,"shangCiGetUserId":shangCiGetUserId}, arguments[12]);
 },
 GetForumModelScore: function(forumId) {
 new CmfuAjax().invoke("GetForumModelScore", { "forumId": forumId }, arguments[1]);
 },
 UpdateAdminInviteInfoStatus:function(inviteId,status,forumId,forumName){
 new CmfuAjax().invoke("UpdateAdminInviteInfoStatus", { "inviteId": inviteId,"status":status,"forumId":forumId,"forumName":forumName}, arguments[4]);
 }

}

