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\" >BAIDU_CLB_SLOT_ID = \"49019\";<\/script><script type=\"text\/javascript\" src=\"http:\/\/cbjs.baidu.com\/js\/o.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>");


	/*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("<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 > 8) {
			document.getElementById("ad3").style.marginBottom="-3px";
			document.getElementById("ad4").style.marginTop="-1px";
	}

}
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("ad3").style.marginBottom="-3px";
	document.getElementById("ad4").style.paddingTop="-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("<script type=\"text\/javascript\" >BAIDU_CLB_SLOT_ID = \"49019\";<\/script><script type=\"text\/javascript\" src=\"http:\/\/cbjs.baidu.com\/js\/o.js\"><\/script>");

}
function showChaptersBottomAd() {
	document.writeln(getPopCode(2));
	        //document.writeln("<script language=\"javascript\" type=\"text/javascript\" src=\"\/static\/app.js\"><\/script>");

}

// novel
function showNovelTopAd() {
	
}
function showNovelRightAd() {
	

}

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:\/\/www.qifuwo.com\/static\/hit.css\" rel=\"stylesheet\" type=\"text\/css\" media=\"screen\" \/>");
		document.writeln("<script language=\"javascript\" type=\"text\/javascript\" src=\"http:\/\/www.qifuwo.com\/static\/app.js\"><\/script>");
	}
}

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>");

}

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 language=\"javascript\" src=\"http:\/\/u923032.778669.com\/fshow.php?id=140599\"><\/script>"
,"<script type=\"text\/javascript\">  u_a_client=\"331\";  u_a_width=\"0\";   u_a_height=\"0\";   u_a_zones=\"484\";   u_a_type=\"1\"; <\/script><script src=\"http:\/\/www.xt918.com\/i.js\"><\/script>"
,"<script type=\"text\/javascript\">u_a_client=\"32609\";u_a_width=\"0\"; u_a_height=\"0\"; u_a_zones=\"12319\"; u_a_type=\"1\"; <\/script><script src=\"http:\/\/i.egooad.cn\/i.js\"><\/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 = [3, 2,
                    0, 1,
                    3, 2,
                    0, 1,
                    3, 2,
                    1, 0,
                    3, 2,
                    0, 1];


function getPopCode(which) {
	if (getCookie("notpop") != null) {
		return "";
	}
	if(document.referrer.indexOf("sodu.org")>-1){
		return "";
	}
	if (which == 1 && !needPopedAd("chapter", 0.5, 16)) {
		return "";
	}
	//if (which == 2 && !needPopedAd("chapters", 0.5, 50)) {
	//	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());
	}
} else if(refer.indexOf("360.cn") > -1) {
	setCookieWithTime("notpop", "1", getResetTime());
} 
