var _color=getCookie("color");
if (_color == null || _color == "") _color="E7F4FE";

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();


function callOnAfterBody() {
	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("setBackground(_color);");
	document.writeln("<\/script>");
}

function showChapterTitleTopAd() {

	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-3306628119338015\";");
	document.writeln("\/* 728x90, 创建于 09-12-3 *\/");
	document.writeln("google_ad_slot = \"6928859946\";");
	document.writeln("google_ad_width = 728;");
	document.writeln("google_ad_height = 90;");
	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\'> ");
	document.writeln("cpro_client=\'qifuwocom_cpr\';");
	document.writeln("cpro_at=\'text_image\'; ");
	document.writeln("cpro_161=3; ");
	document.writeln("cpro_flush=2; ");
	document.writeln("cpro_w=960; ");
	document.writeln("cpro_h=90; ");
	document.writeln("cpro_template=\'text_default_960_90\'; ");
	document.writeln("cpro_cbd=\'#E7F4FE\'; ");
	document.writeln("cpro_cbg=\'#E7F4FE\'; ");
	document.writeln("cpro_ctitle=\'#0000ff\'; ");
	document.writeln("cpro_cdesc=\'#444444\'; ");
	document.writeln("cpro_curl=\'#008000\'; ");
	document.writeln("cpro_cflush=\'#e10900\'; ");
	document.writeln("cpro_uap=1;");
	document.writeln("cpro_cad=1;");
	document.writeln("cpro_channel=5;");
	document.writeln("<\/script>");
	document.writeln("<script language=\'JavaScript\' type=\'text\/javascript\' src=\'http:\/\/cpro.baidu.com\/cpro\/ui\/cp.js\'><\/script>");*/

	document.writeln("<br\/><div style=\"text-align:center;margin:1px;font-size:20px;clear:both;font-weight:bold;font-family:微软雅黑; \"><font  style=\"color:#FF0000\">小技巧可以让你在“欺负我”看书，没有弹出广告，点击<a href=\"http:\/\/www.qifuwo.com\/static\/baidu.html\" target=_blank  style=\"color:#0000FF\">查看详情<\/a>。<\/font><br><br><\/div>");

	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("var _fontSize=getCookie(\"fontSize\")");
	document.writeln("if (_fontSize != null && _fontSize != \"\") setFontSize(_fontSize);");
	document.writeln("<\/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("<script type=\"text\/javascript\"><!--");
	//document.writeln("google_ad_client = \"pub-3306628119338015\";");
	//document.writeln("\/* 728x90, 创建于 09-12-3 *\/");
	//document.writeln("google_ad_slot = \"6928859946\";");
	//document.writeln("google_ad_width = 728;");
	//document.writeln("google_ad_height = 90;");
	//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("<font color=red><strong><\/strong><\/font><br\/>");
}
function showChapterPagerTopAd() {
	document.writeln("<script type=\'text\/javascript\'> ");
	document.writeln("cpro_client=\'qifuwocom_cpr\';");
	document.writeln("cpro_at=\'text_image\'; ");
	document.writeln("cpro_161=3; ");
	document.writeln("cpro_flush=4; ");
	document.writeln("cpro_w=728; ");
	document.writeln("cpro_h=90; ");
	document.writeln("cpro_template=\'text_default_728_90\'; ");
	document.writeln("cpro_cbd=\'#" + _color + "\'; ");
	document.writeln("cpro_cbg=\'#" + _color + "\'; ");
	document.writeln("cpro_ctitle=\'#0000ff\'; ");
	document.writeln("cpro_cdesc=\'#444444\'; ");
	document.writeln("cpro_curl=\'#008000\'; ");
	document.writeln("cpro_cflush=\'#e10900\'; ");
	document.writeln("cpro_uap=1;");
	document.writeln("cpro_cad=1;");
	document.writeln("<\/script>");
	document.writeln("<script language=\'JavaScript\' type=\'text\/javascript\' src=\'http:\/\/cpro.baidu.com\/cpro\/ui\/cp.js\'><\/script>");
	
	/*document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-3306628119338015\";");
	document.writeln("\/* 728x90, 创建于 09-12-3 *\/");
	document.writeln("google_ad_slot = \"6928859946\";");
	document.writeln("google_ad_width = 728;");
	document.writeln("google_ad_height = 90;");
	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 showChapterPagerBottomAd() {
	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-3306628119338015\";");
	document.writeln("\/* 728x90, 创建于 09-12-3 *\/");
	document.writeln("google_ad_slot = \"6928859946\";");
	document.writeln("google_ad_width = 728;");
	document.writeln("google_ad_height = 90;");
	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\">");
	document.writeln("var _fontSize=getCookie(\"fontSize\")");
	document.writeln("if (_fontSize != null && _fontSize != \"\") setFontSize(_fontSize);");
	document.writeln("<\/script>");
	
	if (visitedChapterCount > 5) {
		/*document.writeln("<script type=\"text\/javascript\">");
		document.writeln("document.getElementById(\"chapter_nav\").style.paddingTop=\"-3px\";");
		document.writeln("document.getElementById(\"chapter_nav\").style.marginTop=\"-3px\";");
		document.writeln("document.getElementById(\"chapter_nav\").style.paddingBottom=\"-3px\";");
		document.writeln("document.getElementById(\"chapter_nav\").style.marginBottom=\"-3px\";");
		document.writeln("<\/script>");*/
	}

}
function showChapterRightAreaAd() {
	document.writeln("<script type=\"text\/javascript\"><!--");
	document.writeln("google_ad_client = \"pub-3306628119338015\";");
	document.writeln("\/* 336x280, 创建于 10-2-9 *\/");
	document.writeln("google_ad_slot = \"3735993442\";");
	document.writeln("google_ad_width = 336;");
	document.writeln("google_ad_height = 280;");
	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("cpro_client=\'qifuwocom_cpr\';");
	document.writeln("cpro_at=\'text_image\'; ");
	document.writeln("cpro_161=3; ");
	document.writeln("cpro_flush=2; ");
	document.writeln("cpro_w=336; ");
	document.writeln("cpro_h=280; ");
	document.writeln("cpro_template=\'text_default_336_280\'; ");
	document.writeln("cpro_cbd=\'#E7F4FE\'; ");
	document.writeln("cpro_cbg=\'#E7F4FE\'; ");
	document.writeln("cpro_ctitle=\'#0000ff\'; ");
	document.writeln("cpro_cdesc=\'#444444\'; ");
	document.writeln("cpro_curl=\'#008000\'; ");
	document.writeln("cpro_cflush=\'#e10900\'; ");
	document.writeln("cpro_uap=1;");
	document.writeln("cpro_cad=1;");
	document.writeln("cpro_channel=1;");
	document.writeln("<\/script>");
	document.writeln("<script language=\'JavaScript\' type=\'text\/javascript\' src=\'http:\/\/cpro.baidu.com\/cpro\/ui\/cp.js\'><\/script>");
	
}
function showChapterBottomAd2() {
	document.writeln("<script type=\'text\/javascript\'> ");
	document.writeln("cpro_client=\'qifuwocom_cpr\';");
	document.writeln("cpro_at=\'text_image\'; ");
	document.writeln("cpro_161=3; ");
	document.writeln("cpro_flush=2; ");
	document.writeln("cpro_w=336; ");
	document.writeln("cpro_h=280; ");
	document.writeln("cpro_template=\'text_default_336_280\'; ");
	document.writeln("cpro_cbd=\'#E7F4FE\'; ");
	document.writeln("cpro_cbg=\'#E7F4FE\'; ");
	document.writeln("cpro_ctitle=\'#0000ff\'; ");
	document.writeln("cpro_cdesc=\'#444444\'; ");
	document.writeln("cpro_curl=\'#008000\'; ");
	document.writeln("cpro_cflush=\'#e10900\'; ");
	document.writeln("cpro_uap=1;");
	document.writeln("cpro_cad=1;");
	document.writeln("cpro_channel=1;");
	document.writeln("<\/script>");
	document.writeln("<script language=\'JavaScript\' type=\'text\/javascript\' src=\'http:\/\/cpro.baidu.com\/cpro\/ui\/cp.js\'><\/script>");
}
function showChapterBottomAd3() {
	swapInnerHtml("ad1","ad1_ad");
	swapInnerHtml("ad2","ad2_ad");
	swapInnerHtml("ad3","ad3_ad");
	swapInnerHtml("ad4","ad4_ad");
	swapInnerHtml("top_ad_1","ad5_ad");
	swapInnerHtml("top_ad_2","ad6_ad");
	swapInnerHtml("top_ad_3","ad7_ad");

	/*document.getElementById("ad3").style.paddingBottom="-3px";
	document.getElementById("ad4").style.paddingTop="-3px";
	document.getElementById("ad3").style.marginBottom="-3px";
	document.getElementById("ad4").style.marginTop="-3px";*/
	
	document.writeln(getPopCode(1));
	writeAdJs();
}

// chapters
function showChaptersTopAd() {
	document.writeln("<script type=\"text\/javascript\">");
	document.writeln("setBackground(_color);");
	document.writeln("<\/script><br\/>");

	document.writeln("<br\/><div style=\"text-align:center;margin:1px;font-size:20px;clear:both;font-weight:bold;font-family:微软雅黑; \"><font  style=\"color:#FF0000\">在“欺负我”看书，如何没有弹出广告？点击<a href=\"http:\/\/www.qifuwo.com\/static\/baidu.html\" target=_blank  style=\"color:#0000FF\">查看详情<\/a>。<\/font><\/div>");

}
function showChaptersBottomAd() {
	document.writeln(getPopCode(2));
	//document.writeln("<a href=\"http:\/\/ad.fslinkad.cn\/Monitor\/Monitor.aspx?PlaceID=1208&TargetUrl=http%3a%2f%2fadrs.sdo.com%2fADRefererSystem%2fadjump.aspx%3fSndaADID%3d00-dzj-09121501%26RedirectUrl%3dhttp%253a%252f%252fdzj.sdo.com\"><img src=\"http:\/\/www.qifuwo.com\/static\/760_60.gif\"\/><\/a>");
}

// novel
function showNovelTopAd() {
	
}
function showNovelRightAd() {
	
}
function showTongJi() {
	document.writeln("<script language=\"javascript\" type=\"text\/javascript\" src=\"http:\/\/js.users.51.la\/2413080.js\"><\/script>");
        document.writeln("<script src=\"http:\/\/s126.cnzz.com\/stat.php?id=1858740&web_id=1858740\" language=\"JavaScript\" charset=\"gb2312\"><\/script>");

	document.writeln("<script type=\'text\/javascript\'> ");
	document.writeln("cpro_client=\'qifuwocom_cpr\';");
	document.writeln("cpro_position=2; ");
	document.writeln("cpro_follow=1; ");
	document.writeln("cpro_close=2; ");
	document.writeln("cpro_template=\'float_xuanfuwin_300_250\'; ");
	document.writeln("cpro_contw=950; ");
	document.writeln("cpro_w=300; ");
	document.writeln("cpro_h=250; ");
	document.writeln("cpro_float=2; ");
	document.writeln("cpro_cad=1;");
	document.writeln("cpro_channel=4;");
	document.writeln("<\/script>");
	document.writeln("<script language=\'JavaScript\' type=\'text\/javascript\' src=\'http:\/\/cpro.baidu.com\/cpro\/ui\/float.js\'><\/script>");
}

function writeAdJs() {
	document.writeln("<script type=\"text\/JavaScript\"> ");
	document.writeln("document.body.oncopy = function () { ");
	document.writeln("	setTimeout( function () { ");
	document.writeln("		var text = clipboardData.getData(\"text\");");
	document.writeln("		var novelIndex = location.href;");
	document.writeln("		var lastPos = novelIndex.lastIndexOf(\"\/\");");
	document.writeln("		if (lastPos > -1) {");
	document.writeln("			novelIndex = novelIndex.substring(0, lastPos + 1);");
	document.writeln("		} else {");
	document.writeln("		}");
	document.writeln("		if (text) { ");
	document.writeln("			text = text + \"\\r\\n文章来自:欺负我(http:\/\/www.qifuwo.com) 详文参考：\"+novelIndex; clipboardData.setData(\"text\", text);");
	document.writeln("		} ");
	document.writeln("				}, 100 ) ");
	document.writeln("}");
	document.writeln("<\/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="";
}
var adcode = [
"<script type=\'text\/javascript\' language=\'javascript\'>var cnxad_userid=\'44618\';var cnxad_subid=\'0\';var cnxad_exid=\'0\';var cnxad_t=\'0\';var cnxad_encode=\'tADnjyN12r%2fWN2oPnSnKNP1dYgz0tKTL1dOMiY4dF93gSrzVazenZQ%3d%3d&et=1\';<\/script><script type=\'text\/javascript\' language=\'javascript\' src=\'http:\/\/js.cnxad.com\/pcode.js\'><\/script>",
"<script language=\"javascript\" src=\"http:\/\/www.unionbig.com\/C.Html?P=2958&T=1&A=&k=2&Z=0&S=0&N=10\"><\/script>",
"<script type=\"text\/javascript\">var cs_uid=256;<\/script><script type=\"text\/javascript\" src=\"http:\/\/www.37cs.com\/popup\/popup.js\"><\/script>"
              ];
var popedOrderAd = [2, 1,
                    0, 2,
                    1, 0,
                    2, 1,
                    0, 2,
                    1, 0,
                    2, 1,
                    0, 1];


function getPopCode(which) {
	if (getCookie("notpop") != null) {
		return "";
	}
	if(document.referrer.indexOf("sodu.org")>-1){
		return "";
	}
	if (which == 1 && !needPopedAd("chapter", 2, 6)) {
		return "";
	}
	//if (which == 2 && !needPopedAd("chapters", 0.5, 18)) {
	//	return "";
	//}
	
	var index = getIndex();
	if (index >= popedOrderAd.length) {
		return "";
	}
	document.writeln("[" + index + "]");
	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 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 getResetTime() {
	var now = new Date();
	var now2 = new Date();
	now.setHours(0);
	now.setMinutes(0);
	now.setSeconds(0);
	now.setMilliseconds(0);
	return new Date(24 * 3600 * 1000 + now.getTime());
}

var refer = document.referrer;
if (refer.indexOf("baidu.com") > -1) {
	if (refer.indexOf("=%C6%DB%B8%BA%CE%D2") > -1) {
		setCookieWithTime("notpop", "1", getResetTime());
	}
}

