
lstart=165;
loop=true;
speed=50;
pr_step=1;
timerID=0;
f_clicks=0;
r_clicks=0;

function makeNewsObj(obj,nest)
{
    nest=(!nest) ? '':'document.'+nest+'.';
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
	if(this.el){
		this.isObject = true;
		this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
		this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight;
		this.newsScroll=newsScroll;
		this.newsScrollRev=newsScrollRev;
		this.moveIt=b_moveIt; this.x; this.y;
		this.dir="forward";
		this.obj = obj + "Object";
		eval(this.obj + "=this");
		return this;
	} else {
		return this.isObject = false;
	}
}

function b_moveIt(x,y)
{
	this.x=x;this.y=y;
	this.css.left=this.x;
	this.css.top=this.y;
}

function newsScroll(speed)
{
	if(this.y > -this.scrollHeight){
		this.moveIt(0,this.y-pr_step);
		timerID=setTimeout(this.obj+".newsScroll("+speed+")",speed);
	}else if(loop) {
		this.moveIt(0,lstart);
		eval(this.obj+".newsScroll("+speed+")");
	  }
}

function newsScrollRev(speed)
{
	if(this.y < lstart){
		this.moveIt(0,this.y + pr_step);
		timerID=setTimeout(this.obj+".newsScrollRev("+speed+")",speed);
	}else if(loop) {
		this.moveIt(0,-this.scrollHeight);
		eval(this.obj+".newsScrollRev("+speed+")");
	  }
}

function newsScrollInit()
{
	oNewsCont=new makeNewsObj('divNewsCont');
	
	if (oNewsCont.isObject){
		oNewsScroll=new makeNewsObj('divNewsText','divNewsCont');
		oNewsScroll.moveIt(0,lstart);
		oNewsCont.css.visibility='visible';
		oNewsScroll.newsScroll(speed);
		
		if ((!document.all) && (document.getElementById))
		{
			oNewsScroll.el.setAttribute("onmouseover", "pauseScroll()");
			oNewsScroll.el.setAttribute("onmouseout", "resumeScroll()");
		}
		//workaround for IE 5.x
		if ((document.all) && (document.getElementById))
		{
			oNewsScroll.el.attachEvent("onmouseover", pauseScroll);
			oNewsScroll.el.attachEvent("onmouseout", resumeScroll);
		}
	}

	// re-position the inviters content under the news

	/*
	oInviters=new makeNewsObj('divInviters');

	if (oInviters.isObject && oNewsCont.isObject)
	{
		oInviters.el.setAttribute("className", "divInvitersWithNews", 0);
		oInviters.el.setAttribute("class", "divInvitersWithNews", 0);
	}
	*/
}

function pauseScroll()
{
	clearTimeout(timerID);
}

function resumeScroll()
{
	if (oNewsScroll.dir=="forward")
	{
		oNewsScroll.newsScroll(speed);
	}
	else
	{
		oNewsScroll.newsScrollRev(speed);
	}
}

function scrollForward()
{
	r_clicks=0;
	f_clicks++;
	pr_step=f_clicks;
	oNewsScroll.dir="forward";
	clearTimeout(timerID);
	oNewsScroll.newsScroll(speed);
}

function scrollRev()
{
	f_clicks=0;
	r_clicks++;
	pr_step=r_clicks;
	oNewsScroll.dir="reverse";
	clearTimeout(timerID);
	oNewsScroll.newsScrollRev(speed);
}

onload=newsScrollInit;
