/***********************************
*  http://news-scroller.vbarsan.com/
*   This notice may not be removed 
***********************************/

// obj=instansiated object name; text=array of strings
function eventscroller(obj, w, h, s, p, bgcolor, data) {

this.obj = obj;	// this object name
this.data = data;

//-- Begin Scroller's Parameters and messages -->
//scroller's width
this.swidth=w;

//scroller's height
this.sheight=h;

//scroller's speed 
this.sspeed=s;
this.restart=this.sspeed;
this.rspeed=this.sspeed;
this.gspeed=this.sspeed;
//scroller's pause 
this.spause=p;
this.gpause=p;

//scroller's background
this.sbcolor=bgcolor;

this.center = true;

//-- begin: Scroller's Algorithm -->
this.ii=0;
var gekso=0;
if(navigator.product&&navigator.product=="Gecko"){
	var agt = navigator.userAgent.toLowerCase();
	var rvStart = agt.indexOf('rv:');
	var rvEnd = agt.indexOf(')', rvStart);
	var check15 = agt.substring(rvStart+3, rvEnd);
	if(parseFloat(check15)<1.8)
		gekso=1;
}
var operbr=0;
operbr=navigator.userAgent.toLowerCase().indexOf('opera');

this.goup = function(){
	if(this.sspeed!=rspeed*16){
		this.sspeed=this.sspeed*2;
		this.restart=this.sspeed;
	}
};
this.loaddata = function(){
	speed = (this.data[this.ii].speed?this.data[this.ii].speed:this.gspeed);
	if ( this.sspeed != 0 )
		this.sspeed = speed;
	this.restart=speed;
	this.spause = (this.data[this.ii].pause?this.data[this.ii].pause:this.gpause);
	this.rspeed=speed;
	this.singletext=data[this.ii].text;
};

this.start = function(){
	this.loaddata();
	if(document.getElementById){
		this.ns6div=document.getElementById(''+this.obj+'_iens6div');
		if(operbr!=-1)
			this.operdiv=document.getElementById(''+this.obj+'_operaslider');

		this.ns6div.style.left=this.swidth+"px";
		this.ns6div.innerHTML=this.singletext;
		this.sizeup=this.ns6div.offsetWidth;
		if(operbr!=-1&&this.sizeup==this.swidth){
			this.operdiv.innerHTML=this.singletext;
			this.sizeup=this.operdiv.offsetWidth;
		}
		this.ns6scroll();
	}
	else if(document.layers){
		this.ns4layer=eval('document.'+this.obj+'_ns4div.document.'+this.obj+'_ns4div1');
		this.ns4layer.left=this.swidth;
		this.ns4layer.document.write(this.singletext);
		this.ns4layer.document.close();
		this.sizeup=this.ns4layer.document.width;
		this.ns4scroll();
	}
	else if(document.all){
		this.iediv=eval(''+this.obj+'_iens6div');
		this.iediv.style.pixelLeft=this.swidth+"px";
		this.iediv.innerHTML=this.singletext;
		this.sizeup=this.iediv.offsetWidth;
		this.iescroll();
	}
};

this.iescroll = function(){
	stoppos = parseInt((this.swidth-this.iediv.offsetWidth)/2);
	if(this.iediv.style.pixelLeft>stoppos&&this.iediv.style.pixelLeft<=(stoppos+this.sspeed)){
		this.iediv.style.pixelLeft=0;
		this.iescrollTimeout(this.spause);
	}
	else if(this.iediv.style.pixelLeft>=this.sizeup*-1){
		this.iediv.style.pixelLeft-=this.sspeed+"px";
		this.iescrollTimeout(17);
	}
	else{
		if(this.ii==this.data.length-1)
			this.ii=0;
		else
			this.ii++;
		this.loaddata();
		this.iediv.style.pixelLeft=this.swidth+"px";
		this.iediv.innerHTML=this.singletext;
		this.sizeup=this.iediv.offsetWidth;
		this.iescroll();
	}
};

this.ns4scroll = function(){
	stoppos = parseInt((this.swidth-this.ns4layer.document.width)/2);
	if(this.ns4layer.left>stoppos&&this.ns4layer.left<=(stoppos+this.sspeed)){
		this.ns4layer.left=0;
		this.ns4scrollTimeout(this.spause);
	}
	else if(this.ns4layer.left>=this.sizeup*-1){
		this.ns4layer.left-=this.sspeed;
		this.ns4scrollTimeout(17);
	}
	else{
		if(this.ii==this.data.length-1)
			this.ii=0;
		else this.ii++;
		this.loaddata();
		this.ns4layer.left=this.swidth;
		this.ns4layer.document.write(this.singletext);
		this.ns4layer.document.close();
		this.sizeup=this.ns4layer.document.width;
		this.ns4scroll();
	}
};

this.ns6scroll = function(){
	stoppos = parseInt((this.swidth-this.ns6div.offsetWidth)/2);
	if(parseInt(this.ns6div.style.left)>stoppos&&parseInt(this.ns6div.style.left)<=(stoppos+this.sspeed)){
		this.ns6div.style.left=stoppos+"px";
		this.ns6scrollTimeout(this.spause);
	}
	else if(parseInt(this.ns6div.style.left)>=this.sizeup*-1){
		this.ns6div.style.left=parseInt(this.ns6div.style.left)-this.sspeed+"px";
		this.ns6scrollTimeout(17);	// approx 60fps increments for sspeed...
	}
	else{
		if(this.ii==this.data.length-1)
			this.ii=0;
		else
			this.ii++;
		this.loaddata();
		this.ns6div.style.left=this.swidth+"px";
		this.ns6div.innerHTML=this.singletext;
		this.sizeup=this.ns6div.offsetWidth;
		if(operbr!=-1&&this.sizeup==this.swidth){
			this.operdiv.innerHTML=this.singletext;
			this.sizeup=this.operdiv.offsetWidth;
		}
		this.ns6scroll();
	}
};
//-- end Algorithm -->

this.iescrollTimeout = function(ms) {
	var _self = this;
	setTimeout(function(ms){
		_self.iescroll();
	}, ms);
};
this.ns4scrollTimeout = function(ms) {
	var _self = this;
	setTimeout(function(ms){
		_self.ns4scroll();
	}, ms);
};
this.ns6scrollTimeout = function(ms) {
	var _self = this;
	setTimeout(function(ms){
		_self.ns6scroll();
	}, ms);
};


this.embed = function() {
	document.write('<table align="center" border="0" cellpadding="0" cellspacing="0" class="newstable"><tr>');document.write('<td style="width="'+this.swidth+'px">');
	if(document.layers){document.write('<ilayer id="'+this.obj+'_ns4div" width="'+this.swidth+'" height="'+this.sheight+'" bgcolor='+this.sbcolor+'><layer id="'+this.obj+'_ns4div1" width="'+this.swidth+'" height="'+this.sheight+'" onmouseover="'+this.obj+'.sspeed=0;" onmouseout="'+this.obj+'.sspeed='+this.obj+'.restart"></layer></ilayer>')}
	if(document.getElementById||document.all){document.write('<div style="position:relative;overflow:hidden;width:'+this.swidth+'px;height:'+this.sheight+'px;clip:rect(0 '+this.swidth+'px '+this.sheight+'px 0);background-color:'+this.sbcolor+';" onmouseover="'+this.obj+'.sspeed=0;" onmouseout="'+this.obj+'.sspeed='+this.obj+'.restart">');if(gekso==0&&operbr==-1)document.write('<div id="'+this.obj+'_iens6div" style="position:absolute;height:'+this.sheight+'px;"></div></div>');else 
	document.write('<div id="'+this.obj+'_iens6div" style="position:relative;height:'+this.sheight+'px;"></div><div id="'+this.obj+'_operaslider" style="position:absolute;visibility:hidden;"></div></div>');}
	document.write('</td></tr></table>');
};

}