
function bbTicker(parameter) {

	this.ID=""; // ID des Tickers
	this.TickerWidth=100; // Tickerbreite
	this.TickerHeight=100; // Tickerhöhe
	this.TickerPlane=1; // Ausrichtung des Tickers (1=vertical, 2=horizontal)
	this.ScrollSpeed=1; // Tempo scrollen
	this.ScrollStep=1; // Schrittweite scrollen
	this.ScrollBreak=10; // Pause zwischen den Schritten
	this.ScrollTimeout=0; // TimerID für das Scrollen
	this.InfoAuto=true; // automatisch Info-Weiterschaltung
	this.Infos=new Array(); // Inhalte der Infos
	this.InfoNum=0; // Anzahl der Infos
	this.InfoPos=0; // Position des Info-Div's
	this.InfoDimension=0; // Höhe oder Breite eines Info-Div
	this.InfoAllDimension=0; // Höhe oder Breite aller Info-Div
	this.InfoTarget=0; // Position des Info-Div's
	this.InfoBreak=5000; // Dauer der Anzeige
	this.InfoTimeout=0; // TimerID für das automatische Scrollen


	this.SiteUp=function() {
		var obj=this;
		window.clearTimeout(this.ScrollTimeout);
		window.clearTimeout(this.InfoTimeout);
		this.InfoTarget=(Math.floor(this.InfoPos/this.InfoDimension)+1)*this.InfoDimension;
		if(this.InfoTarget>0) this.InfoTarget=0; else this.InfoScroll("up");
		if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteUp(); }, this.InfoBreak);
	}
	
	this.SiteDown=function() {
		var obj=this;
		window.clearTimeout(this.ScrollTimeout);
		window.clearTimeout(this.InfoTimeout);
		this.InfoTarget=(Math.ceil(this.InfoPos/this.InfoDimension)-1)*this.InfoDimension;
		if(this.InfoTarget<(this.TickerHeight-this.InfoAllDimension)) this.InfoTarget=this.TickerHeight-this.InfoAllDimension; else this.InfoScroll("down");
		if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteDown(); }, this.InfoBreak);
	}
	
	this.SiteLeft=function() {
		var obj=this;
		window.clearTimeout(this.ScrollTimeout);
		window.clearTimeout(this.InfoTimeout);
		this.InfoTarget=(Math.floor(this.InfoPos/this.InfoDimension)+1)*this.InfoDimension;
		if(this.InfoTarget>0) this.InfoTarget=0; else this.InfoScroll("left");
		if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteLeft(); }, this.InfoBreak);
	}
	
	this.SiteRight=function() {
		var obj=this;
		window.clearTimeout(this.ScrollTimeout);
		window.clearTimeout(this.InfoTimeout);
		this.InfoTarget=(Math.ceil(this.InfoPos/this.InfoDimension)-1)*this.InfoDimension;
		if(this.InfoTarget<(this.TickerWidth-this.InfoAllDimension)) this.InfoTarget=this.TickerWidth-this.InfoAllDimension; else this.InfoScroll("right");
		if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteRight(); }, this.InfoBreak);
	}
	
	this.SiteRepeatUp=function() {
		this.SiteStop();
		this.InfoTarget=0;
		this.InfoScroll("up");
	}
	
	this.SiteRepeatDown=function() {
		this.SiteStop();
		this.InfoTarget=this.TickerHeight-this.InfoAllDimension;
		this.InfoScroll("down");
	}
	
	this.SiteRepeatLeft=function() {
		this.SiteStop();
		this.InfoTarget=0;
		this.InfoScroll("left");
	}
	
	this.SiteRepeatRight=function() {
		this.SiteStop();
		this.InfoTarget=this.TickerWidth-this.InfoAllDimension;
		this.InfoScroll("right");
	}
	
	this.SiteStop=function() {
		window.clearTimeout(this.ScrollTimeout);
		window.clearTimeout(this.InfoTimeout);
		this.InfoAuto=false;
	}
	
	
	this.InfoScroll=function(direction) {
		var obj=this;
		if(direction=="down") {
			this.InfoPos-=this.ScrollStep;
			if(this.InfoPos < this.InfoTarget) this.InfoPos=this.InfoTarget; else this.ScrollTimeout=window.setTimeout(function () { obj.InfoScroll("down"); }, this.ScrollBreak);
			document.getElementById(this.ID + "_bbcontent").style.top=this.InfoPos + "px";
		}

		if(direction=="up") {
			this.InfoPos+=this.ScrollStep;
			if(this.InfoPos > this.InfoTarget) this.InfoPos=this.InfoTarget; else this.ScrollTimeout=window.setTimeout(function () { obj.InfoScroll("up"); }, this.ScrollBreak);
			document.getElementById(this.ID + "_bbcontent").style.top=this.InfoPos + "px";
		}

		if(direction=="left") {
			this.InfoPos+=this.ScrollStep;
			if(this.InfoPos > this.InfoTarget) this.InfoPos=this.InfoTarget; else this.ScrollTimeout=window.setTimeout(function () { obj.InfoScroll("left"); }, this.ScrollBreak);
			document.getElementById(this.ID + "_bbcontent").style.left=this.InfoPos + "px";
		}

		if(direction=="right") {
			this.InfoPos-=this.ScrollStep;
			if(this.InfoPos < this.InfoTarget) this.InfoPos=this.InfoTarget; else this.ScrollTimeout=window.setTimeout(function () { obj.InfoScroll("right"); }, this.ScrollBreak);
			document.getElementById(this.ID + "_bbcontent").style.left=this.InfoPos + "px";
		}
};



	this.Init=function(parameter) {
		var obj=this;
		this.ID=(parameter.ID)?parameter.ID:"Ticker";
		
		if(!document.getElementById(this.ID)) {
			window.setTimeout(function () { obj.Init(parameter); }, 100);
			return;
		}

		this.TickerWidth=(parameter.Width)?parameter.Width:200;
		this.TickerHeight=(parameter.Height)?parameter.Height:200;
		this.TickerPlane=parameter.Plane;
		this.ScrollStep=parameter.ScrollSpeed/4;
		this.Infos=parameter.Infos;
		this.InfoAuto=parameter.InfoAuto;
		this.InfoNum=this.Infos.length;
		this.InfoBreak=(parameter.InfoBreak)?parameter.InfoBreak:5000;
		this.InfoTarget=0;

		if(this.TickerPlane==1) {
			this.InfoDimension=(parameter.InfoDimension)?parameter.InfoDimension:this.TickerHeight;
			this.InfoAllDimension=this.InfoDimension*this.InfoNum;
			htmlText='<div id="' + this.ID + '_bbcontent" style="position:absolute; top:' + this.TickerHeight + 'px; left:0px; width:' + this.TickerWidth + 'px;">';
			for(var i=0; i<this.InfoNum; i++) htmlText+='<div style="position:absolute; top:' + (i*this.InfoDimension) + 'px; left:0px; width:' + this.TickerWidth + 'px; height:' + this.InfoDimension + 'px; overflow:hidden;">' + this.Infos[i] + '</div>';
			htmlText+='</div>';
			if(this.InfoAuto) this.InfoPos=this.TickerHeight; else this.InfoPos=0;
		}
		
		if(this.TickerPlane==2) {
			this.InfoDimension=(parameter.InfoDimension)?parameter.InfoDimension:this.TickerWidth;
			this.InfoAllDimension=this.InfoDimension*this.InfoNum;
			htmlText='<div id="' + this.ID + '_bbcontent" style="position:absolute; top:0px; left:0px; width:' + this.TickerWidth + 'px;">';
			for(var i=0; i<this.InfoNum; i++) htmlText+='<div style="position:absolute; top:0px; left:' + (i*this.InfoDimension) + 'px; width:' + this.InfoDimension + 'px; height:' + this.TickerHeight + 'px; overflow:hidden;">' + this.Infos[i] + '</div>';
			htmlText+='</div>';
			if(this.InfoAuto) this.InfoPos=this.TickerWidth; else this.InfoPos=0;
		}
		document.getElementById(this.ID).innerHTML=htmlText;
		document.getElementById(this.ID).style.overflow="hidden";
		document.getElementById(this.ID).style.position="relative";
		document.getElementById(this.ID).style.width=this.TickerWidth + "px";
		document.getElementById(this.ID).style.height=this.TickerHeight + "px";

		
		if(this.TickerPlane==1) {
			this.InfoTarget=0;
			document.getElementById(this.ID + "_bbcontent").style.top=this.TickerHeight + "px";

			this.InfoScroll("down");
			if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteDown(); }, this.InfoBreak);

//			if(this.InfoAuto) this.SiteDown();
//			document.getElementById(this.ID + "_bbcontent").style.top=this.InfoPos + "px";
		}
		
		if(this.TickerPlane==2) {
			this.InfoTarget=0;
			document.getElementById(this.ID + "_bbcontent").style.left=this.TickerWidth + "px";
			this.InfoScroll("right");
			if(this.InfoAuto) this.InfoTimeout=window.setTimeout(function () { obj.SiteRight(); }, this.InfoBreak);

//			if(this.InfoAuto) this.SiteRight();
//			document.getElementById(this.ID + "_bbcontent").style.left=this.InfoPos + "px";
		}
		
	};


	this.Init(parameter);
}


