function Cella(valore,tipo,decimali) {
	this.decimali=decimali;
	this.tipo=tipo;
	this.valoreConfronto;
	this.valore;
	this.setValore(valore);
	this.eventi=new Array();
	this.stile=null;
	this.righe="";
	this.colonne="";
	this.id="";
}

Cella.prototype.setId=function(id){
	return this.id=" id='" + id + "'";
}

Cella.prototype.getValore=function(){
	return this.valoreConfronto;
}

Cella.prototype.setValore=function(valore){
	if(valore==null || valore=="null"){
		this.valoreConfronto=null;
		this.valore="&nbsp;";
	}
	else
		switch(this.tipo){
		case 'd':
			valore=new Date(valore)
			var mese="0" + (valore.getMonth()+1)
			mese=mese.substring(mese.length-2);
			var giorno="0" + valore.getDate();
			giorno=giorno.substring(giorno.length-2);
			this.valoreConfronto=String(valore.getFullYear()) + mese + giorno;
			this.valore=giorno + "/" + mese + "/" + valore.getFullYear();
			break;
		case 'o':
			valore=new Date(valore);
			var ore="0" + valore.getHours();
			var minuti="0" + valore.getMinutes();
			this.valoreConfronto=ore.substring(ore.length-2) + ":" + minuti.substring(minuti.length-2);
			this.valore=this.valoreConfronto;
			break;
		case 't':
			this.valoreConfronto=valore;
			this.valore=formatoData(new Date(valore),"d");
			break;
		case 'n':
			if (this.decimali==0){
				valore=parseInt(valore)
				this.valore=valore;
				this.valoreConfronto=valore;
			}
			else {
				this.valore=valore.replace(/,/g,'.');
				var i=this.valore.indexOf('.');
				var zeri="000000000000000";
				if (i>-1)
					this.valore=this.valore.substring(0,i+1) + (this.valore.substring(i+1) + zeri).substring(0,this.decimali);
				else
					this.valore+='.' + zeri.substring(0,this.decimali);
				this.valoreConfronto=parseFloat(valore);
			}
			break;
		default:
			this.valoreConfronto=valore;
			this.valore=valore;
		}
}

Cella.prototype.evento=function (oEvento){
	for(var i in this.eventi)
		if (this.eventi[i].tipo==oEvento.tipo) {
			this.eventi[i].azione+=";" + oEvento.azione;
			return;
		}
	this.eventi[this.eventi.length]=oEvento;
};

Cella.prototype.occupRighe=function (n){
	if (n>1)
		this.righe=" rowSpan='" +n +"' ";
	else
		this.righe="";
}

Cella.prototype.occupCol=function (n){
	if (n>1)
		this.colonne=" colSpan='" +n + "'' ";
	else
		this.colonne="";
}

Cella.prototype.getNomeStile=function (){
	return this.stile.valore;
}

Cella.prototype.getTipoStile=function (){
	return this.stile.tipo;
}

Cella.prototype.setStile=function (oStile){
	this.stile=oStile;
}

Cella.prototype.aggiungiStile=function (oStile){
	this.stile=oStile;
}

Cella.prototype.toString=function (){
	var testo="<td" + this.id + this.stile;
	for ( var i in this.eventi)
		testo+= this.eventi[i];
	return testo + this.righe + this.colonne + ">" + this.valore + "</td>";
}

