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;

	this.Scroll = function(boxScroll, scrollerheight, obj){
		this.boxScroll = document.getElementById(boxScroll);
		//this.barraScroll = document.getElementById(barraScroll);
		//this.barraHeight = barraHeight;
		this.scrollerheight = scrollerheight;
		this.scrollerspeed = 1;
		this.actualheight = this.boxScroll.offsetHeight;
		this.boxScroll.style.top = "0px";
		this.MaxScroller = parseInt(this.actualheight/2)// + this.scrollerheight;
		//this.barraScroll.style.height = this.barraHeight+"px";
		//this.showBarra();
		this.obj = obj
		this.scroll_auto(true);
	}

	
	this.scroll_auto = function(mode){
		if(mode)
			this.autotimer = eval("setInterval('"+this.obj+".scrollscroller(true)',20)");
		else
			clearInterval(this.autotimer);
	}
	
	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.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;
	}
}
