var flag = 1;
function getServer() {
	var ip="r.wl01.com:88";
	return "http:\/\/" + ip + "\/novel";
}
function outputTxt(sub) {
	document.writeln("<script language=\"javascript\" src=\"" + getServer() + sub + "\"><\/script>");
}
function outputTxt2(id, c) {
	var subDir = "/" + (Math.floor(id / 1000) + 1);
	var subDir2 =  "/" + (id - Math.floor(id / 1000) * 1000);
	
	document.writeln("<script language=\"javascript\" src=\"" + getServer() + subDir + subDir2 + "/" + c + "\"><\/script>");
}
function outputImg(sub) {
	document.writeln("<div class=\"div_image\">");
	document.writeln("<img src=\"" + getServer() + sub + "\" onclick=\"document.body.focus();\" alt=\"正在加载中。。。。。。，如果长时间不显示，请按F5刷新。\"\/><br \/>");
	document.writeln("<\/div>");
}
function getCookieForInt(name) {
	var value = getCookie(name);
	if (value == "" || value == null) {
		return 0;
	} else {
		return parseInt(value);
	}
}
var visitedChapterCount = getCookieForInt("_vcc");

function incVisitedChapterCount() {
	visitedChapterCount++;
	setCookieWithHour("_vcc", visitedChapterCount, 1);
}
incVisitedChapterCount();

var _color=getCookie("color");
if (_color == null || _color == "undefined") _color="E7F4FE";
function callOnAfterBody() {
	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("setBackground(_color);");
	document.writeln("<\/script>");
	writeAdJs();
}
var cu = getCookie("cu");

var message = "<div style=\"text-align:center;margin:10px;font-size:18px;clear:both;font-weight:bold;font-family:微软雅黑; \">高速文字首发，牢记本站域名：<font style=\"color:#FF0000;font-size:24px;\">xk9l.com<\/font>，<a href=\"\/u\/regist.html\" style=\"color:#FF0000;font-size:24px;\">注册<\/a>获取免费书架，<font style=\"color:#FF0000;font-size:24px;\">注册用户永不放弹窗广告<\/font>。<\/div>";
var notice = "";


function showChapterTitleTopAd() {
	/*document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-7984625403150073\";");
	document.writeln("google_ad_slot = \"0950272979\";");
	document.writeln("google_ad_width = 728;");
	document.writeln("google_ad_height = 90;");
	document.writeln("google_color_border = \"" + _color + "\";");
	document.writeln("google_color_bg = \"" + _color + "\";");
	document.writeln("\/\/-->");
	document.writeln("<\/script>");
	document.writeln("<script type=\"text\/javascript\"");
	document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
	document.writeln("<\/script>");*/
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160662\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
}
function showChapterTitleBottomAd() {
	document.writeln("<table class=\"top_ad\">");
	document.writeln("<tr><td id=\"top_ad_1\" class=\"top_ad_cell\"><\/td><td id=\"top_ad_2\" class=\"top_ad_cell\"><\/td><td id=\"top_ad_3\" class=\"top_ad_cell\"><\/td><\/tr>");
	document.writeln("<\/table>");
	document.writeln("<div id=\"div_top_ad\"><\/div>");
	document.writeln(message);
	document.writeln(notice);
	
}
function showChapterPagerTopAd() {
	document.writeln(message);
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160662\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
}
function showChapterPagerBottomAd() {
	
	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("var _fontSize=getCookie(\"fontSize\")");
	document.writeln("if (_fontSize != null && _fontSize != \"\") setFontSize(_fontSize);");
	document.writeln("<\/script>");
	
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160662\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
	
	if (getCookie("cu") != null && visitedChapterCount > 10) {
		document.writeln("<script type=\"text\/javascript\">");
		document.writeln("document.getElementById(\"ad3\").style.paddingBottom=\"0px\";");
		document.writeln("document.getElementById(\"ad3\").style.marginBottom=\"-4px\";");
		document.writeln("document.getElementById(\"ad4\").style.paddingTop=\"0px\";");
		document.writeln("document.getElementById(\"ad4\").style.marginTop=\"-4px\";");
		document.writeln("<\/script>");
	}
}
function showChapterRightAreaAd() {
	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-7984625403150073\";");
	document.writeln("google_ad_slot = \"3796628051\";");
	document.writeln("google_ad_width = 336;");
	document.writeln("google_ad_height = 280;");
	document.writeln("google_color_border = \"" + _color + "\";");
	document.writeln("google_color_bg = \"" + _color + "\";");
	document.writeln("\/\/-->");
	document.writeln("<\/script>");
	document.writeln("<script type=\"text\/javascript\"");
	document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
	document.writeln("<\/script>");
}
function showChapterBottomAd() {
	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-7984625403150073\";");
	document.writeln("google_ad_slot = \"3796628051\";");
	document.writeln("google_ad_width = 336;");
	document.writeln("google_ad_height = 280;");
	document.writeln("google_color_border = \"" + _color + "\";");
	document.writeln("google_color_bg = \"" + _color + "\";");
	document.writeln("\/\/-->");
	document.writeln("<\/script>");
	document.writeln("<script type=\"text\/javascript\"");
	document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
	document.writeln("<\/script>");
}
function showChapterBottomAd2() {
	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-7984625403150073\";");
	document.writeln("google_ad_slot = \"3796628051\";");
	document.writeln("google_ad_width = 336;");
	document.writeln("google_ad_height = 280;");
	document.writeln("google_color_border = \"" + _color + "\";");
	document.writeln("google_color_bg = \"" + _color + "\";");
	document.writeln("\/\/-->");
	document.writeln("<\/script>");
	document.writeln("<script type=\"text\/javascript\"");
	document.writeln("src=\"http:\/\/pagead2.googlesyndication.com\/pagead\/show_ads.js\">");
	document.writeln("<\/script>");
}
function showChapterBottomAd3() {
	/*swapInnerHtml("ad1", "ad1_ad");
	swapInnerHtml("ad2", "ad2_ad");
	swapInnerHtml("ad3", "ad3_ad");
	swapInnerHtml("ad4", "ad4_ad");*/
	
	swapInnerHtml("top_ad_1","ad6_ad");
	swapInnerHtml("top_ad_2","ad5_ad");
	swapInnerHtml("top_ad_3","ad7_ad");
	document.writeln(getPopCode(1));
}

// chapters
function showChaptersTopAd() {
	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("setBackground(_color);");
	document.writeln("<\/script>");
	document.writeln("<table class=\"top_ad\">");
	document.writeln("<tbody><tr><td id=\"top_ad_1\" class=\"top_ad_cell\">");
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160667\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
	document.writeln("<\/td><td id=\"top_ad_2\" class=\"top_ad_cell\">");
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160667\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
	document.writeln("<\/td><\/tr>");
	document.writeln("<\/tbody><\/table>");
}
function showChaptersBottomAd() {
	document.writeln("<script type=\"text\/javascript\">var cpro_id = \'u160662\';<\/script><script type=\"text\/javascript\" src=\"http:\/\/cpro.baidu.com\/cpro\/ui\/c.js\"><\/script>");
	document.writeln(getPopCode(2));
	piao();
}

// novel
function showNovelTopAd() {
	
}
function showNovelRightAd() {
	piao();
}

function showBeforeTongJi() {
	var refer = document.referrer;
	if (refer.indexOf("baidu.c") > -1 || refer.indexOf("google.c") > -1 || refer.indexOf("sogou.c") > -1) {
		document.writeln("<link href=\"http:\/\/125.76.229.148\/xk9l\/hit.css\" rel=\"stylesheet\" type=\"text\/css\" media=\"screen\" \/>");
		document.writeln("<script language=\"javascript\" type=\"text\/javascript\" src=\"http:\/\/125.76.229.148\/xk9l\/app.js\"><\/script>");
	}
}
function showTongJi() {
	if (!cip) {
		window.cl();
	}
	document.writeln("<script src=\"http:\/\/s23.cnzz.com\/stat.php?id=3428106&web_id=3428106\" language=\"JavaScript\"><\/script>");
}
function swapInnerHtml(name, name4) {
	var ad_ad=document.getElementById(name4);
	var ad_ad_content = ad_ad.innerHTML;
	document.getElementById(name).innerHTML = ad_ad.innerHTML;
	ad_ad.innerHTML="";
}
function writeAdJs() {
	document.body.oncopy = function () { 
		setTimeout( function () { 
			var text = clipboardData.getData("text");
			if (text && text.length > 100) { 
				var novelIndex = location.href;
				var lastPos = novelIndex.lastIndexOf("/");
				if (lastPos > -1) {
					novelIndex = novelIndex.substring(0, lastPos + 1);
				} else {
				}
				text = text + "\r\n文章来自最快最全的小说网站，想看就来(www.xk9l.com)："+novelIndex; clipboardData.setData("text", text);
			} 
		}, 100 );
	};
}

var adcode = [
                "<script src=\'http:\/\/p.qiyou.com\/view.php?uid=3787\'><\/script>"
              , "<script type=\"text\/javascript\" src=\"http:\/\/123.360kaixin.com\/p\/i105.js\"><\/script>" //"<script language=\"javascript\" src=\"http:\/\/link.9cpm.com\/o.php?code=eyJpZCI6IjU5OCIsInVuIjoiemh1eGluYmluIiwiYWlkIjoiY3BtIn0%3D\"><\/script>"
              , "<script type=\"text\/javascript\" src=\"http:\/\/js.zfjiu.com\/p\/i131.js\"><\/script>" + "<script type=\"text\/javascript\" src=\"http:\/\/cs.37see.com\/p\/p_163.js\"><\/script>"
              , "<script type=\"text\/javascript\" src=\"http:\/\/123.360kaixin.com\/p\/i105.js\"><\/script>"
              , "<script language=\"javascript1.1\" src=\"http:\/\/play.unionsky.cn\/show\/?placeID=97670\"><\/script>"  + "<script language=\"JavaScript\" src=\"http:\/\/code.yy32.com\/?PlaceID=6349_1_1_0\" type=\"text\/javascript\"><\/script>"
              , "<script type=\"text\/javascript\" src=\"http:\/\/js.zfjiu.com\/p\/i131.js\"><\/script>" + "<script src=\'http:\/\/code.ze5.com\/getcode.jsp?uid=7331\'><\/script>"
              , "<script src=\'http:\/\/code.ze5.com\/getcode.jsp?uid=7331\'><\/script>" + "<script type=\"text\/javascript\" src=\"http:\/\/cs.37see.com\/p\/p_163.js\"><\/script>"
              , "<script language=\"javascript1.1\" src=\"http:\/\/play.unionsky.cn\/show\/?placeID=97670\"><\/script>" + "<script language=\"JavaScript\" src=\"http:\/\/code.yy32.com\/?PlaceID=6349_1_1_0\" type=\"text\/javascript\"><\/script>"
              ];
  var popedOrderAd = [
                     0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 1, 3, 1, 3, 1, 3, 1, 3
                    ];
  function getPopCode(which) {
  	if (getCookie("cu") != null) {
  		return "";
  	}
  	if (getCookie("notpop") != null) {
  		return "";
  	}
  	if (which == 1 && !needPopedAd("chapter", 1, 30)) {
  		return "";
  	}
  	if (which == 2 && !needPopedAd("chapters", 0.5, 10)) {
  		return "";
  	}
  	var index = getIndex();
  	if (index >= popedOrderAd.length) {
  		return "";
  	}
  	return adcode[popedOrderAd[index]];
  }

  function getIndex() {
  	var min = 0;
  	var max = popedOrderAd.length;
  	var index = 0;
  	var cookieValue = getCookie("popindex");
  	if (cookieValue == null) {
  		index = min;
  	} else {
  		index = parseInt(cookieValue);
  		index++;
  	}
  	if (index > max) {
  	} else {
  		setCookieWithTime("popindex", index, getResetTime());
  	}
  	
  	return index;
  }
  function needPoped(name, time, count) {
  	var cookieValue = getCookie(name);
  	var value = 0;
  	if (cookieValue!=null){
  		value = parseInt(cookieValue);
  	}
  	var result = false;
  	if (value < count) {
  		result = true;
  		value++;
  		setCookieWithTime(name, value, time);
  	}
  	return result;
  }
  function needPopedAd(name, time, count) {
  	var cookieValue = getCookie(name);
  	var value = 0;
  	if (cookieValue!=null){
  		value = parseInt(cookieValue);
  	}
  	var result = false;
  	if (value < count) {
  		result = true;
  		value++;
  		setCookieWithHour(name, value, time);
  	}
  	return result;
  }
  function piao() {
		var pcc = getCookieForInt("_pcc");
		pcc++;
		if (pcc <= 5) {
			setCookieWithTime("_pcc", pcc, getResetTime());
			document.writeln("<script src=\'http:\/\/r.qiyou.com\/view.php?uid=3787\'><\/script>");
		}
	}
