function Selettore(tabella) {
	this.indice=-1;
	this.bottone=0;
	this.tabella=tabella;
	this.impostaSelettore();
}

Selettore.prototype.impostaSelettore=function (){
	for(r=0; r<this.tabella.dati.length; r++)
		this.tabella.dati[r].sostEvento(new Evento("onmousedown", this.tabella.variabile + '.tipo.doMouseDown()" onmouseup="' + this.tabella.variabile + '.tipo.seleziona('+ r +')"'));
}

Selettore.prototype.doMouseDown=function (){
	this.bottone=window.event.button;
}

Selettore.prototype.seleziona=function (pos){
	if (this.bottone==1){
		var elemento=this.tabella.tabe.rows(pos+this.tabella.rTit);
		if (!this.tabella.dati[pos].selezionata){
			for(var c in this.tabella.dati[pos].celle)
				elemento.cells(parseInt(c)).className=this.tabella.stileSelezione;
		}
		else
			for(var c in this.tabella.dati[pos].celle)
				elemento.cells(parseInt(c)).className=this.tabella.dati[pos].celle[c].stile[0].valore;
		this.tabella.dati[pos].selezionata=!this.tabella.dati[pos].selezionata;
	}
	else if (this.indice!=-1){
	var selezionato=this.tabella.dati[this.indice].selezionata;
		var inizio=this.indice,fine=pos;
		if (pos<this.indice){
			inizio=pos;
			fine=this.indice;
		}
		for (var i=inizio; i<=fine; i++){
			if (selezionato)
				for(var c in this.tabella.dati[i].celle)
					this.tabella.tabe.rows(i+this.tabella.rTit).cells(parseInt(c)).className=this.tabella.stileSelezione;
			else
				for(var c in this.tabella.dati[i].celle)
					this.tabella.tabe.rows(i+this.tabella.rTit).cells(parseInt(c)).className=this.tabella.dati[i].celle[c].stile[0].valore;
			this.tabella.dati[i].selezionata=selezionato;
		}
	}

	this.indice=pos;
}

Selettore.prototype.ripristinaSelezionati=function (){
	for (var i in this.tabella.dati){
		if (this.tabella.dati[i].selezionata)
			for(var c in this.tabella.dati[i].celle)
				this.tabella.tabe.rows(parseInt(i)+this.tabella.rTit).cells(parseInt(c)).className=this.tabella.stileSelezione;
	}
	this.indice=-1;
	this.bottone=0;
}

Selettore.prototype.elencoSelezionati=function (){
	var esito="";
	for(i=this.tabella.rTit;i<this.tabella.tabe.rows.length;i++)
		if (this.tabella.tabe.rows(i).cells(0).className==this.tabella.stileSelezione)
			esito+= this.tabella.chiavi[i-this.tabella.rTit] + ',';
	if (esito!="")
		return esito=esito.substring(0,esito.length-1);
	else
		return ""
}

Selettore.prototype.posCorrente= function (){
	return -1;
};

Selettore.prototype.posizionaCursore =function (chiave){
	return ;
};

Selettore.prototype.spostaCursore =function (chiave){
	return ;
};

Selettore.prototype.posizione =function (){
	return 1;
};

Selettore.prototype.impostaCursore =function (){
	return;
};

