var t_id=setInterval(animate,10);var pos=0;var dir=2;var len=0;function animate()
{var elem=document.getElementById('progress');if(elem!=null){if(pos==0)len+=dir;if(len>32||pos>249)pos+=dir;if(pos>249)len-=dir;if(pos>249&&len==0)pos=0;elem.style.left=pos;elem.style.width=len;}}
function remove_loading(){this.clearInterval(t_id);var targelem=document.getElementById('loader_container');targelem.style.display='none';targelem.style.visibility='hidden';}
//setTimeout("remove_loading()",7000);
function ShowMemPop(){
	$("#loader_container").show();
	$("#popmsg").empty();
	$("#popmsg").append("您的广告票还有剩余,系统将自动为您使用一张,<br/>并赠送15积分,感谢你对我们的支持!");
	setTimeout("remove_loading()",4000);
}
function ShowGuePop(){
	$("#loader_container").show();
	$("#popmsg").empty();
	$("#popmsg").append("小提示:登陆/注册成为本站会员即可屏蔽弹出广告.");
	setTimeout("remove_loading()",4000);
}

// Tpl
function TplReportBug(bookname, bookid, cpid, cptitle, url) {
	/*<br /><font size="3"> <a href="javascript:void(0)" onclick="ReportBug(location.href)">[→举报章节错误←]</a> </font>*/
	document.writeln("<br \/><font size=\"3\"> <a href=\"javascript:void(0)\" onclick=\"ReportBug(location.href)\">[→举报章节错误←]<\/a> <\/font>");	
}
function TplMenuEnd(bookid, markurl, cpl, rec) {
	document.writeln("<div id=\"MenuEnd\">");
	document.writeln("	<ul>");
	document.writeln("		<li><a href=\"#\" onclick=\"GotoCpList(\'" + cpl + "\')\">章节目录<\/a><\/li>");
	document.writeln("		<li><a href=\"javascript:void(0)\" onclick=\"SetCpMark(\'" + markurl + "\')\">加入书签<\/a><\/li>");
	document.writeln("		<li><a href=\"#\" onclick=\"OpenBookStore()\">打开书架<\/a><\/li>");
	document.writeln("		<li><a href=\"#\" onclick=\"GotoBookInfoPage(\'" + bookid + "\')\">返回书页<\/a><\/li>");
	document.writeln("		<li><a href=\"javascript:void(0)\" onclick=\"RecBook(\'" + rec + "\')\">推荐本书<\/a><\/li>");
	document.writeln("	<\/ul>");
	document.writeln("<\/div>");
	/*
	<div id="MenuEnd">
	<ul>
	<li><a href="javascript:void(0)" onclick="GotoCpList('')">章节目录</a></li>
	<li><a href="javascript:void(0)" onclick="SetCpMark('')">加入书签</a></li>
	<li><a href="javascript:void(0)" onclick="OpenBookStore()">打开书架</a></li>
	<li><a href="javascript:void(0)" onclick="GotoBookInfoPage('')">返回书页</a></li>
	<li><a href="javascript:void(0)" onclick="RecBook('')">推荐本书</a></li>
	</ul>
	</div>
	*/
}
function TplMenuTop(bookid, markurl, cpl, rec) {
	document.writeln("<div id=\"MenuTop\">");
	document.writeln("	<ul>");
	document.writeln("		<li><a href=\"#\" onclick=\"GotoCpList(\'" + cpl + "\')\">章节目录<\/a><\/li>");
	document.writeln("		<li><a href=\"javascript:void(0)\" onclick=\"SetCpMark(\'" + markurl + "\')\">加入书签<\/a><\/li>");
	document.writeln("		<li><a href=\"#\" onclick=\"OpenBookStore()\">打开书架<\/a><\/li>");
	document.writeln("		<li><a href=\"#\" onclick=\"GotoBookInfoPage(\'" + bookid + "\')\">返回书页<\/a><\/li>");
	document.writeln("		<li><a href=\"javascript:void(0)\" name=\"StranLink\" style=\"color: red\">简体中文<\/a><\/li>");
	document.writeln("	<\/ul>");
	document.writeln("<\/div>");
	/*
	<div id="MenuTop">
	<ul>
	<li><a href="javascript:void(0)" onclick="GotoCpList('')">章节目录</a></li>
	<li><a href="javascript:void(0)" onclick="SetCpMark('')">加入书签</a></li>
	<li><a href="javascript:void(0)" onclick="OpenBookStore()">打开书架</a></li>
	<li><a href="javascript:void(0)" onclick="GotoBookInfoPage('')">返回书页</a></li>
	<li><a href="javascript:void(0)" name="StranLink" style="color: red">简体中文</a></li>
	</ul>
	</div>
	*/
}
function TplLinkMenu(varup, varlist, vardown) {
	document.writeln("<br \/><font size=\"3\">[←]" + varup + " <a href=\"" + varlist + "\">[目录]<\/a> " + vardown + "[→]<\/font>");

	/*
	<br /><font size="3"> <a href="">[目录]</a> </font>
	*/
}
function TplTextSelect(){
	document.writeln("	<div id=\"TextSelect\">");
	document.writeln("	<div class=\"ts1\">");
	document.writeln("	<span>选择背景颜色：<\/span><a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#dcecf5\')\"><img");
	document.writeln("	src=\"http:\/\/img.uutxt.com\/images\/icon01.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#e7f4fe\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon02.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#edf6d0\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon03.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#f5f1e7\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon04.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#eae8f7\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon05.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#fef4f0\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon06.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#ebf4ef\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon07.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetBgColor(\'#616378\')\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon08.gif\" width=\"15\" height=\"18\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a>");
	document.writeln("	<\/div>");
	document.writeln("	<div class=\"ts2\">");
	document.writeln("	<span>选择字体：<\/span><a href=\"javascript:void(0)\" onclick=\"SetfontSize(17)\"><img src=\"http:\/\/img.uutxt.com\/images\/icon09.gif\"");
	document.writeln("	width=\"21\" height=\"21\" border=\"0\" alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetfontSize(12)\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon10.gif\" width=\"21\" height=\"21\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetfontSize(10)\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon11.gif\" width=\"21\" height=\"21\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a><\/div>");
	document.writeln("	<div class=\"ts3\">");
	document.writeln("	<span>滚动速度：<\/span><a href=\"javascript:void(0)\" onclick=\"SetSpeed(1)\"><img src=\"http:\/\/img.uutxt.com\/images\/icon12.gif\"");
	document.writeln("	width=\"21\" height=\"21\" border=\"0\" alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetSpeed(20)\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon13.gif\" width=\"21\" height=\"21\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a> <a href=\"javascript:void(0)\" onclick=\"SetSpeed(40)\">");
	document.writeln("	<img src=\"http:\/\/img.uutxt.com\/images\/icon14.gif\" width=\"21\" height=\"21\" border=\"0\"");
	document.writeln("	alt=\"\" \/><\/a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"SongTi()\">宋体<\/a>&nbsp;&nbsp;<a");
	document.writeln("	href=\"javascript:void(0)\" onclick=\"SetDefault()\">默认<\/a>&nbsp;&nbsp;<a href=\"javascript:void(0)\" ");
	document.writeln("	onclick=\"SetFont()\">字体<\/a><\/div>");
	document.writeln("	<div class=\"ts4\">");
	document.writeln("	<span id=\"adnotify\">双击开始滚动屏幕<\/span>");
	document.writeln("	<\/div>");
	document.writeln("	<\/div>");
	/*
	<div id="TextSelect">
	<div class="ts1">
	<span>选择背景颜色：</span><a href="javascript:void(0)" onclick="SetBgColor('#dcecf5')"><img
	src="http://img.uutxt.com/images/icon01.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#e7f4fe')">
	<img src="http://img.uutxt.com/images/icon02.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#edf6d0')">
	<img src="http://img.uutxt.com/images/icon03.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#f5f1e7')">
	<img src="http://img.uutxt.com/images/icon04.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#eae8f7')">
	<img src="http://img.uutxt.com/images/icon05.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#fef4f0')">
	<img src="http://img.uutxt.com/images/icon06.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#ebf4ef')">
	<img src="http://img.uutxt.com/images/icon07.gif" width="15" height="18" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetBgColor('#616378')">
	<img src="http://img.uutxt.com/images/icon08.gif" width="15" height="18" border="0"
	alt="" /></a>
	</div>
	<div class="ts2">
	<span>选择字体：</span><a href="javascript:void(0)" onclick="SetfontSize(17)"><img src="http://img.uutxt.com/images/icon09.gif"
	width="21" height="21" border="0" alt="" /></a> <a href="javascript:void(0)" onclick="SetfontSize(12)">
	<img src="http://img.uutxt.com/images/icon10.gif" width="21" height="21" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetfontSize(10)">
	<img src="http://img.uutxt.com/images/icon11.gif" width="21" height="21" border="0"
	alt="" /></a></div>
	<div class="ts3">
	<span>滚动速度：</span><a href="javascript:void(0)" onclick="SetSpeed(1)"><img src="http://img.uutxt.com/images/icon12.gif"
	width="21" height="21" border="0" alt="" /></a> <a href="javascript:void(0)" onclick="SetSpeed(20)">
	<img src="http://img.uutxt.com/images/icon13.gif" width="21" height="21" border="0"
	alt="" /></a> <a href="javascript:void(0)" onclick="SetSpeed(40)">
	<img src="http://img.uutxt.com/images/icon14.gif" width="21" height="21" border="0"
	alt="" /></a>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="SongTi()">修复字体变形</a>&nbsp;&nbsp;<a
	href="javascript:void(0)" onclick="SetDefault()">默认方案</a>&nbsp;&nbsp;<a href="javascript:void(0)" 
	onclick="SetFont()">设定字体</a></div>
	<div class="ts4">
	<span id="adnotify">双击开始滚动屏幕</span>
	</div>
	</div>
	*/
}
// ---
function GotoCpList(o) {
	//alert(o);
	location.href = o;
}
function SetCpMark(o) {
	//ymPrompt.win({ message: "http://user.uutxt.com"+o, width: 800, height: 600, title: '悠悠助手提示您', btn: [['关闭', '']], iframe: true, titleBar: false });
	//G("xloader").src = "http://user.uutxt.com" + o;
	G("xloader").src = "http://nyuser.uutxt.com/center/addbookmark.aspx?seaid=" + tbookid + "&sonid=" + tcpid + "&url=" + tcpid + "&name=" + encodeURI(tcptitle) + "&title=" + encodeURI(tbooktitle) + "&group=book&siteid=1" + UrlSeed();
	//alert("设定成功!");
}
function OpenBookStore() {
	location.href = "http://nyuser.uutxt.com/center/bookstore.aspx";
}
function GotoBookInfoPage(o) {
	//alert("http://www.uutxt.com/" + o + ".html");
	location.href = "http://www.uutxt.com/" + o + ".html";
}
function RecBook(o) {
	//ymPrompt.win({ message: "http://user.uutxt.com"+o, width: 800, height: 600, title: '悠悠助手提示您', btn: [['关闭', '']], iframe: true, titleBar: false });
	//G("xloader").src = "http://user.uutxt.com" + o;
	G("xloader").src = "http://nyuser.uutxt.com/ashx/click.aspx?id=0&act=rec"+ UrlSeed();
	//alert("推荐成功!");
}
function ReportBug(url){
	//url = "http://www.niaoyan.com/app/bugreport/uutxtrep.aspx?g=chapter&act=post&url=" + url;
	//ymPrompt.win({ message: url, width: 300, height: 250, title: '书盟的发展离不开您的支持~', btn: [['关闭', '']], iframe: true, titleBar: false });
}

function isNum(s) {
	var pattern = /^\d+(\.\d+)?$/;
	return pattern.test(s)
}
var timer;
function StopScroll() {
	clearInterval(timer);
}
function BeginScroll() {
	timer = setInterval("Scrolling()", $.cookie("cp_speed_8x"));
}
function SetSpeed(o) {
	$.cookie("cp_speed_8x", o);
}
function Scrolling() {
	currentpos = document.documentElement.scrollTop;
	window.scroll(0, ++currentpos);
	if (currentpos != document.documentElement.scrollTop) {
		clearInterval(timer);
	}
}
function LoadUserPro() {
	if ($.cookie("cp_speed_8x") == false) {
		SetSpeed(20);
	} else {
		SetSpeed($.cookie("cp_speed_8x"));
	}
	if ($.cookie("cp_fontsize_8x") == false) {
		SetfontSize(12);
	} else {
		SetfontSize($.cookie("cp_fontsize_8x"));
	}
	if ($.cookie("cp_bg_8x") == false) {
		SetBgColor("#E7F4FE");
	} else {
		SetBgColor($.cookie("cp_bg_8x"));
	}
	if ($.cookie("cp_fontFamily_8x") != false) {
		G('BookText').style.fontFamily = $.cookie("cp_fontFamily_8x");
	}
}
function SetfontSize(o) {
	var Divs = G('BookText');
	if (Divs != null) {
		Divs.style.fontSize = o + "pt";
	}
	$.cookie("cp_fontsize_8x", o);
}
function SetBgColor(o) {
	document.body.bgColor = o;
	$.cookie("cp_bg_8x", o);
}
function SetFont() {
	var tempA = window.prompt("请输入您喜欢的字体,默认为微软雅黑,如果不存在则为宋体.", "微软雅黑");
	if (tempA == "") {
		tempA = "微软雅黑";
	}
	G('BookText').style.fontFamily = tempA;
	$.cookie("cp_fontFamily_8x", tempA);
	tempA = window.prompt("请输入字体大小,默认为 12PX .", "12");
	if (tempA == "" || !isNum(tempA)) {
		tempA = 12;
	}
	SetfontSize(tempA);
}
function SetDefault() {
	SetSpeed(20);
	SetBgColor("#e7f4fe");
	SetfontSize(12);
	$.cookie("cp_fontFamily_8x", "微软雅黑");
	G('BookText').style.fontFamily = $.cookie("cp_fontFamily_8x");
}
function SongTi(){
	$.cookie("cp_fontFamily_8x", "宋体");
	G('BookText').style.fontFamily = $.cookie("cp_fontFamily_8x");
}

document.onmousedown = StopScroll;
document.ondblclick = BeginScroll;

var w = 0;
function AutoWidth() {
	var q_23 = document.body.clientWidth;
	if (q_23 != w) {
		w = q_23;
		if (w < 800) {
			ww = w - 30;
			$("#AutoWidth").attr("style", "width:" + ww + "px");
		} else {
			if (w != 0) {
				$("#AutoWidth").attr("style", "width:100%");
			}
		}

	}
}

//////////////////////////////////////////////////////////////////////////
// 广告模块
var cpx1785;
function Locker() {
	if (cpx1785 == 1) {
		cpx1785 = 0;
		document.body.onclick = "";
	}
}
function log() {
	if (cpx1785 == 0) {
		cpx1785 = 1;
		document.body.onclick = function() {
			Locker();
		};
		setTimeout(function() {
			LinkAlert();
		}, 4000);
	}
}
function LinkAlert() {
	if (cpx1785 == 1) {
		cpx1785 = 0;
		document.body.onclick = "";
		$("#adnotify").empty();
		$("#adnotify").append("<font color=red><b>您刚刚点击了广告!</b></font>");
		//bug = new Image();
		//bug.src = 'http://user.uutxt.com/adscount.aspx'
		//G("xloader").src = "http://user.uutxt.com/adscount.aspx";
		G("xloader").src = "http://nyuser.uutxt.com/ashx/click.aspx?act=ad&id=0" + UrlSeed();
	}
}
$(document).ready(function() {
	elements2 = document.getElementsByTagName("iframe");
	for (var i = 0; i < elements2.length; i++) {
		if (elements2[i].src.indexOf(':/') > -1) {
			elements2[i].onfocus = log;
		}
	}
	LoadUserPro();
	cpx1785 = 0;
	AutoWidth();
	setInterval("AutoWidth()", 1000);
});
function UrlSeed() {
  return "&seed=" + Date.parse(new Date());
}