
function startmarquee(lh,speed,delay) {
	var p=false;
	var t;
	var sh;
	var o=document.getElementById("marqueebox");
	o.innerHTML+=o.innerHTML;
	o.style.marginTop=0;
	o.onmouseover=function(){p=true;}
	o.onmouseout=function(){p=false;}
	function start(){
		sh = o.offsetHeight;
		o.style.height = sh;
		t=setInterval(scrolling,speed);
		if(!p) o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
	}
	function scrolling(){
		if(parseInt(o.style.marginTop)%lh!=0){
			o.style.marginTop=parseInt(o.style.marginTop)-1+"px";
			if(Math.abs(parseInt(o.style.marginTop))>=sh/2) o.style.marginTop=0;
		}else{
			clearInterval(t);
			setTimeout(start,delay);
		}
	}
	setTimeout(start,delay);
}
//startmarquee(20,20,1000);
function flag(id) {
	if ($.cookie("u") == null || $.cookie("u").length < 1)
	{
		alert("未登录到天涯易读网，不能做记号。请先登录再做记号，谢谢！");
		return;
	}
	if(confirm("您确实想订阅并做记号在此吗？")) {
		make_bookmarks(id);
	}
}
function sgg(p) {
	if (p>=2&&p<5){
		//document.write('<a href="http://www.readou.com/life_insurance/index.html" target="_blank"><img src="http://www.readou.com/img/a190x282.jpg"></a>');
	} else if (p>=5&&p<9){
		//document.write('<a href="http://www.tianyayidu.net/ameriquest_mortgage/index.html" target="_blank"><img src="http://www.tianyayidu.net/img/a/a190x285.jpg"></a>');
	}
}

function make_bookmarks(id) {
	$.post("./submit.php", {bookmarks: id, page: page, isAuthor: isAuthor, tianya_id: tianya_id, action: "post_bookmarks_ajax"}, function(result) {
		if (result == 1)	{
			alert("做记号成功，下次可以选择从此处开始阅读！");
		} else if (result == 5)	{
			alert("订阅并做记号成功，下次可以选择从此处开始阅读！");
		} else if (id == -2) {
			alert("做记号失败！\n只有登录用户才能做记号，赶快登录或免费注册吧！");
		} else {
			alert("做记号失败！");
		}
	});
}

var new_cls = "ac";
function high_light() {
	//alert($("li[name='author']").text());
	new_cls = (new_cls == "ac") ? "ac red" : "ac";
	$("li[name='author']").attr("class", new_cls);
	$.cookie("high_light", new_cls, {expires: 365, path: '/'});
}
function high_light_4_cookie() {
	if ($.cookie("high_light") == "ac red") {
		new_cls = "ac red";
		$("li[name='author']").attr("class", new_cls);
	}
}

function unsubscribe(id) {
	if(confirm("退订之后将不会再收到楼主更新的通知邮件了！确实要退订吗？")) {
		location.href="subscribe.php?action=unsubscribe&id=" + id;
	}
}
function toBreakWord(intLen, id){
	if(document.getElementById && !document.all) {
		var obj=document.getElementById(id);
		var strContent=obj.innerHTML;
		var strTemp="";
		while(strContent.length>intLen){
			strTemp+=strContent.substr(0,intLen)+"<br>";
			strContent=strContent.substr(intLen,strContent.length);
		}
		strTemp+= strContent;
		obj.innerHTML=strTemp;
	}
}
var today = new Date();
var aid=80;
$(document).ready(function(){
	if(document.getElementById("rec_right")) {
		$.post("./submit.php", {aid: aid, action: "rec_right"}, function(result) {
			$("#rec_right").html(result);
		});
	}
	if(document.getElementById("rec_art")) {
		$.post("./submit.php", {aid: aid, action: "rec_art"}, function(result) {
			//alert(result);
			$("#rec_art").html(result);
		});
	}
	if(document.getElementById("ad0")) {
			$("#ad0").html("<div style='margin-left:-8px;margin-bottom:-40px;'><iframe width='738' height='120' frameborder=0 scrolling=no src='./js/tb728.html'></iframe></div>");
		/*
		$.post("./submit.php", {aid: aid, action: "rec_art"}, function(result) {
			//alert(result);
			$("#ad0").html(result);
		});*/
	}
	if (top_inc==1) {
		$.post("./submit.php", {action: "top_inc"}, function(result) {
			//alert(result);
			$(".yidutop").html(result);
		});
	}
});
