
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 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 (result == -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 isvote=false;
function vote(id,divid) {
	if (typeof(divid)=="undefined"){
		divid = "#mark_prompt_art";
	}
	//$(divid).show();$(divid).fadeIn(10);
	if (isvote) {
		$(divid).html('请不要重复提交！');
		$(divid).fadeOut(2000);
		return;
	}
	//$(divid).html('正在提交...');
		msgwin('dddddddddddd', 2000, 'mark_prompt_art');
	/*
	$.post("./submit.php", {tianya_id: id, action: "post_vote_ajax"}, function(result) {
		if (result == -2) {
			$(divid).html('登录才能推荐帖子，请先登录！');
		} else {
			$(divid).html(result);
		}
		$(divid).fadeOut(5000);
	});
	*/
	isvote=true;
}
function msgwin(s, t, id) {	
	var msgWinObj = document.getElementById(id);
	if(!msgWinObj) {
		var msgWinObj = document.createElement("div");
		msgWinObj.id = id;
		msgWinObj.style.display = 'none';
		msgWinObj.style.position = 'absolute';
		msgWinObj.style.zIndex = '100000';
		$('append_parent').appendChild(msgWinObj);
	}
	msgWinObj.innerHTML = s;
	msgWinObj.style.display = '';
	msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)';
	msgWinObj.style.opacity = 0;
	var sTop = document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop;
	pbegin = sTop + (document.documentElement.clientHeight / 2);
	pend = sTop + (document.documentElement.clientHeight / 5);
	setTimeout(function () {showmsgwin(pbegin, pend, 0, t, id)}, 10);
	msgWinObj.style.left = ((document.documentElement.clientWidth - msgWinObj.clientWidth) / 2) + 'px';
	msgWinObj.style.top = pbegin + 'px';
}
function showmsgwin(b, e, a, t, id) {
	step = (b - e) / 10;
	var msgWinObj = document.getElementById(id);
	newp = (parseInt(msgWinObj.style.top) - step);
	if(newp > e) {
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + a + ')';
		msgWinObj.style.opacity = a / 100;
		msgWinObj.style.top = newp + 'px';
		setTimeout(function () {showmsgwin(b, e, a += 10, t, id)}, 10);
	} else {
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		msgWinObj.style.opacity = 1;
		setTimeout('displayOpacity(\''+id+'\', 100)', t, id);
	}
}
function displayOpacity(id, n) {
	var msgWinObj = document.getElementById(id);
	if(!msgWinObj) {
		return;
	}
	if(n >= 0) {
		n -= 10;
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + n + ')';
		msgWinObj.style.opacity = n / 100;
		setTimeout('displayOpacity(\'' + id + '\',' + n + ')', 50);
	} else {
		msgWinObj.style.display = 'none';
		msgWinObj.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=100)';
		msgWinObj.style.opacity = 1;
	}
}

var tyurl=document.getElementById('tyurl');durl='http://www.tianya.cn/publicforum/content/funinfo/1/2039425.shtml';
function clk() {
tyurl=document.getElementById('tyurl');
if (tyurl.value==durl){
	tyurl.value='';
	tyurl.style.color='#000';
}
}
function ob() {
tyurl=document.getElementById('tyurl');
if (tyurl.value==''){
	tyurl.value=durl;
	tyurl.style.color='#999';
}
}
$(document).ready(function(){
	tyurl=document.getElementById('tyurl');tyurl.value=durl;
})
