﻿var enableCoverPingbaSite = '<%= Snda.CMFU.Common.CmfuConfig.Instance.AppSetting.EnableCoverPingbaSite %>';
if (enableCoverPingbaSite.toLowerCase() == "true") {
 document.domain = ".qidian.com"; //跨域引用
}

//打赏
function DoReward(bookId, authorId, authorName) {
 if (bookId != null && authorId != null && authorName != null && bookId != "undefined" && authorId != "undefined") {
 var _ora=8;
 if(location.href.toLowerCase().indexOf('dmreader.aspx')>0) _ora=9;
 Snda.Layer.Show({
 title: '我要打赏',
 src: '../BookReader/DivAuthorTippingNew.aspx?ora='+_ora+'&bookId=' + bookId + "&authorId=" + authorId + 
 "&authorName=" + authorName,
 follow: true,
 move: true,
 callBack: function() { }
 });
 }
}
function Comments(flag, bookid) {
 if (!checkLoginByCookie()) {
 alert('您尚未登录,请登录后操作');
 var logtxt = document.getElementById("txtUserName");
 if (logtxt != null && logtxt != undefined) logtxt.focus();
 return false;
 }
 else {
 if (flag != null && flag != "undefined" && bookid != null && bookid != "undefined") {
 switch (flag) {
 case 1:
 Snda.Layer.Show({
 title: "我要送花",
 src: 'ReviewTicket.aspx?bid=' + bookid + "&flag=1",
 follow: true,
 move: true,
 callBack: function() { }
 });
 break;
 case 3:
 Snda.Layer.Show({
 title: "我要灌水",
 src: 'ReviewTicket.aspx?bid=' + bookid + "&flag=3",
 follow: true,
 move: true,
 callBack: function() { }
 });
 break;
 case 5:
 Snda.Layer.Show({
 title: "我要砸砖",
 src: 'ReviewTicket.aspx?bid=' + bookid + "&flag=5",
 follow: true,
 move: true,
 callBack: function() { }
 });
 break;
 default:
 break;
 }
 }
 }
}
//加入书架
function AddBookCase(bookId) {
 if (!checkLoginByCookie()) {
 ShowLoginDiv();
 return false;
 }
 MyAjax.AddBookCase(bookId, ShowServerMessage);
}
//推荐本书
function CommendBook(bookId) {
 if (!checkLoginByCookie()) {
 ShowLoginDiv();
 return false;
 }
 MyAjax.RecomBook(bookId, ShowServerMessage);
}
//添加手机提醒
function AddUpdateAwake(bookId) {
 if (confirm('亲爱的起点用户，感谢您使用更新提醒服务！\r当小说有新章节更新时，我们将通过短信提醒您！\r\r每提醒一条短信将从您的起点帐号中扣除10起点币。\r您确认使用更新提醒服务吗？')) {
 if (!checkLoginByCookie()) {
 ShowLoginDiv();
 return false;
 }
 MyAjax.AddUpdateAwake(bookId, ShowServerMessage);
 return false;
 }
}

function showAjaxMessage(res) {
 if (res && res.value) {
 alert(res.value);
 }
}

//显示服务器返回的信息
function ShowServerMessage(result) {
 if (result.value.indexOf('登录') > -1) {
 ShowLoginDiv();
 }
 else {
 var value = result.value.replace("\n", "");
 eval(value);
 }
}

function iframeFitHeight(iframeId) {
 var frm = $(iframeId);

 if (frm == null)
 return;

 try {
 var oWin = frm.name ? window.frames[frm.name] : frm.contentWindow;
 $("divBookReview").style.height = oWin.document.body.scrollHeight + "px";
 frm.style.height = oWin.document.body.scrollHeight + "px";
 }
 catch (e) { }
}
