function cgtab(no) {
	for ( var i = 1; i <= 3; i++) {
		document.getElementById('tab' + i).className = '';
		document.getElementById('cmtListPart' + i).style.display = 'none';
	}
	document.getElementById('tab' + no).className = 'on';
	document.getElementById('cmtListPart' + no).style.display = 'block';
}

function change_opt(obj) {
	this.document.location.href = obj.value;
}
var pre_page, next_page;
function page(evt) {
	var e = evt ? evt : top.window.event;
	if (e.keyCode == 37) {
		pre_page = (pre_page == '#T') ? "/" : pre_page;
		window.location.href = pre_page;
	}
	if (e.keyCode == 39 || e.keyCode == 192) {
		next_page = (next_page == '#T') ? "/" : next_page;
		window.location.href = next_page;
	}
}
var __is_ff = (navigator.userAgent.indexOf("Firefox") != -1);// Firefox
function getEvent() {
	if (document.all)
		return window.event;
	func = getEvent.caller;
	while (func != null) {
		var arg0 = func.arguments[0];
		if (arg0) {
			if ((arg0.constructor == Event || arg0.constructor == MouseEvent)
					|| (typeof (arg0) == "object" && arg0.preventDefault && arg0.stopPropagation)) {
				return arg0;
			}
		}
		func = func.caller;
	}
	return null;
}
function getMouseLocation() {
	e = getEvent();
	var mouseX = 0;
	if (__is_ff) {
		mouseX = e.layerX + document.body.scrollLeft;
	} else {
		mouseX = e.offsetX + document.body.scrollLeft;
	}
	return mouseX;
}
function click_pic(o) {
	var offset_x = getMouseLocation();
	if (offset_x <= o.clientWidth / 2) {
		pre_page = (pre_page == '#T') ? "/" : pre_page;
		window.location.href = pre_page;
	} else {
		next_page = (next_page == '#T') ? "/" : next_page;
		window.location.href = next_page;
	}
}
function change_style(o) {
	var offset_x = getMouseLocation();
	if (offset_x <= o.clientWidth / 2) {
		if (!o.style.cursor.match("pre")) {
			o.style.cursor = "/files/img/pre.cur";// "NW-resize";
		}
	} else if (!o.style.cursor.match("next")) {
		o.style.cursor = "/files/img/next.cur";
	}
	return;
}
function download_next(pic_path) {
	document.getElementById("pix_next_download").src = pic_path;
}
var COOKIE_DAYS = 30;
function getCookieVal(offset) {
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1) {
		endstr = document.cookie.length;
	}
	return unescape(document.cookie.substring(offset, endstr));
}
function setCookie(name, value) {
	var expdate = new Date();
	var argv = setCookie.arguments;
	var argc = setCookie.arguments.length;
	var expires = (argc > 2) ? argv[2] : COOKIE_DAYS * 24 * 3600;
	var path = (argc > 3) ? argv[3] : "/";
	var domain = (argc > 4) ? argv[4] : ".dm72.com";
	var secure = (argc > 5) ? argv[5] : false;
	if (expires != null) {
		expdate.setTime(expdate.getTime() + (expires * 1000));
	}
	document.cookie = name + "=" + escape(value)
			+ ((expires == null) ? "" : ("; expires=" + expdate.toGMTString()))
			+ ((path == null) ? "" : ("; path=" + path))
			+ ((domain == null) ? "" : ("; domain=" + domain))
			+ ((secure == true) ? "; secure" : "");
}
function delCookie(name) {
	var exp = new Date();
	exp.setTime(exp.getTime() - 1);
	var cval = getCookie(name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0)
			break;
	}
	return null;
}
function show_views(id) {
	var manhua_hits = getCookie("auto_comic_browse");
	if (manhua_hits != null) {
		var hits_string = manhua_hits.split("#");
		for (i = 0; i < hits_string.length; i++) {
			var id_info = hits_string[i].split(",");
			if (id_info[0] == id) {
				document.writeln(id_info[1]);
				return false;
				break;
			}
		}
	}
	document.writeln('<script src="/chapter/views/' + id + '" type="text/javascript"></script>');
}