function newsticker(){

	var scrollerspeed; //velocida com que o boxScroll rola;
	var barraSpeed; //velocida com que a barra de rolagem mexe, proporcional ao scrollerspeed;
	var boxScroll; //div com position absolute que contem o texto a mexer
	var scrollerheight; //altura do containner do box Scroll
	var barraScroll; //div com position absolute que contem a barra de rolagem
	var barraHeight; //altura do containner da BarraScroll
	var actualheight; //tamanho do newsticker dinamico
	var MaxScroller; // Tamanho maximo a subir antes da repetição
	var obj;
	var autotimer;

	this.Scroll = function(boxScroll, barraScroll, scrollerheight, barraHeight, obj){
		this.boxScroll = document.getElementById(boxScroll);
		this.barraScroll = document.getElementById(barraScroll);
		this.barraHeight = barraHeight;
		this.scrollerheight = scrollerheight;
		this.scrollerspeed = 4;
		this.actualheight = this.boxScroll.offsetHeight;
		this.MaxScroller = parseInt(this.actualheight/2)// + this.scrollerheight;
		//alert(parseInt(this.actualheight)+"/2"+this.scrollerheight);
		this.boxScroll.style.top = "0px";
		this.barraScroll.style.height = this.barraHeight+"px";
		this.showBarra();
		this.obj = obj;
		this.scroll_auto();
	}

	this.scroll_up = function(mouseover){
		if(mouseover){
			//clearInterval(this.autotimer);
			lefttime = eval("setInterval('"+this.obj+".scrollscroller(false)',20)")
		}
		else{
			clearInterval(lefttime);
			this.scroll_auto();
		}
	}

	this.scroll_down = function(mouseover){
		if(mouseover){
			//clearInterval(this.autotimer);
			lefttime = eval("setInterval('"+this.obj+".scrollscroller(true)',20)")
		}
		else{
			clearInterval(lefttime);
			this.scroll_auto();
		}
	}

	this.pause = function(){
		clearInterval(this.autotimer);
	}

	this.scroll_auto = function(){
		//this.autotimer = eval("setInterval('"+this.obj+".scrollscroller(true)',200)");
	}

	this.scrollscroller = function(up){
		//alert("("+scrollerspeed+"*"+(barraHeight-barraNoticia.offsetHeight)+")/("+(actualheight-scrollerheight)+") = "+((scrollerspeed * (barraHeight-barraNoticia.offsetHeight))/(actualheight-scrollerheight)))
		if(up){ //subindo
			//if (parseInt(this.boxScroll.style.top)>((this.actualheight-this.scrollerheight)*-1)){
			//console.debug("",(parseInt(this.boxScroll.style.top) > (this.MaxScroller*-1)));
			//console.debug("",parseInt(this.boxScroll.style.top))
			//console.debug("",(this.MaxScroller*-1));
			if (parseInt(this.boxScroll.style.top) > (this.MaxScroller*(-1))){
				this.boxScroll.style.top = parseInt(this.boxScroll.style.top)-this.scrollerspeed+"px";
				if(parseInt(this.barraScroll.style.top) < (this.barraHeight - parseInt(this.barraScroll.offsetHeight))) //para a barra
					this.barraScroll.style.top = (parseInt(this.barraScroll.style.top) + this.barraSpeed) +"px"
			}
			else{
				this.boxScroll.style.top = "-4px";
				this.barraScroll.style.top = "0px";
			}
		}
		else{ //descendo
			if (parseInt(this.boxScroll.style.top)<0){
				this.boxScroll.style.top=parseInt(this.boxScroll.style.top)+this.scrollerspeed+"px"
				if(parseInt(this.barraScroll.style.top) > 0)//para a barra
					this.barraScroll.style.top = parseInt(this.barraScroll.style.top) - this.barraSpeed +"px";
			}
		}
	}

	/** /
	this.showBarra = function(){
		percent = ((this.scrollerheight*100)/this.actualheight)/100;
		this.barraScroll.style.height = (Math.round(this.barraHeight*percent))+"px";
		//this.barraScroll.style.top = (this.barraHeight - parseInt(this.barraScroll.offsetHeight)) + "px";
		this.barraScroll.style.top = "0px";
		this.barraSpeed = ""+((this.scrollerspeed * (this.barraHeight-this.barraScroll.offsetHeight))/(this.actualheight-this.scrollerheight));
		//alert("("+this.scrollerspeed+"*"+(this.barraHeight-this.barraScroll.offsetHeight)+")/("+(this.actualheight-this.scrollerheight)+") = "+((this.scrollerspeed * (this.barraHeight-this.barraScroll.offsetHeight))/(this.actualheight-this.scrollerheight)))
		decimal = this.barraSpeed.split(".");
		this.barraSpeed = parseInt(decimal[0]) + 1;
	}
	/**/

	this.showBarra = function(){
		this.barraScroll.style.height = 9+"px";
		this.barraScroll.style.top = "0px";
		x = (parseInt(this.actualheight)/2);// - this.scrollerheight; //
		y = this.barraHeight - parseInt(this.barraScroll.offsetHeight);
		Vx = this.scrollerspeed;
		speed = (Vx*y)/x;
		//alert(speed+"/"+y+" = "+Vx+" / "+x);
		this.barraSpeed = ""+speed;

		/* ROUND */
		decimal = this.barraSpeed.split(".");
		dec = ""+decimal[1];
		//alert(parseInt(dec.charAt(0)))
		this.barraSpeed = (parseInt(dec.charAt(0)) > 5)?(parseInt(decimal[0])+1):parseInt(decimal[0]);
		//alert(this.barraSpeed);
		//this.barraSpeed = parseInt(decimal[0]) + 1;
	}
}
