function timer_class()
{this.arr=new Array();
this.addRef =	timer_class_addRef;
this.addClassRef =	timer_class_addClassRef;
this.setInterval =	timer_class_setInterval;
this.setFunzione =  timer_class_setFunzione;
this.startInterval =timer_class_startInterval;
this.clearInterval=timer_class_clearInterval;
this.esegui_azione=  timer_class_esegui_azione;
this.trova = timer_class_trova;	}

function timer_class_addRef(valore)
{
if(valore==undefined) valore= null;
this.arr.push(new Array(null,null,-1,valore,0));
return this.arr.length-1;
	}
function timer_class_addClassRef(rif_istanza,valore)
{
if(rif_istanza==undefined) rif_istanza= null;
if(valore==undefined) valore= null;
this.arr.push(new Array(rif_istanza,null,-1,valore,0));
return this.arr.length-1;
	}
function timer_class_setInterval(ist,funz,intervallo,valore)
{
if(ist>=0 && ist <this.arr.length)
	{	if(this.arr[ist][2]!=-1) clearInterval(this.arr[ist][2]);
	this.arr[ist][1]=funz;
	if(this.arr[ist][0] != null) this.arr[ist][0].timer_class_azione = funz;
	if(intervallo != undefined && intervallo != null) this.arr[ist][4]=intervallo;
	if(valore!=undefined) this.arr[ist][3]=valore;
	return this.arr[ist][2]=setInterval("qtimer.esegui_azione("+ist+")",this.arr[ist][4]);
		}

	}
function timer_class_startInterval(ist)
{
if(ist>=0 && ist <this.arr.length && this.arr[ist][1]!=null)
	{
	if(this.arr[ist][2]!=-1) clearInterval(this.arr[ist][2]);
	return this.arr[ist][2]=setInterval("qtimer.esegui_azione("+ist+")",this.arr[ist][4]);
		}

	}
function timer_class_clearInterval(pos)
{
if(pos>=0 && pos <this.arr.length)
	{
	clearInterval(this.arr[pos][2])
    this.arr[pos][2]=-1;
		}

	}
function timer_class_esegui_azione(pos)
{var p,f;
if(pos>=0 && pos < this.arr.length && (f=this.arr[pos][1]) != null)
	{	if(this.arr[pos][0] != null) this.arr[pos][0].timer_class_azione(this.arr[pos][3]);	else f(this.arr[pos][3]);		}
	}
function timer_class_setFunzione(pos,funz,intervallo,valore)
{
if(pos>=0 && pos <this.arr.length)
	{	if(funz != null)
		{		this.arr[pos][1]=funz;
		if(this.arr[pos][0] != null) this.arr[pos][0].timer_class_azione = funz;
		}
	if(intervallo != undefined && intervallo != null) this.arr[pos][4]=intervallo;
	if(valore != undefined) this.arr[pos][3]=valore;
		}
	}

function timer_class_trova(rif_istanza)
{
 for (var n=0; n< this.arr.length;n++)
 	if( rif_istanza == this.arr[n][0]) return n;
 return -1;
	}

function document_class()
	{	this.tipo=0;
	this.ObjById;
	this.ImgByName=null;
	this.All=_GetObjAll;
	this.stipo="none";
if(document.all)
	{
	this.tipo=1;
	this.ObjById=_ObjById;
	this.stipo="all ";
	}
else if(document.getElementById)
		{
			this.tipo=2;
			this.ObjById=_ObjById;
			this.stipo="getElementById ";
			}
	else alert("Browser non compatibile!");


if(document.images)
			{
			this.ImgByName=_ImgByName;
			this.stipo+="ImgByName ";
			}

else
	{		this.ImgByName=document.getElementById;
  		this.stipo+="getElementById ";
  		}

	}

	function  _ObjById(id) { return this.tipo==1?document.all[id]:document.getElementById(id); }
	function  _ImgByName(id) { return document.images[id]; }
	function  _GetObjAll(id)
		{		var obj = this.ObjById(id);
		if(obj== undefined)
			 obj = this.ImgByName(id);
		if(obj== undefined)
			alert("L'oggetto "+id+" non è stato trovato nelle collections!");
	return obj;
	}

qdocument = new document_class();
qtimer = new timer_class()