
$(function(){$(".cldz").click(function(){$("#readview").slideToggle();});$('#fbpl').draggable({handle:'h3'});$('#a_fbpl').click(openPinglun);$('#open_pl').click(openPinglun);$('#small_pl').click(function(){$('#fbpl').toggle('slow');});$('#send_thread').click(function(){formThread();});function formThread(){if(!user){if(confirm("发表书评需要用户登录，确定登录吗？")){login();}else{return false;}}
var content=$.trim($('#content').val());var title=$.trim($('#title').val());if(content==""){alert("请输入内容");return false;}
if(title==""){alert("请输入标题");return false;}
var url='/ajax/book.commend.addThread.do';var bookId=$('body').attr("bookId");var params={bookId:bookId,title:title,content:content};$.ajax({type:"POST",url:url,data:params,success:function(data){if(data){if(data.mes){alert(data.mes);}
if(data.ret){alert("发表书评成功");$('#thread_total').html(parseInt($('#thread_total').html())+1);$('#content').val("");$('#title').val("");var threadId=data.threadId;var time=data.time;var nickname=data.nickname;var out="<li>";out+="<a target=\"_blank\"  href=\"http://book.zongheng.com/postList/"+bookId+"/"+threadId+".html\">"+title+"</a>";out+="<p>发表人:<a href=\"http://home.zongheng.com/show/userInfo/"+user.userId+".html\">"+nickname+"</a>回复数:0 发表时间："+time+"</p>";out+="</li>";$('#thread').prepend($(out));}}},dataType:'json',async:false});return false;}
$('#rbticket').draggable();$('#open_tj').click(openTuijian);$('#close_tj').click(function(){$('#rbticket').toggle('slow');$('#a_tpfj').remove();});$('#small_tj').click(function(){$('#rbticket').toggle('slow');});$('.voteRecommend').click(function(){if(user){var url='/ajax/book.recommend.do';var bookId=$('body').attr("bookId");var tp=$(this).attr("tp");var params={bookId:bookId,tp:tp};$.ajax({type:"POST",url:url,data:params,success:function(data){if(data){if(data.mes){alert(data.mes);}
if(data.ret){if(tp==0){$('#red').html(parseInt($('#red').html())+1);}else if(tp==1){$('#black').html(parseInt($('#black').html())+1);}}}},dataType:'json',async:false});}else{if(confirm('只有登录用户才能投票,确定要登录吗?')){login();}}});var ratio=$('#pingjia').attr("ratio");$('#pingjia').css("width",ratio+"%");$('#tuck').draggable();$('#open_sj').click(function(){var size=$('#a_sj').size();if(size==0){var console_pl=$('<a id="a_sj"></a>');console_pl.click(function(){$('#tuck').toggle('slow');});console_pl.append("<span>加入书架</span>");$('#console_list').append(console_pl);}
$('#tuck').toggle('slow');});$('#close_sj').click(function(){$('#tuck').toggle('slow');$('#a_sj').remove();});$('.small_sj').click(function(){$('#tuck').toggle('slow');});$('#add_shelf').click(function(){if(user){var url='/ajax/bookshelf.do';var bookId=$('body').attr("bookId");$.ajax({type:"POST",url:url,data:{bookId:bookId},success:function(data){if(data){if(data.mes){alert(data.mes);}}},dataType:'json',async:false});}else{if(confirm('只有登录用户才能使用书架,确定要登录吗?')){login();}}});if(user){setTimeout(function(){$.getJSON("/ajax/loadShelf.do",{bookId:$('body').attr("bookId")},function(data){if(data.ret){$('#shelf_list').append($(data.list));}});},1000);}
$('#authortp').draggable();$('#open_dc').click(function(){var size=$('#a_zzdc').size();if(size==0){var console_pl=$('<a id="a_zzdc"></a>');console_pl.click(function(){$('#authortp').toggle('slow');});console_pl.append("<span>作者调查</span>");$('#console_list').append(console_pl);}
$('#authortp').toggle('slow');});$('#close_dc').click(function(){$('#authortp').toggle('slow');$('#a_zzdc').remove();});$('#small_dc').click(function(){$('#authortp').toggle('slow');});$('#submit_vote').click(function(){if(!user){if(confirm("注册用户才可以投票，确定登录吗？")){login();}else{return;}}
var bookId=$('body').attr("bookId");var topicId=$(this).attr("topicId");var voteEver=$.cookie('v'+bookId+"_"+topicId);if(voteEver){alert("已经投过了，感谢支持");return;}
var single=$(this).attr("sg");var val;if(single==="true"){val=$('input:radio[name=option_check]:checked').val();}else{val=new Array();$('input:checkbox[name=option_check]:checked').each(function(index,obj){val[index]=$(obj).val();});}
var params={bookId:bookId,topicId:topicId,single:single,val:val};var url='/ajax/book.addvote.do';$.ajax({type:"POST",url:url,data:params,success:function(data){if(data){if(data.mes){alert(data.mes);}
if(data.ret){alert("投票成功,感谢您的支持");$.cookie('v'+bookId+"_"+topicId,true,{path:"/",domain:".zongheng.com",expires:1});}}},dataType:'json',async:false});return false;});$('#goLogin').click(function(){loginSubmit();});if(user){$.PopPanel({from:"#userInfoBtn",to:"#userinfo"});}else{$.PopPanel({from:"#userLogin",to:"#login-block",close:"#userLoginCloseBtn"});}
$('.reg').click(function(){location.href="http://passport.zongheng.com?location="+encodeURIComponent(location.href);});function loginSubmit(){var username=$('input[name=username]').val();if(username==''){alert("请输入登录用户名");return false;}
var passwd=$('input[name=passwd]').val();if(passwd==''){alert("请输入密码");return false;}
var rand=$('input[name=rand]').val();if(rand==''){alert("请输入验证码");return false;}
var macval=hex_hmac_md5(rand.toLowerCase(),str_md5(username+passwd));$('input[name=macval]').val(macval);$('input[name=location]').val(location.href);document.wmlogin.submit();return false;}
$('.changeimg').click(function(){$('#randimg').attr("src","http://passport.wanmei.com/servlet/GetRandomImg?r="+Math.random()).show();$(document).unbind('keydown');$(document).unbind('keyup');$(document).keydown(function(event){if(event.keyCode==$.ui.keyCode.ENTER){loginSubmit();}});});$('.logout').click(function(){logout();});$('.readAll').click(function(){var bookId=$('body').attr("bookId");if(user){location.href='http://book.zongheng.com/totaltome/'+bookId+'.html';}else{if(confirm('只有登录用户才能使用全文阅读,确定要登录吗?')){login('http://book.zongheng.com/totaltome/'+bookId+'.html');}}});$('.readPart').click(function(){var bookId=$('body').attr("bookId");var tomeId=$(this).attr("tomeId");if(user){location.href='http://book.zongheng.com/parttome/'+bookId+"/"+tomeId+'.html';}else{if(confirm('只有登录用户才能使用全文阅读,确定要登录吗?')){login('http://book.zongheng.com/totaltome/'+bookId+'.html');}}});$('.download').click(function(){var bookId=$('body').attr("bookId");if(user){var logURL=$(this).attr('log');if(logURL){logger(logURL);}
location.target='_blank';location.href='http://dl.zongheng.com/book/'+bookId+'.txt';}else{if(confirm('只有登录用户才能使用全文下载,确定要登录吗?')){login();}}});if(user){$.post("/ajax/user.info.do",{},function(data){if(data.ret){var obj=$('#userinfo');var userImage=$('<a href="http://home.zongheng.com" title="头像" class="userimg"></a>');userImage.append($('<img width="100" height="100"></img>').attr("src",data.image));obj.append(userImage);var div=$('<div class="right"></div>');div.append($('<h2><a href="http://home.zongheng.com" class="f33">'+user.nickName+'</a></h2>'));div.append($('<div class="spline"></div>'));div.append($('<p>头衔：<span>'+data.level_title+'</span></p>'));div.append($('<p>等级：<span>'+data.level+'</span></p>'));div.append($('<p>选票：<span>'+data.recomment+'</span></p>'));div.append($('<p>纵横币：<span class="qian">'+data.money+'<em>&nbsp;</em></span><a href="http://home.zongheng.com/show/charge.html" class="forg">[充值]</a></p>'));obj.append(div);$('#userMsg').html(data.message);$('#open_msg').html("·短消息("+data.message+")");}},"json");}
$('.jrsq').click(function(){var params={bookId:$('body').attr("bookId"),chapterId:$('body').attr("chapterId"),tomeId:$('body').attr("tomeId")};if(user){$.getJSON("/ajax/book.bookmark.do",params,function(data){if(data.mes){alert(data.mes);}});}else{if(confirm('只有登录用户才能使用书签功能,确定要登录吗?')){login();}}});$('.listenRead').mouseover(function(){var tomeId=$(this).attr('tomeId');var chapterId=$(this).attr('chapterId');$('body').attr('tomeId',tomeId);$('body').attr('chapterId',chapterId);});$('#open_msg').click(function(){if(user){document.location="http://home.zongheng.com/msgIn.do";}else{if(confirm('只有登录用户才能使用短消息功能,确定要登录吗?')){login("http://home.zongheng.com/msgIn.do");}}});$('#default_view').click(function(){defaultView();$.cookie("rv",'defaultView',{path:"/",domain:".book.zongheng.com",expires:365});});$('#pink_view').click(function(){pinkView();$.cookie("rv",'pinkView',{path:"/",domain:".book.zongheng.com",expires:365});});$('#green_view').click(function(){greenView();$.cookie("rv",'greenView',{path:"/",domain:".book.zongheng.com",expires:365});});$('#vista_view').click(function(){vistaView();$.cookie("rv",'vistaView',{path:"/",domain:".book.zongheng.com",expires:365});});$('#user_view').click(function(){userView();$.cookie("rv",'userView',{path:"/",domain:".book.zongheng.com",expires:365});});$('#style_bg_color').change(function(){var bgColor=$("#style_bg_color option:selected").val();$('body').css('background',bgColor);});$('#style_font').change(function(){var stFont=$("#style_font option:selected").val();$('#readtext p').css('font-family',stFont);});$('#style_ft_color').change(function(){var ftColor=$("#style_ft_color option:selected").val();$('#readtext p').css('color',ftColor);});$('#style_font_size').change(function(){var ftSize=$("#style_font_size option:selected").val();$('#readtext p').css('font-size',ftSize);});$('#style_margin').change(function(){var stMargin=$("#style_margin option:selected").val();$('#readcon').css('margin',stMargin);});$('#style_line_height').change(function(){var stLineHeight=$("#style_line_height option:selected").val();$('#readtext p').css('line-height',stLineHeight);});$('#save_user_view').click(function(){var bgColor=$("#style_bg_color option:selected").val();var stFont=$("#style_font option:selected").val();var ftColor=$("#style_ft_color option:selected").val();var ftSize=$("#style_font_size option:selected").val();var stMargin=$("#style_margin option:selected").val();var stLineHeight=$("#style_line_height option:selected").val();$.cookie("uv",'userView',{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("rv",'userView',{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_bg_color",bgColor,{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_font",stFont,{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_ft_color",ftColor,{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_font_size",ftSize,{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_margin",stMargin,{path:"/",domain:".book.zongheng.com",expires:365});$.cookie("style_line_height",stLineHeight,{path:"/",domain:".book.zongheng.com",expires:365});alert("保存自定义策略成功");});readView();if($.browser.mozilla){$(document).keydown(function(event){if(event.keyCode==32||event.keyCode==34){event.preventDefault();var wHeight=$(window).height();var scrollTop=$(document).scrollTop();var mc=$.cookie("mc");if(mc==="true"){$(document).scrollTop(wHeight+scrollTop-30);}else{$(document).scrollTop(wHeight+scrollTop-90);}}
if(event.keyCode==33){event.preventDefault();var wHeight=$(window).height();var scrollTop=$(document).scrollTop();$(document).scrollTop(scrollTop-wHeight+60);}});}});function openTuijian(){var size=$('#a_tpfj').size();if(size==0){var console_pl=$('<a id="a_tpfj"></a>');console_pl.click(function(){$('#rbticket').toggle('slow');});console_pl.append("<span>投票推荐</span>");$('#console_list').append(console_pl);}
$('#rbticket').toggle('slow');}
function openPinglun(){$('#fbpl').toggle('slow');}
function defaultView(){$('body').css('background','#f0fafe');var cssObj={'color':'#454545','line-height':'1.6em','font-family':'宋体','font-size':'14px'};$('#readtext p').css(cssObj);$('#readcon').css('margin','0 10%');$('#headSlected').html('默认策略');}
function pinkView(){$('body').css('background','#ffeff5');var cssObj={'color':'#a30355','line-height':'1.6em','font-family':'宋体','font-size':'14px'};$('#readtext p').css(cssObj);$('#readcon').css('margin','0 10%');$('#headSlected').html('粉色言情');}
function greenView(){$('body').css('background','#eefaee');var cssObj={'color':'#00471e','line-height':'1.6em','font-family':'宋体','font-size':'14px'};$('#readtext p').css(cssObj);$('#readcon').css('margin','0 10%');$('#headSlected').html('绿色健康');}
function vistaView(){$('body').css('background','#f0fafe');var cssObj={'color':'#454545','line-height':'1.6em','font-family':'微软雅黑','font-size':'14px'};$('#readtext p').css(cssObj);$('#readcon').css('margin','0 20%');$('#headSlected').html('Vista宽屏');}
function userView(){var view=$.cookie('uv');if(view!=null&&view=='userView'){var bgColor=$.cookie('style_bg_color');if(bgColor!=null){$('body').css('background',bgColor);}
var stFont=$.cookie('style_font');if(stFont!=null){$('#readtext p').css('font-family',stFont);}
var ftColor=$.cookie('style_ft_color');if(ftColor!=null){$('#readtext p').css('color',ftColor);}
var ftSize=$.cookie('style_font_size');if(ftSize!=null){$('#readtext p').css('font-size',ftSize);}
var stMargin=$.cookie('style_margin');if(stMargin!=null){$('#readcon').css('margin',stMargin);}
var stLineHeight=$.cookie('style_line_height');if(stLineHeight!=null){$('#readtext p').css('line-height',stLineHeight);}
$('#headSlected').html('自定义策略');}}
function readView(){var readView=$.cookie('rv');if(readView!=null){switch(readView){case'defaultView':{defaultView();break;}
case'pinkView':{pinkView();break;}
case'greenView':{greenView();break;}
case'vistaView':{vistaView();break;}
case'userView':{userView();break;}
default:{defaultView();}}}}
$(function(){$('a[rel=tooltip]').mouseover(function(e){var t=$(this).attr('title');$(this).attr('title','');if($.browser.msie&&$.browser.version=='6.0'){$(this).append('<div id="tooltip" class=tooltip>'+t+'</div>');$("#tooltip").css("margin-top",+12+"px");}else{$(this).append('<div id="tooltip" class=tooltip>'+t+'</div>');$("#tooltip").css("top",(e.pageY+12)+"px");}
$('#tooltip').css('left',e.pageX+10);}).mousemove(function(e){if($.browser.msie&&$.browser.version=='6.0'){$("#tooltip").css("margin-top",+12+"px");}else{$("#tooltip").css("top",(e.pageY+12)+"px");}
$('#tooltip').css('left',e.pageX+10);}).mouseout(function(){$(this).attr('title',$('.tooltip').html());$(this).children('div#tooltip').remove();});$("span.close").click(function(){var mc=$.cookie("mc");if(mc==null||mc==="false"){$.cookie("mc","true",{expires:365,path:"/",domain:".zongheng.com"});}else{$.cookie("mc","false",{expires:365,path:"/",domain:".zongheng.com"});}
menuClose.call(this);});var mc=$.cookie("mc");if(mc==="true"){menuClose.call($("span.close").get(0));}});function menuClose(){$("#readtop span.close").css("padding-right","0");$("#readtop .bg").css("margin-right","0");$("#readbot .bg").css("margin-right","0");$("#readtop .bg").slideToggle("normal");$(this).toggleClass("open");$(this).toggleClass("active");$("#readtop #login").slideToggle("normal");$(this).toggleClass("active");$("#readtop a").slideToggle("normal");$(this).toggleClass("active");$("#readbot").slideToggle("normal");$(this).toggleClass("active");}
var timeout=500;var closetimer=0;var ddmenuitem=0;function jsddm_open()
{jsddm_canceltimer();jsddm_close();ddmenuitem=$(this).find('ul').css('visibility','visible');}
function jsddm_close()
{if(ddmenuitem)ddmenuitem.css('visibility','hidden');}
function jsddm_timer()
{closetimer=window.setTimeout(jsddm_close,timeout);}
function jsddm_canceltimer()
{if(closetimer)
{window.clearTimeout(closetimer);closetimer=null;}}
$(document).ready(function()
{$('#ment > li').bind('mouseover',jsddm_open);$('#ment > li').bind('mouseout',jsddm_timer);});document.onclick=jsddm_close;