﻿function grf_fx_txt(idbase){
	var Elementi=new Array()
	var tempo=new Date().getTime()
	this.cartellaImmagini=""
	var This=this
	setInterval(Esecuzione,16)
	
	this.generaScroller = function(idCollegato){
		document.getElementById(idCollegato).onscroll=SuScroll
		document.getElementById(idCollegato).style.overflow='hidden'
		var idFsu=idbase+'_'+idCollegato+'_txt_frSu'
		var idFgiu=idbase+'_'+idCollegato+'_txt_frGiu'
		document.write('<img alt="" src="'+This.cartellaImmagini+'frSu.gif" style="position:absolute;border:0px;width:19px" id="'+idFsu+'" />')
		document.write('<img alt="" src="'+This.cartellaImmagini+'frGiu.gif" style="position:absolute;border:0px;width:19px" id="'+idFgiu+'" />')
		setTimeout('document.getElementById("'+idFgiu+'").style.top=document.getElementById("'+idFgiu+'").parentNode.offsetHeight-document.getElementById("'+idFgiu+'").offsetHeight',20)
		document.getElementById(idFgiu).onmouseover=ScrollaGiu
		document.getElementById(idFgiu).onmouseout=ScrollaGiu_stop
		document.getElementById(idFsu).onmouseover=ScrollaSu
		document.getElementById(idFsu).onmouseout=ScrollaSu_stop
		Elementi[idFgiu]=new Elemento(idFgiu,idCollegato)
		Elementi[idFsu]=new Elemento(idFsu,idCollegato)
		Elementi[idCollegato]=new Elemento(idCollegato)
		Elementi[idCollegato].idCollegati[0]=idFsu
		Elementi[idCollegato].idCollegati[1]=idFgiu
		Elementi[idCollegato].Scorrimento=-1
		function ScrollaGiu(){
			Elementi[Elementi[this.id].idCollegati[0]].Scorrimento=1
			this.src=This.cartellaImmagini+'frGiu2.gif'
		}
		function ScrollaSu(){
			Elementi[Elementi[this.id].idCollegati[0]].Scorrimento=-1
			this.src=This.cartellaImmagini+'frSu2.gif'
		}
		function ScrollaGiu_stop(){
			Elementi[Elementi[this.id].idCollegati[0]].Scorrimento=0
			this.src=This.cartellaImmagini+'frGiu.gif'
		}
		function ScrollaSu_stop(){
			Elementi[Elementi[this.id].idCollegati[0]].Scorrimento=0
			this.src=This.cartellaImmagini+'frSu.gif'
		}
	}
	
	function SuScroll(){


		
	}
		
	function Esecuzione(){
		var diff=new Date().getTime()-tempo
		tempo=new Date().getTime()
		for(e in Elementi){
			if(Elementi[e].Scorrimento!=0){
				document.getElementById(Elementi[e].id).scrollTop+=Math.round(Elementi[e].Scorrimento*diff/100)+Elementi[e].Scorrimento
				if(document.getElementById(Elementi[e].id).scrollTop==0){
					document.getElementById(Elementi[e].idCollegati[0]).style.visibility='hidden'
					Elementi[e].Scorrimento=0
				}else{document.getElementById(Elementi[e].idCollegati[0]).style.visibility='visible'}
				if(document.getElementById(Elementi[e].id).scrollTop+document.getElementById(Elementi[e].id).offsetHeight>=document.getElementById(Elementi[e].id).scrollHeight){
					document.getElementById(Elementi[e].idCollegati[1]).style.visibility='hidden'
					Elementi[e].Scorrimento=0
				}else{document.getElementById(Elementi[e].idCollegati[1]).style.visibility='visible'}
			}
		}
	}
	
	function Elemento(id,idCollegato){
		this.Scorrimento=0
		this.id=id
		this.idCollegati=new Array()
		this.idCollegati[0]=idCollegato
	}
}

