/*
插件名称：论坛公告调用垂直滚动更新版(V2.0) For Dvbbs7.x
更新日期：2005-03-29
插件作者：stardy(斯大里) http://www.stardy.com
调用方法：<Script Language=Javascript Src="DV_Plus/StardyJs/Std_loadNews.Js"></Script>
*/
function news_create()
{
	//参数设置
	this.speed = 10								//滚动快慢(越小滚动越快)
	this.stayTime = 3							//停留时间(秒，可写小数)
	this.record = 3								//滚动数目，填0不限制
	this.num = 1	 							//可见行数，填数字
	this.height = 19							//每行高度(px)
	//未载入公告时显示的欢迎语支持HTML
	this.welcome = '欢迎您！这里是『'+document.title+'』正在载入公告，请稍候...'
	this.delaytime = 1							//欢迎语显示时间
	this.newscolor = ["#000","#00f"]			//链接字体颜色(首页颜色和非首页颜色)
	this.id = "ScrollnewsTable"					//滚动对象唯一标识
	//参数设置End
	this.startTop = 0
	this.objectTop = this.num*this.height
	this.stopTime = 0
	this.stopScroll = false
	this.objectHeight = this.num*this.height + 1
	this.url = self.location.search.toLowerCase()
	var re = /(.*)[\?|\&]boardid\=(\d)/i
	if(re.test(this.url))this.boardid = this.url.replace(re,"$2")
	else this.boardid = 0
	this.color = this.newscolor[this.boardid?1:0]
	if(this.color!="")this.color=' style="color:'+this.color+'" '
	this.text = new Array()
	this.text[0]=this.welcome
	for(var i=1;i<=this.record;i++)
		this.text[i]="&nbsp;"
	this.start = news_init
	this.process = news_makeTable
	this.loadnews = news_load
	this.getReady = news_getReady
	this.srcollit = news_Scroll
}
function news_init()
{
	var s='<div onmouseover="bbsnews.stopScroll=true" onmouseout="bbsnews.stopScroll=false"'
	s+='oncontextmenu=return(false) id="'+this.id+'" style="overflow-y:hidden;width:100%;'
	s+='height:'+(this.height*this.num)+'px;font-weight:100" align=left>'
	//s+='<marquee onmouseover=this.stop() onmouseout=this.start() direction="right" behavior="alternate">'
	s+=this.text[0]
	//s+='</marquee>'
	s+='</div>'
	document.write(s)
	this.object=document.getElementById(this.id)
	if(this.object)setTimeout("bbsnews.loadnews()",this.delaytime*1000)
}
function news_makeTable()
{
	s=""
	for(var i=0;i<=this.record;i++)
		s+='<div '+this.color+'align=center style="font-weight:800;height:'+this.height+'px;width:100%;">'+this.text[i]+'</div>'
	return s
}
function news_load()
{
	this.xml_news = new ActiveXObject("Microsoft.XMLDOM")
	this.xml_news.async = true
	this.xml_news.onreadystatechange = this.getReady
	this.xml_news.load("Std_News.asp?num="+this.record+"&boardid="+this.boardid)
}
function news_getReady()
{
	if(bbsnews.xml_news.readyState!=4)return
	if(bbsnews.xml_news.parseError.errorCode!=0)
	{
		delete(bbsnews.xml_news)
		bbsnews.object.innerHTML="对不起，xml公告加载出错！可能Std_News.asp文件丢失或无效！"
		return
	}
	bbsnews.text = new Array()
	bbsnews.record = bbsnews.xml_news.getElementsByTagName("news").length  //检索的记录数
	for (var i=0;i<bbsnews.record;i++){
		var title = bbsnews.xml_news.getElementsByTagName("newstitle").item(i).text
		var url = bbsnews.xml_news.getElementsByTagName("url").item(i).text
		var admin = bbsnews.xml_news.getElementsByTagName("writter").item(i).text
		var posttime = bbsnews.xml_news.getElementsByTagName("time").item(i).text
		if(admin!="")admin=' title="发布人：'+admin+'"'
		if(posttime=="")title+="(单击查看说明)"
		else posttime=" ("+posttime+")"
		bbsnews.text[i] ='<font color="#FF0000"><span>本站公告：</span></font> '
		bbsnews.text[i]+='<a '+bbsnews.color+admin+' href=javascript:openScript("'+url+'",500,400)>'+title+'</a>'+posttime
		if(bbsnews.record>bbsnews.num&&i==bbsnews.record-1)bbsnews.text[bbsnews.record]=bbsnews.text[0]
	}
	bbsnews.record = bbsnews.text.length-1
	bbsnews.object.innerHTML = bbsnews.process()
	delete(bbsnews.xml_news)
	if(bbsnews.record<=bbsnews.num)return;
	bbsnews.object.scrollTop = 0
	bbsnews.ievent=window.setInterval("bbsnews.srcollit()",bbsnews.speed)
}
function news_Scroll(){
	if(this.stopScroll==true){this.stopTime=0;return;}
	this.objectTop++
	if(this.objectTop>this.objectHeight)
	{
		if(this.stopTime*this.speed>this.stayTime*1000){this.objectTop=0 ; 	this.stopTime=0}
		else this.stopTime++
		} 
	else 
	{
		this.startTop++
		this.object.scrollTop = this.startTop
		if(this.startTop>=this.record*(1+this.height))this.startTop=0
 	}
}
var bbsnews = new news_create()
bbsnews.start()

