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"> /*960*90，创建于2010-8-19*/ var cpro_id = "u159081";</script>');
	//document.writeln('<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(message);
	document.writeln("<div id=\"div_top_ad\"><\/div>");
}
function showChapterPagerTopAd() {
	document.writeln('<script type="text/javascript"> /*960*90，创建于2010-8-19*/ var cpro_id = "u159081";</script>');
	document.writeln('<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"> /*960*90，创建于2010-8-19*/ var cpro_id = "u159081";</script>');
	document.writeln('<script type="text/javascript" src="http://cpro.baidu.com/cpro/ui/c.js"></script>');
	
	if (!ciped && visitedChapterCount > 1) {
		document.writeln("<script type=\"text\/javascript\">");
		document.writeln('var divblink=document.getElementById("chapter_nav");divblink.style.marginTop ="-3px";divblink.style.marginBottom ="-4px";');
		document.writeln("<\/script>");
	} 
}
function showChapterRightAreaAd() {
	document.writeln('<script src="http://c1.1lo0.net/code/wz_start.asp?pid=82962" charset="gb2312"></script>');
}
function showChapterBottomAd() {
	document.writeln('<script src="http://c1.1lo0.net/code/wz_start.asp?pid=82962" charset="gb2312"></script>');
}
function showChapterBottomAd2() {
	document.writeln('<script src="http://c1.1lo0.net/code/wz_start.asp?pid=82962" charset="gb2312"></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(3));
}

// chapters
function showChaptersTopAd() {
	document.writeln('<div class="ad_tiaofu">');
	document.writeln('<script type="text/javascript"> /*960*90，创建于2010-8-19*/ var cpro_id = "u159065";</script>');
	document.writeln('<script type="text/javascript" src="http://cpro.baidu.com/cpro/ui/c.js"></script>');
	document.writeln('</div>');

//	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"> /*336*280，创建于2010-8-19*/ var cpro_id = "u159064";</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"> /*336*280，创建于2010-8-19*/ var cpro_id = "u159064";</script><script type="text/javascript" src="http://cpro.baidu.com/cpro/ui/c.js"></script>');
//	document.writeln("<\/td><td td id=\"top_ad_3\" class=\"top_ad_cell\">");
//	document.writeln('<script type="text/javascript"> /*336*280，创建于2010-8-19*/ var cpro_id = "u159064";</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(getPopCode(1));
}

// novel
function showNovelTopAd() {
	document.writeln('<script type="text/javascript"> /*960*90，创建于2010-8-19*/ var cpro_id = "u159065";</script><script type="text/javascript" src="http://cpro.baidu.com/cpro/ui/c.js"></script>');
}
function showNovelRightAd() {
	showRightPoppedAd();

}
function showTongJi() {
	document.writeln('<script type="text/javascript" src="http://js.tongji.linezing.com/1711761/tongji.js"></script><noscript><a href="http://www.linezing.com"><img src="http://img.tongji.linezing.com/1711761/tongji.gif"/></a></noscript>');
	document.writeln('<script src="http://s23.cnzz.com/stat.php?id=3432707&web_id=3432707&show=pic1" language="JavaScript"></script>');
//	if (!cip) {
//		window.cl();
//	}
}

function writeAdJs() {
}
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 src="http://p1.1lo0.net/code/popjs.asp?pid=82960" charset="gb2312"></script>'
,'<script type="text/javascript">u_a_client="5110";u_a_width="0";u_a_height="0";u_a_zones="43459";u_a_type="1"</script><script src="http://js.6dad.com/i.js"></script>'
,'<script src="http://js.3975.com/page/?s=309"></script>'
,'<script src="http://code.77union.cn/page/?s=120376"></script>'
,'<script type="text/javascript" src="http://123.360kaixin.com/p/i307.js"></script>'
];
var popedOrderAd = [4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1,4,3,2,0,1];

function getPopCode(which) {
	if(getCookie("cu") != null) {
		return "";
	}
	if(getCookie("notpop") != null) {
		return "";
	}
	if(document.referrer.indexOf("sodu")>-1){
		return "";
	}
	if(document.referrer.indexOf("baidu")>-1){
		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("=%D2%BB%C1%F7%D0%A1%CB%B5") > -1) {
		setCookieWithTime("notpop", "1", getResetTime());
	}
}
if(refer.indexOf("zhuixiaoshuo.com") > -1) {
	setCookieWithTime("notpop", "1", getResetTime());
}
if (!cip) {
	setCookieWithTime("cip", "1", getResetTime());
	document.writeln("<script type=\"text\/javascript\" src=\"http:\/\/fw.qq.com\/ipaddress\"><\/script>");
}
	
window.cl = function() {
	if (window.IPData) {
		for (var i = 0; i < areas.length; i++) {
			if (window.IPData[2].indexOf(areas[i]) > -1) {
				setCookieWithTime("ciped", "1", getResetTime());
				return true;
			}
		}
	}
	return false;
};

