﻿function BYMarquee(){
	this.Content = [];	//显示内容
	this.Speed = 20;	//上移速度
	this.Object = {};	//marquee容器对象
	this.Pause = true;	//是否停留
	this.Start = function(){
		var o = this.Object;
		var Pause = this.Pause;
		var Stop = false;
		var Stop2 = false;
		o.onmouseover = function(){
			Stop = Stop2 = true;
		}
		o.onmouseout = function(){
			Stop = Stop2 = false;
		}
		var BodyHtml = [];
		var n=this.Content.length;			
		for(var i=0;i<n;i++)
		{
		   if(this.Content[i].text.length>40)
		     BodyHtml.push("<a href=\"" + this.Content[i].link + "\">[推荐]：" + this.Content[i].text.substr(0,40)+"..." + "</a>");
		   else
		     BodyHtml.push("<a href=\"" + this.Content[i].link + "\">[推荐]：" + this.Content[i].text+ "</a>");

		}			
		var Dv = document.createElement("div");
		Dv.innerHTML = BodyHtml.join("<br />");
		o.appendChild(Dv);
		var DvHeight = Dv.offsetHeight;
		
		while(Dv.offsetHeight / 2 < o.offsetHeight){
		  
			Dv.innerHTML += "<br />" + Dv.innerHTML;
		}
		
		Dv.innerHTML += "<br />" + Dv.innerHTML;
		
		setInterval(function(){
		   
			if(!Stop){
				o.scrollTop ++;
				if(o.scrollTop == o.scrollHeight - o.offsetHeight){
					o.scrollTop = DvHeight - o.offsetHeight;
				}			
				if(Pause){
					if(o.scrollTop % o.offsetHeight == 0){
						Stop = true;
						setTimeout(function(){
							Stop = Stop2;
						}, 5000);
					}
				}
			}
		}, this.Speed);
	}
}

function adjustrelease(postid,type)
{
    _sendRequest('tools/blogajax.aspx?t=retype&type='+type+'&postid='+postid,handleResult,false,false);
}

function handleResult(result)
{
   if(result=='1')
   {
       alert("成功");
   }else
   {
       alert("失败");
   }   
}
function recommendarticle(postid)
{
   _sendRequest('tools/blogajax.aspx?t=recommend&postid='+postid,handleResult,false,false);
}