

function AssoloTable(elTable, elPaginator,myConfigs,myColumnDefs) 
{
	this._internalCounter = 0;
	this.Configs = {
		debug: false,
		width: "800", 
		height: "768",
		initialRequest: "", 
		datasource: "",
		sortedBy : null, 
		paginator: null,
		cellSingleSelect: false,
        showColumnMultiselect: false,
        RecordId : "id", 
        RecordName : "titolo",
		NonCiSonoDatiMsg: "Non&nbsp;ci&nbsp;sono&nbsp;dati...",
		CaricamentoMsg: "Caricamento&nbsp;in&nbsp;corso...",        
		TotaleMsg: "Totale:&nbsp;",
		selectedClass : "_rowSelected",
		unselectedClass1 : "_row1",
		unselectedClass2 : "_row2",
		rolloverClass : "_rowRollover",
		rolloverSelectedClass: "_rowRolloverSelected",
        tableHeadDivClass : "_tabellaHeadDiv",
        tableHeadClass : "_tabellaHead",
		afterFetchCallback: null,
		TableBodyCell: "_TableBodyCell",
        tabellaBodyClass: "_tabellaBody",
		TableBodyCellToolsCkb: "_TableBodyCellToolsCkb",
		TableHeadCell_SortedAsc: "_TableHeadCell_SortedAsc",
		TableHeadCellDiv_SortedAsc: "_TableHeadCellDiv_SortedAsc",
		TableHeadCell_SortedDesc: "_TableHeadCell_SortedDesc",
		TableHeadCellDiv_SortedDesc: "_TableHeadCellDiv_SortedDesc",
		TableHeadCell_Unsorted: "_TableHeadCell_Unsorted",
		TableHeadCellDiv_Unsorted: "_TableHeadCellDiv_Unsorted",
        TableHeadCellDivToolsCkb: "_TableHeadCellDivToolsCkb",
		paginator_table: "_paginator_table",
		paginator_primapagina: "_paginator_primapagina",
		paginator_precedente: "_paginator_precedente",
		paginator_pagine: "_paginator_pagine",
		paginator_paginacorrente: "_paginator_paginacorrente",
		paginator_pagina: "_paginator_pagina",
		paginator_prossima: "_paginator_prossima",
		paginator_ultimapagina: "_paginator_ultimapagina",
		paginator_rowsPerPage: "_paginator_rowsPerPage",
        paginator_numrecs: "_paginator_numrecs",
        filterForm: null,
        ForceSelected: null,
        forceColWidth: false,
        dontSetClass: false
    };
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	this.TableDIVID  = elTable.id;
	this.TableContainer = elTable;
	
	if (myConfigs) {
		if (myConfigs.debug)  this.Configs.debug  = myConfigs.debug;
		if (myConfigs.width)  this.Configs.width  = myConfigs.width;
		if (myConfigs.height) this.Configs.height = myConfigs.height;
		if (myConfigs.initialRequest) this.Configs.initialRequest = myConfigs.initialRequest;
		if (myConfigs.datasource) this.Configs.datasource = myConfigs.datasource;
		if (myConfigs.sortedBy) this.Configs.sortedBy = myConfigs.sortedBy;
		if (myConfigs.paginator) this.Configs.paginator = myConfigs.paginator;
		if (myConfigs.selectedClass) this.Configs.selectedClass = myConfigs.selectedClass;
		if (myConfigs.unselectedClass1) this.Configs.unselectedClass1 = myConfigs.unselectedClass1;
		if (myConfigs.unselectedClass2) this.Configs.unselectedClass2 = myConfigs.unselectedClass2;
		if (myConfigs.rolloverClass) this.Configs.rolloverClass = myConfigs.rolloverClass;
		if (myConfigs.rolloverSelectedClass) this.Configs.rolloverSelectedClass = myConfigs.rolloverSelectedClass;
        if (myConfigs.TableHeadCell_SortedAsc) this.Configs.TableHeadCell_SortedAsc = myConfigs.TableHeadCell_SortedAsc;
		if (myConfigs.TableHeadCellDiv_SortedAsc) this.Configs.TableHeadCellDiv_SortedAsc = myConfigs.TableHeadCellDiv_SortedAsc;
		if (myConfigs.TableHeadCell_SortedDesc) this.Configs.TableHeadCell_SortedDesc = myConfigs.TableHeadCell_SortedDesc;
		if (myConfigs.TableHeadCellDiv_SortedDesc) this.Configs.TableHeadCellDiv_SortedDesc = myConfigs.TableHeadCellDiv_SortedDesc;
		if (myConfigs.TableHeadCell_Unsorted) this.Configs.TableHeadCell_Unsorted = myConfigs.TableHeadCell_Unsorted;
		if (myConfigs.TableHeadCellDiv_Unsorted) this.Configs.TableHeadCellDiv_Unsorted = myConfigs.TableHeadCellDiv_Unsorted;
		if (myConfigs.cellSingleSelect) this.Configs.cellSingleSelect = myConfigs.cellSingleSelect;
		if (myConfigs.showColumnMultiselect) this.Configs.showColumnMultiselect = myConfigs.showColumnMultiselect;
		if (myConfigs.NonCiSonoDatiMsg) this.Configs.NonCiSonoDatiMsg = myConfigs.NonCiSonoDatiMsg;
		if (myConfigs.TotaleMsg) this.Configs.TotaleMsg = myConfigs.TotaleMsg;
		if (myConfigs.paginator) {
			this.Configs.paginator = myConfigs.paginator;
			this.PaginatorDIV = elPaginator;
		}
		if (myConfigs.afterFetchCallback) this.Configs.afterFetchCallback = myConfigs.afterFetchCallback;
		if (myConfigs.TableBodyCell) this.Configs.TableBodyCell = myConfigs.TableBodyCell;
		if (myConfigs.RecordId) this.Configs.RecordId = myConfigs.RecordId;
		if (myConfigs.RecordName) this.Configs.RecordName = myConfigs.RecordName;
		if (myConfigs.ForceSelected) this.Configs.ForceSelected = myConfigs.ForceSelected;
		if (myConfigs.TableBodyCellToolsCkbClass) this.Configs.TableBodyCellToolsCkb = myConfigs.TableBodyCellToolsCkbClass;
		if (window.AssoloUtils.isdefined(myConfigs.tableHeadDivClass)) this.Configs.tableHeadDivClass = myConfigs.tableHeadDivClass;
		if (myConfigs.tableHeadClass) this.Configs.tableHeadClass = myConfigs.tableHeadClass;
        if (myConfigs.forceColWidth) this.Configs.forceColWidth = myConfigs.forceColWidth;
        if (myConfigs.dontSetClass) this.Configs.dontSetClass = myConfigs.dontSetClass;
        if (myConfigs.paginator_table) this.Configs.paginator_table = myConfigs.paginator_table;
        if (myConfigs.paginator_primapagina) this.Configs.paginator_primapagina = myConfigs.paginator_primapagina;
        if (myConfigs.paginator_precedente) this.Configs.paginator_precedente = myConfigs.paginator_precedente;
        if (myConfigs.paginator_pagine) this.Configs.paginator_pagine = myConfigs.paginator_pagine;
        if (myConfigs.paginator_paginacorrente) this.Configs.paginator_paginacorrente = myConfigs.paginator_paginacorrente;
        if (myConfigs.paginator_pagina) this.Configs.paginator_pagina = myConfigs.paginator_pagina;
        if (myConfigs.paginator_prossima) this.Configs.paginator_prossima = myConfigs.paginator_prossima;
        if (myConfigs.paginator_ultimapagina) this.Configs.paginator_ultimapagina = myConfigs.paginator_ultimapagina;
        if (myConfigs.paginator_rowsPerPage) this.Configs.paginator_rowsPerPage = myConfigs.paginator_rowsPerPage;
        if (myConfigs.paginator_numrecs) this.Configs.paginator_numrecs = myConfigs.paginator_numrecs;
        if (myConfigs.tabellaBodyClass) this.Configs.tabellaBodyClass = myConfigs.tabellaBodyClass;
	}
	
    if (this.Configs.showColumnMultiselect && !this.Configs.cellSingleSelect) 
    {
        this.ColumnDefs = [{key:"_toolsCkb"}];

        if (myColumnDefs) {
            for (var i in myColumnDefs)
                this.ColumnDefs.push(myColumnDefs[i]);
        }
    } else {
        if (myColumnDefs) {
            this.ColumnDefs = myColumnDefs;
        } else {
            this.ColumnDefs = null;
        }
    }
  
	this.render();
	this.fetchRows();
	this.resize();
}

AssoloTable.prototype.handleOnResize = function(e) 
{
	var targ;
	if (!e) var e = window.event;
	if (e.target) targ = e.target;
	else if (e.srcElement) targ = e.srcElement;
	if (targ.nodeType == 3) // defeat Safari bug
		targ = targ.parentNode;

	var pos;
	if (targ) {
		pos = window.AssoloUtils.GetXYWH(targ);
		window.AssoloUtils.debug("sem chi["+pos[0]+";"+pos[1]+"]["+pos[2]+";"+pos[3]+"] ["+targ.id+"]["+targ.className+"]");
	} else {
		window.AssoloUtils.debug("sem chi");
	}
}

AssoloTable.prototype.resize = function() 
{
	/*this.Table.style.width = parseInt(this.Configs.width)+'px';
	this.TableHead.style.width = parseInt(this.Configs.width)+'px';*/
}

AssoloTable.prototype.forceResize = function() 
{
    this.TableDIVStinc.style.width = parseInt(this.Configs.width)+'px';
    this.TableHeadDivScroller.style.width = parseInt(this.Configs.width)+'px';
    this.Table.style.width = parseInt(this.Configs.width)+'px';
    this.TableHead.style.width = parseInt(this.Configs.width)+'px';
}

AssoloTable.prototype.renderHeader = function()
{
	this.TableHeadDiv = document.createElement("div");
	this.TableHeadDiv.style.position = "relative";
	this.TableHeadDiv.style.overflow = "hidden";
	this.TableHeadDiv.style.top = "0";
	this.TableHeadDiv.style.left = "0";
	this.TableHeadDiv.style.width = "100%";
	this.TableHeadDiv.style.margin = "0";
	this.TableHeadDiv.style.padding = "0";
	this.TableHeadDiv.style.border = "0";
	this.TableHeadDiv.className = this.Configs.tableHeadDivClass;
	this.TableHead = document.createElement("table");
	this.TableHead.className = this.Configs.tableHeadClass;
	this.TableTHead = this.TableHead.createTHead();
	this.TableTHeadRow = this.TableTHead.insertRow(0);
		
	this.TableTHeadRow.column = new Array();
	var THCD;
	var curClassTD;
	var curClassDiv;
	var TabellaObj = this;
    
	for (var i in this.ColumnDefs) 
    {
        if (this.Configs.showColumnMultiselect && this.Configs.cellSingleSelect && (i == 0)) 
        {
            this.TableTHeadRow.column["_toolsCkb"] = this.TableTHeadRow.insertCell(-1);
            this.TableTHeadRow.column["_toolsCkb"].id = this.TableID+"_THC_"+"_toolsCkb";
            THCD = this.TableID+"_THCD_"+"_toolsCkb";
            curClassTD = this.Configs.TableHeadCell_Unsorted;
            curClassDiv = this.Configs.TableHeadCellDivToolsCkb;
            this.TableTHeadRow.column["_toolsCkb"].className = curClassTD;

            var curDiv = document.createElement("div");	
            curDiv.id = THCD;
            curDiv.className = curClassDiv;
            this._allToolsCkb = document.createElement("input");
            this._allToolsCkb.type = "checkbox";
            this._allToolsCkb.name = "_allToolsCkb";
            this._allToolsCkb.onclick = function(){ TabellaObj.TRHeadAllToolsCkbOnclick(this); }
            curDiv.appendChild(this._allToolsCkb);
            this.TableTHeadRow.column["_toolsCkb"].appendChild(curDiv);
        } 
        else 
        {
            this.TableTHeadRow.column[this.ColumnDefs[i]["key"]] = this.TableTHeadRow.insertCell(-1);
            this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].id = this.TableID+"_THC_"+this.ColumnDefs[i]["key"];
            THCD = this.TableID+"_THCD_"+this.ColumnDefs[i]["key"];
            if (this.Configs.showColumnMultiselect && (this.ColumnDefs[i]["key"] == "_toolsCkb")) 
            {
                curClassTD = this.Configs.TableHeadCell_Unsorted;
                curClassDiv = this.Configs.TableHeadCellDivToolsCkb;
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].className = curClassTD;

                var curDiv = document.createElement("div");	
                curDiv.id = THCD;
                curDiv.className = curClassDiv;
                this._allToolsCkb = document.createElement("input");
                this._allToolsCkb.type = "checkbox";
                this._allToolsCkb.name = "_allToolsCkb";
                this._allToolsCkb.onclick = function(){ TabellaObj.TRHeadAllToolsCkbOnclick(this); }
                curDiv.appendChild(this._allToolsCkb);
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].appendChild(curDiv);
            } 
            else
            {
              if (this.ColumnDefs[i]["sortable"]) 
              {
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].style.cursor = "pointer";
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].onclick = function(){ 	TabellaObj.TRHeadOnclick(this); }
                
                if (this.ColumnDefs[i]["key"] == this.Configs.sortedBy.key ) {
                  if (this.Configs.sortedBy.dir == "desc") {
                    curClassTD = this.Configs.TableHeadCell_SortedDesc;
                    curClassDiv = this.Configs.TableHeadCellDiv_SortedDesc;
                  } else {
                    curClassTD = this.Configs.TableHeadCell_SortedAsc;
                    curClassDiv = this.Configs.TableHeadCellDiv_SortedAsc;
                  }
                } else {
                  curClassTD = this.Configs.TableHeadCell_Unsorted;
                  curClassDiv = this.Configs.TableHeadCellDiv_Unsorted;
                }
              } else {
                curClassTD = this.Configs.TableHeadCell_Unsorted;
                curClassDiv = this.Configs.TableHeadCellDiv_Unsorted;
              }
              
              this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].className = curClassTD;
              if (this.ColumnDefs[i]["label"] != null) {
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].innerHTML = "<div id='"+THCD+"' class='"+curClassDiv+"'>"+this.ColumnDefs[i]["label"]+"</div>";
              } else {
                this.TableTHeadRow.column[this.ColumnDefs[i]["key"]].innerHTML = "<div id='"+THCD+"' class='"+curClassDiv+"'>"+this.ColumnDefs[i]["key"]+"</div>";
              }
            }
        }
	}

	this.TableHeadDivScroller = document.createElement("div");	
	this.TableHeadDivScroller.appendChild(this.TableHead);
	this.TableHeadDivScroller.style.position = "relative";
	this.TableHeadDiv.appendChild(this.TableHeadDivScroller);
	this.TableContainer.appendChild(this.TableHeadDiv);

	this.TableDIV = document.createElement("div");
	this.TableDIV.style.margin = "0";
	this.TableDIV.style.padding = "0";
	this.TableDIV.style.border = "0";	
	this.TableDIV.style.overflow = "auto";
	this.TableContainer.appendChild(this.TableDIV);
}


AssoloTable.prototype.fixHeadWidth = function()
{
	var elPrimaRiga;
	var elHead;
	var TotW = 0;
	var ColumnMaxWidth = new Array();
	var posH, posR;

	this.TableDIV.scrollLeft = "0";
	this.Table.style.width = '1px';
	this.TableHead.style.width = '1px';
    
    if (this.Rows && this.Rows[0]) {
        for (var i in this.ColumnDefs) 
        {
            if (this.Configs.showColumnMultiselect && this.Configs.cellSingleSelect && (i == 0))
            {
                elPrimaRiga = this.Rows[0][1][i];
                elHead = this.TableTHeadRow.column["_toolsCkb"];

                posH = window.AssoloUtils.GetXYWH(elHead);
                posR = window.AssoloUtils.GetXYWH(elPrimaRiga);

                ColumnMaxWidth[i] = ((posH[2]>posR[2])?posH[2]:posR[2]);
                TotW += ((posH[2]>posR[2])?posH[2]:posR[2]);
            }
            else
            {
                elPrimaRiga = this.Rows[0][1][i];
                elHead = this.TableTHeadRow.column[this.ColumnDefs[i]["key"]];

                posH = window.AssoloUtils.GetXYWH(elHead);
                posR = window.AssoloUtils.GetXYWH(elPrimaRiga);

                ColumnMaxWidth[i] = ((posH[2]>posR[2])?posH[2]:posR[2]);
                TotW += ((posH[2]>posR[2])?posH[2]:posR[2]);
            }
        }
        if (TotW) {
            this.Table.style.width = '';
            this.TableHead.style.width = '';

            var forceColWidthElHead = null;
            var forceColWidthElPrimaRiga = null;
            
            for (var i in this.ColumnDefs) 
            {
                if (this.Configs.showColumnMultiselect && this.Configs.cellSingleSelect && (i == 0))
                {
                    elPrimaRiga = this.Rows[0][1][i];
                    elHead = this.TableTHeadRow.column["_toolsCkb"];
                    elHead.style.width = ColumnMaxWidth[i] + "px";
                    elPrimaRiga.style.width = (ColumnMaxWidth[i]+2) + "px";
                }
                else
                {
                    elPrimaRiga = this.Rows[0][1][i];
                    elHead = this.TableTHeadRow.column[this.ColumnDefs[i]["key"]];
                    elHead.style.width = ColumnMaxWidth[i] + "px";
                    elPrimaRiga.style.width = (ColumnMaxWidth[i]+2) + "px";
                    if (this.Configs.forceColWidth && (this.Configs.forceColWidth == this.ColumnDefs[i]["key"])) {
                        forceColWidthElHead = elHead;
                        forceColWidthElPrimaRiga = elPrimaRiga;
                    }
                }
            }
            posR = window.AssoloUtils.GetXYWH(this.Table);

            TotW += (this.ColumnDefs.length*3); // 3 px/campo ????????????????????????

            if (this.Configs.forceColWidth && forceColWidthElHead && forceColWidthElPrimaRiga) {
                if (TotW < this.Configs.width) {
                    var DiffW = parseInt(this.Configs.width - TotW);
                    forceColWidthElHead.style.width = (parseInt(forceColWidthElHead.style.width)+DiffW) + "px";
                    forceColWidthElPrimaRiga.style.width = (parseInt(forceColWidthElPrimaRiga.style.width)+DiffW) + "px";
                    TotW = this.Configs.width;
                }
            }
            
            this.TableDIVStinc.style.width = TotW+'px';
            this.TableHeadDivScroller.style.width = TotW+'px';
            this.Table.style.width = TotW+'px';
            this.TableHead.style.width = TotW+'px';

            posH = window.AssoloUtils.GetXY(this.TableHeadDiv);
            this.TableHeadDivScroller.style.left = (posH[0]-posR[0])+"px";
        }	
    } else {
        var forceColWidthElHead = null;
        var forceColWidthElPrimaRiga = null;

        for (var i in this.ColumnDefs) 
        {
            if (this.Configs.showColumnMultiselect && this.Configs.cellSingleSelect && (i == 0))
            {
                elHead = this.TableTHeadRow.column["_toolsCkb"];
                posH = window.AssoloUtils.GetXYWH(elHead);
                TotW += posH[2];
            }
            else
            {
                elHead = this.TableTHeadRow.column[this.ColumnDefs[i]["key"]];
                posH = window.AssoloUtils.GetXYWH(elHead);
                TotW += posH[2];
                if (this.Configs.forceColWidth && (this.Configs.forceColWidth == this.ColumnDefs[i]["key"])) {
                    forceColWidthElHead = elHead;
                    forceColWidthElPrimaRiga = elPrimaRiga;
                }                
            }        
        }
        if (TotW) {
            if (this.Configs.forceColWidth && forceColWidthElHead && forceColWidthElPrimaRiga) {
                if (TotW < this.Configs.width) {
                    var DiffW = parseInt(this.Configs.width - TotW);
                    forceColWidthElHead.style.width = (parseInt(forceColWidthElHead.style.width)+DiffW) + "px";
                    forceColWidthElPrimaRiga.style.width = (parseInt(forceColWidthElPrimaRiga.style.width)+DiffW) + "px";
                    TotW = this.Configs.width;
                }
            }
            this.Table.style.width = TotW+'px';
        }  
    }
}


AssoloTable.prototype.render = function()
{
	if(!this.TableID) 
	{
		this.TableID = this.TableDIVID + "_Table";
	 	this.Table   = document.createElement("table");
		this.Table.className = this.Configs.tabellaBodyClass;
		this.Table.id = this.TableID;

		this.renderHeader();

		this.TableTFoot = this.Table.createTFoot() 
		this.TableTFootRow = this.TableTFoot.insertRow(0);
		this.TableTFootCell = this.TableTFootRow.insertCell(0);
		this.TableTFootCell.colSpan = this.ColumnDefs.length;
		this.TableTFootCell.innerHTML = this.Configs.NonCiSonoDatiMsg;
		this.TableTFootCell.align = "left";
		this.TableTFootCell.style.verticalAlign = "top";
        if (this.Configs.forceColWidth && this.Configs.width) {
            this.TableTFootCell.style.width = this.Configs.width+"px";
        }
		this.TableTFoot.style.borderWidth="1px";
		this.TableTFoot.style.borderSpacing="0px";
		this.TableTFoot.style.borderStyle="outset";
		this.TableTFoot.style.borderColor="#6f7275";
		this.TableTFoot.style.borderCollapse="collapse";
		this.TableTFoot.style.backgroundColor="#FFFFFF";
		
		this.TableTBody = document.createElement("TBODY");
		this.Table.appendChild(this.TableTBody);
		
		
		this.TableDIVStinc = document.createElement("div");
		
		this.TableDIVStinc.appendChild(this.Table);
		this.TableDIV.appendChild(this.TableDIVStinc);
		
		var myself = this;
		window.AssoloUtils.AddEvent(this.TableDIV, "scroll", function(ev) { myself.TableHeadDivScroller.style.left = (-1*myself.TableDIV.scrollLeft)+"px"; } );
	}
}


AssoloTable.prototype.fetchRows = function()
{
	if (this.Configs.datasource != "")
	{
        this.TableTFootCell.innerHTML = this.Configs.CaricamentoMsg;

		var TabellaObj = this;
		var TableCallback = function(o){ 
            TabellaObj.getFetchedRows(o.responseText);
        }
        
        if (this.Configs.filterForm) {
            window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + "applyfilter=1&" + this.Configs.initialRequest + "", TableCallback, { }, this.Configs.filterForm);
        } else {
            window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + this.Configs.initialRequest + "", TableCallback, { } );
        }
	}
}

AssoloTable.prototype.getFetchedRows = function(responseText)
{
    if (this.Configs.showColumnMultiselect)
        this._allToolsCkb.checked = false;

	var TabellaObj = this;
	this.CurrentData = window.AssoloUtils.parse(responseText);

	for(var i = this.TableTBody.rows.length; i > 0;i--)
	{
		this.TableTBody.deleteRow(i-1);
	}
	if (this.Rows) {
		this.Rows.length = 0;
	}
	this.Rows = new Array();
	
	var k = 0;
	for (var i in this.CurrentData.records)
	{
		this.Rows[k] = new Array(3);
		this.Rows[k][0] = this.TableTBody.insertRow(k); 
		this.Rows[k][0].id = this.TableID + "_row_" + k;
        
        if (this.Configs.ForceSelected && (this.Configs.ForceSelected == this.CurrentData.records[i][this.Configs.RecordId])) {
            this.TableRowSelectedId = this.Rows[k][0].id + " ";
        }
        
		if (!this.Configs.cellSingleSelect) {
			this.Rows[k][0].onmouseover = function(){ TabellaObj.TRonmouseover(this.id); }
			this.Rows[k][0].onmouseout  = function(){ TabellaObj.TRonmouseout(this.id); }
			this.Rows[k][0].onclick     = function(event){ return TabellaObj.TRonclick(event,this.id); }
			this.Rows[k][0].onmousedown  = function(event){ return TabellaObj.TRonkeypress(event); }
		}

        this.Rows[k][1] = new Array(this.ColumnDefs.length);
        this.Rows[k][2] = new Array(this.ColumnDefs.length);

		for (var j in this.ColumnDefs) 
        {
            this.Rows[k][1][j] = this.Rows[k][0].insertCell(j);
            this.Rows[k][1][j].id = this.TableID + "_row_" + k + "_cell_" + j;
            if (this.Configs.cellSingleSelect) {
                this.Rows[k][1][j].k = k;
                this.Rows[k][1][j].j = j;
                
                if (this.Configs.showColumnMultiselect && (this.CurrentData.records[i][this.ColumnDefs[j]["key"]] != "")) 
                {
                    this.Rows[k][1][j].onmouseover = function(){ TabellaObj.TDonmouseover(this.id); }
                    this.Rows[k][1][j].onmouseout  = function(){ TabellaObj.TDonmouseout(this.id); }
                    this.Rows[k][1][j].onclick     = function(event){ TabellaObj.TDonclick(event,this.id); }
                    
                    if (this.Configs.ForceSelected ){ //&& ForceSelected == this.CurrentData.records[i][this.Configs.RecordId]) {
                        //this.TableRowSelectedId = this.Rows[k][0].id;
                        alert("ancora da finire...");
                    }
                    
                    
                }
            }
            
            if (!this.Configs.dontSetClass) {
                if ( ( (!this.Configs.cellSingleSelect) && (window.AssoloUtils.strpos(this.TableRowSelectedId, this.Rows[k][0].id+" ") != -1)) ||
                     (  (this.Configs.cellSingleSelect) && (window.AssoloUtils.strpos(this.TableCellSelectedId,this.Rows[k][1][j].id) != -1))) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                } else {
                    if (k%2) {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                    } else {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                    }
                }
            }
            this.Rows[k][2][j] = document.createElement("div");
            this.Rows[k][1][j].appendChild(this.Rows[k][2][j]);
      
            if (this.Configs.showColumnMultiselect && (!this.Configs.cellSingleSelect) && (this.ColumnDefs[j]["key"] == "_toolsCkb")) 
            {
                this.Rows[k][2][j].className = this.Configs.TableBodyCellToolsCkb;

                this.Rows[k][0]._ToolsCkb = document.createElement("input");
                this.Rows[k][0]._ToolsCkb.type = "checkbox";
                this.Rows[k][0]._ToolsCkb.name = "_ToolsCkb";
                this.Rows[k][0]._ToolsCkb.k = k;
                this.Rows[k][0]._ToolsCkb.onclick = function(event){
                    window.AssoloUtils.debug("AssoloTable.ToolsCkb.onclick=["+this.checked+"]");

                    if (this.checked) 
                    {
                        if (!TabellaObj.Configs.dontSetClass) {
                            for (var j in this.ColumnDefs) {
                                TabellaObj.Rows[this.k][1][j].className =  TabellaObj.Configs.selectedClass;			
                            }
                        }

                        if (window.AssoloUtils.strpos(TabellaObj.TableRowSelectedId, TabellaObj.Rows[this.k][0].id+" ") == -1) 
                        {
                            TabellaObj.TableRowSelectedId += TabellaObj.Rows[this.k][0].id + " ";
                        }
                    }
                    else
                    {
                        if (!TabellaObj.Configs.dontSetClass) {
                            if (this.k%2) {
                                for (var j in this.ColumnDefs) {
                                    TabellaObj.Rows[this.k][1][j].className =  TabellaObj.Configs.unselectedClass1;
                                }
                            } else {
                                for (var j in this.ColumnDefs) {
                                    TabellaObj.Rows[this.k][1][j].className =  TabellaObj.Configs.unselectedClass2;
                                }
                            }
                        }
                        TabellaObj.TableRowSelectedId = window.AssoloUtils.str_replace("  ", " ", window.AssoloUtils.str_replace(TabellaObj.Rows[this.k][0].id, "", TabellaObj.TableRowSelectedId));
                    }

                    var ev = event || window.event;
                    ev.cancelBubble = true;
                    if (ev.stopPropagation) ev.stopPropagation();
                    
                    return true;
                }
                
                if (this.Configs.ForceSelected && (this.Configs.ForceSelected == this.CurrentData.records[i][this.Configs.RecordId])) {
                    this.Rows[k][0]._ToolsCkb.checked = true;
                }

                this.Rows[k][2][j].appendChild(this.Rows[k][0]._ToolsCkb);
            }
            else
            {
                this.Rows[k][2][j].className = this.Configs.TableBodyCell;

                if (this.ColumnDefs[j]["formatter"]) {
                    eval(""+this.ColumnDefs[j]["formatter"]+"(this.Rows[k][2][j], this.CurrentData.records[i]);");
                } else {
                    if ( this.CurrentData.records[i][this.ColumnDefs[j]["key"]] == undefined) {
                        this.Rows[k][2][j].innerHTML="";
                    } else {
                        if (this.Configs.showColumnMultiselect && this.Configs.cellSingleSelect) 
                        {
                            if (this.CurrentData.records[i][this.ColumnDefs[j]["key"]] != "") {
                                this.Rows[k][2][j].innerHTML= "<div class='"+this.Configs.TableBodyCellToolsCkb+"'><input type='checkbox' name='_ToolsCkb'/></div>"
                                                              +this.CurrentData.records[i][this.ColumnDefs[j]["key"]];
                            }
                        } else {
                            this.Rows[k][2][j].innerHTML=this.CurrentData.records[i][this.ColumnDefs[j]["key"]];
                        }
                    }
                }
            }
		}
		k++;
	}

	if (k>=1) {
		try {
			this.Table.removeChild(this.TableTFoot);
		} catch(e) {
		}
	} else {
		try {
			this.Table.appendChild(this.TableTFoot);
		} catch(e) {
		}
		try {
			var myEmptyRow = this.TableTBody.insertRow(0);
		} catch(e) {
		}
	}
    this.fixHeadWidth();
	this.makePaginator();
  
	if (this.Configs.afterFetchCallback) 
		this.Configs.afterFetchCallback(this);
		
	if (this.CurrentData.query) // for debugging
		alert("query=["+this.CurrentData.query+"]");

    this.TableTFootCell.innerHTML = this.Configs.NonCiSonoDatiMsg;
}

AssoloTable.prototype.replaceRows = function(responseText)
{
	var TabellaObj = this;
	var CurrentDataTemp = window.AssoloUtils.parse(responseText);

	var k = 0;
	for (var i in this.CurrentData.records) {
        if (this.CurrentData.records[i][this.Configs.RecordId] == CurrentDataTemp.records[0][this.Configs.RecordId]) {
            this.CurrentData.records[i] = CurrentDataTemp.records[0];
            
            for (var j in this.ColumnDefs) 
            {
                if (this.Configs.showColumnMultiselect && (!this.Configs.cellSingleSelect) && (this.ColumnDefs[j]["key"] == "_toolsCkb")) {
                    // do nothing
                } else {
                    if (this.ColumnDefs[j]["formatter"]) {
                        window.AssoloUtils.parse(""+this.ColumnDefs[j]["formatter"]+"(this.Rows[k][2][j], this.CurrentData.records[i]);");
                    } else {
                        if ( this.CurrentData.records[i][this.ColumnDefs[j]["key"]] == undefined) {
                            this.Rows[k][2][j].innerHTML="";
                        } else {
                            this.Rows[k][2][j].innerHTML=this.CurrentData.records[i][this.ColumnDefs[j]["key"]];
                        }
                    }
                }
            }
            break;
        }
		k++;
	}

    /*if (this.Configs.sortedBy.key) {
        document.getElementById(this.TableID+"_THC_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCell_Unsorted;
        document.getElementById(this.TableID+"_THCD_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCellDiv_Unsorted;
        this.Configs.sortedBy.key = "";
    }*/
    
    this.fixHeadWidth();
//	this.makePaginator();
  
	if (this.Configs.afterFetchCallback) 
		this.Configs.afterFetchCallback(this);
		
	if (this.CurrentData.query) // for debugging
		alert("query=["+this.CurrentData.query+"]");
}

AssoloTable.prototype.TRonmouseover = function(rowid)
{
    if (!this.Configs.dontSetClass) 
    {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (this.Rows[k][0].id == rowid) {
                    if (window.AssoloUtils.strpos(this.TableRowSelectedId, this.Rows[k][0].id+" ") != -1) {
                        this.Rows[k][1][j].className =  this.Configs.rolloverSelectedClass;
                    } else {
                        this.Rows[k][1][j].className =  this.Configs.rolloverClass;			
                    }
                } else {
                    if (window.AssoloUtils.strpos(this.TableRowSelectedId, this.Rows[k][0].id+" ") != -1) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                    } else {
                        if (k%2) {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                        } else {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                        }
                    }
                }
            }
            k++;
        }
    }
}

AssoloTable.prototype.TRonmouseout = function(rowid)
{
    if (!this.Configs.dontSetClass) 
    {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (window.AssoloUtils.strpos(this.TableRowSelectedId, this.Rows[k][0].id+" ") != -1) {
                    this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                } else {
                    if (k%2) {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                    } else {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                    }
                }
            }
            k++;
        }
    }
}

AssoloTable.prototype.TRHeadAllToolsCkbOnclick = function(el)
{
    if (this.Configs.cellSingleSelect) 
    {
        this.TableCellSelectedId = "";
        
        var k = 0;
        for (var i in this.CurrentData.records) 
        {
            for (var j in this.ColumnDefs) 
            {
                if (el.checked) {
                  if (this.TableCellSelectedId) 
                    this.TableCellSelectedId += " ";
                  this.TableCellSelectedId += this.Rows[k][1][j].id;
                }
            
                if (this.Rows[k][2][j].firstChild) {
                    if (this.Rows[k][2][j].firstChild.firstChild) {
                        if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") 
                        {
                            this.Rows[k][2][j].firstChild.firstChild.checked = el.checked;

                            if (!this.Configs.dontSetClass) {
                                if (el.checked) {
                                  this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                                } else {
                                    if (k%2) {
                                        this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                                    } else {
                                        this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                                    }
                                }
                            }
                        }
                    }
                }                    
            }
            k++;
        }
    }
    else
    {
        this.TableRowSelectedId = "";

        var k = 0;
        for (var i in this.CurrentData.records)
        {
            this.Rows[k][0]._ToolsCkb.checked = el.checked;
            if (el.checked) {
              this.TableRowSelectedId += this.Rows[k][0].id + " ";
            }
      
            if (!this.Configs.dontSetClass) {
                for (var j in this.ColumnDefs) 
                {
                    if (el.checked) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;
                    } else {
                        if (k%2) {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                        } else {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                        }
                    }
                }
            }
            k++;
        }
    }
}

AssoloTable.prototype.getSelectedRecord = function()
{
    var KeyArr = new Array(), k = 0;

    if (this.Configs.cellSingleSelect) 
    {
        for (var i in this.CurrentData.records) {
            for (var j in this.ColumnDefs) {
                if (this.Rows[i][2][j].firstChild) {
                    if (this.Rows[i][2][j].firstChild.firstChild) {
                        if (this.Rows[i][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                            if (this.Rows[i][2][j].firstChild.firstChild.checked) 
                            {
                                var curChild = this.Rows[i][2][j].firstChild;
                                var recordId = false;
                                var recordName = false;
                                while (curChild) 
                                {
                                    if (curChild.name == 'recordId') {
                                        recordId = curChild.value;
                                    }
                                    if (curChild.name == 'recordName') {
                                        recordName = curChild.value;
                                    }
                                    if (recordId && recordName) {
                                        KeyArr.push(new Array( recordId, recordName ));
                                        break;
                                    }
                                    curChild = curChild.nextSibling;
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    else
    {
        for (var i in this.CurrentData.records)	{
            if (this.Rows[i][0]._ToolsCkb.checked) {
                KeyArr.push(k);
            }
            k++;
        }
    }

    return KeyArr;
}

AssoloTable.prototype.TRonkeypress = function(event)
{
	var ev = event || window.event;

    var code;
	if (ev.keyCode) code = ev.keyCode;
	else if (ev.which) code = ev.which;
	var character = String.fromCharCode(code);
  
    window.AssoloUtils.debug("AssoloTable.TRonkeypress=["+code+"]["+character+"]");
    //window.AssoloUtils.debug(window.AssoloUtils.print_r(ev), true);

    return false;
}

AssoloTable.prototype.TRonclick = function(event,rowid)
{
    var ev = event || window.event;
    var shiftPressed=ev.shiftKey;
    var ctrlPressed =ev.ctrlKey;  

    var TableRowSelectedIdArr = this.TableRowSelectedId.split(" ");
    var LastIdClicked = "";
    if (TableRowSelectedIdArr.length>0) {
        LastIdClicked = TableRowSelectedIdArr[TableRowSelectedIdArr.length-1];
    }

    var fromK, toK, tempK, CurRowIdArr;
    if (shiftPressed) {
        if (!LastIdClicked) LastIdClicked = rowid;

        CurRowIdArr = LastIdClicked.split("_");
        fromK = CurRowIdArr[CurRowIdArr.length-1];

        CurRowIdArr = rowid.split("_");
        toK = CurRowIdArr[CurRowIdArr.length-1];

        if (fromK > toK) {
            tempK = fromK;
            fromK = toK;
            toK = tempK;
        }
        this.TableRowSelectedId = "";
    }

    if (this._allToolsCkb) {
        this._allToolsCkb.checked = false;
    }
    
	var k = 0;
    var keyrowid = 0;
	for (var i in this.CurrentData.records)
	{
        if (this.Configs.showColumnMultiselect && shiftPressed) {
          if ((k >= fromK) && (k <= toK)) {
              this.Rows[k][0]._ToolsCkb.checked = true;
              this.TableRowSelectedId += this.Rows[k][0].id + " ";
              keyrowid = k;
              
              if (!this.Configs.dontSetClass) {
                  for (var j in this.ColumnDefs) {
                    this.Rows[k][1][j].className =  this.Configs.selectedClass;
                  }
              }
          } else {
              this.Rows[k][0]._ToolsCkb.checked = false;
              if (!this.Configs.dontSetClass) {
                  for (var j in this.ColumnDefs) {
                    if (k%2) {
                      this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                    } else {
                      this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                    }
                  }
              }
          }
        } 
        else
        {
            if (this.Configs.showColumnMultiselect) {
                if (this.Rows[k][0].id == rowid) {
                    keyrowid = k;
                    window.AssoloUtils.debug("AssoloTable.TRonclick=["+this.Rows[k][0]._ToolsCkb.checked+"]");

                    this.Rows[k][0]._ToolsCkb.checked = true;
                } else {
                    if (!ctrlPressed)
                        this.Rows[k][0]._ToolsCkb.checked = false;
                }
            } else {
                if (this.Rows[k][0].id == rowid) {
                   keyrowid = k;
                }
            }

            if (!this.Configs.dontSetClass) {
                for (var j in this.ColumnDefs) 
                {
                    if (this.Rows[k][0].id == rowid) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;
                    } else {
                        if ((!ctrlPressed) || (!this.Configs.showColumnMultiselect)) {
                            if (k%2) {
                                this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                            } else {
                                this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                            }
                        }
                    }
                }
            }
        }
		k++;
	}
    var prima =this.TableRowSelectedId;

    if (!this.Configs.showColumnMultiselect)
    {
        this.TableRowSelectedId = rowid + " ";
    } 
    else if (!shiftPressed)
    {
        if (ctrlPressed) {
            this.TableRowSelectedId += rowid + " ";
        } else {
            this.TableRowSelectedId = rowid + " ";
        }
    }

    if (shiftPressed || ctrlPressed) 
    {
        if (window.AssoloUtils.Browser.isIE) {
            document.selection.empty();
        } else {
            window.getSelection().empty;
        }
        /*ev.cancelBubble = true;
        if (ev.stopPropagation) ev.stopPropagation();*/
    }
    return true;
}

AssoloTable.prototype.TDonmouseover = function(cellid)
{
    if (!this.Configs.dontSetClass) 
    {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (this.Rows[k][1][j].id == cellid) {
                    if (window.AssoloUtils.strpos(this.TableCellSelectedId, this.Rows[k][1][j].id) != -1) {
                        this.Rows[k][1][j].className =  this.Configs.rolloverSelectedClass;
                    } else {
                        this.Rows[k][1][j].className =  this.Configs.rolloverClass;			
                    }
                } else {
                    if (window.AssoloUtils.strpos(this.TableCellSelectedId, this.Rows[k][1][j].id) != -1) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                    } else {
                        if (k%2) {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                        } else {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                        }
                    }
                }
            }
            k++;
        }
    }
}

AssoloTable.prototype.TDonmouseout = function(cellid)
{
    if (!this.Configs.dontSetClass) {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (window.AssoloUtils.strpos(this.TableCellSelectedId, this.Rows[k][1][j].id) != -1) {
                    this.Rows[k][1][j].className =  this.Configs.selectedClass;			
                } else {
                    if (k%2) {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                    } else {
                        this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                    }
                }
            }
            k++;
        }
    }
}
AssoloTable.prototype.TDonclick = function(event,cellid)
{
    var ev = event || window.event;
    var shiftPressed=ev.shiftKey;
    var ctrlPressed =ev.ctrlKey;  


    if (this.Configs.showColumnMultiselect && shiftPressed) 
    {
        var TableCellSelectedIdArr = this.TableCellSelectedId.split(" ");
        var FirstIdClicked = "";
        if (TableCellSelectedIdArr.length>0) {
            FirstIdClicked = TableCellSelectedIdArr[0];
        }

        if (FirstIdClicked != "")
        {
            this.TableCellSelectedId="";
            var ToBeSelected = false;
            var k = 0;
            for (var i in this.CurrentData.records)
            {
                for (var j in this.ColumnDefs) 
                {
                    if ((this.Rows[k][1][j].id == FirstIdClicked) || (this.Rows[k][1][j].id == cellid)) 
                    {
                        if (this.TableCellSelectedId)
                            this.TableCellSelectedId += " ";
                        this.TableCellSelectedId += this.Rows[k][1][j].id;
                        if (!this.Configs.dontSetClass) {
                            this.Rows[k][1][j].className =  this.Configs.selectedClass;
                        }
                        if (this.Rows[k][2][j].firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild) {
                                if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                    this.Rows[k][2][j].firstChild.firstChild.checked = true;
                                }
                            }
                        }
                        ToBeSelected = !ToBeSelected;
                    } else {
                        if (ToBeSelected) {
                            if (this.TableCellSelectedId) 
                                this.TableCellSelectedId += " ";
                            this.TableCellSelectedId += this.Rows[k][1][j].id;

                            if (!this.Configs.dontSetClass) {
                                this.Rows[k][1][j].className =  this.Configs.selectedClass;
                            }
                            if (this.Rows[k][2][j].firstChild) {
                                if (this.Rows[k][2][j].firstChild.firstChild) {
                                    if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                        this.Rows[k][2][j].firstChild.firstChild.checked = true;
                                    }
                                }
                            }
                        } else {
                            if (!this.Configs.dontSetClass) {
                                if (k%2) {
                                    this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                                } else {
                                    this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                                }
                            }
                            
                            if (this.Rows[k][2][j].firstChild) {
                                if (this.Rows[k][2][j].firstChild.firstChild) {
                                    if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                        this.Rows[k][2][j].firstChild.firstChild.checked = false;
                                    }
                                }
                            }   
                        }
                    }
                }
                k++;
            }
        }
        else
        {
            var k = 0;
            for (var i in this.CurrentData.records)
            {
                for (var j in this.ColumnDefs) 
                {
                    if (this.Rows[k][1][j].id == cellid) {
                        if (!this.Configs.dontSetClass) {
                            this.Rows[k][1][j].className =  this.Configs.selectedClass;
                        }
                        
                        if (this.Rows[k][2][j].firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild) {
                                if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                    this.Rows[k][2][j].firstChild.firstChild.checked = true;
                                }
                            }
                        }
                    } else {
                        if (!this.Configs.dontSetClass) {
                            if (k%2) {
                                this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                            } else {
                                this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                            }
                        }
                        
                        if (this.Rows[k][2][j].firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild) {
                                if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                    this.Rows[k][2][j].firstChild.firstChild.checked = false;
                                }
                            }
                        }                    
                    }
                }
                k++;
            }
            this.TableCellSelectedId = cellid;
        }
    } 
    else if (this.Configs.showColumnMultiselect && ctrlPressed) 
    {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (this.Rows[k][1][j].id == cellid) {
                    if (!this.Configs.dontSetClass) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;
                    }
                    
                    if (this.Rows[k][2][j].firstChild) {
                        if (this.Rows[k][2][j].firstChild.firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                this.Rows[k][2][j].firstChild.firstChild.checked = true;
                            }
                        }
                    }                    
                    break;
                }
            }
            k++;
        }
        if (window.AssoloUtils.strpos(this.TableCellSelectedId, cellid) == -1) 
        {
            if (this.TableCellSelectedId) 
                this.TableCellSelectedId += " ";
            this.TableCellSelectedId += cellid;
        }        
    }
    else 
    {
        var k = 0;
        for (var i in this.CurrentData.records)
        {
            for (var j in this.ColumnDefs) 
            {
                if (this.Rows[k][1][j].id == cellid) {
                    if (!this.Configs.dontSetClass) {
                        this.Rows[k][1][j].className =  this.Configs.selectedClass;
                    }
                    
                    if (this.Rows[k][2][j].firstChild) {
                        if (this.Rows[k][2][j].firstChild.firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                this.Rows[k][2][j].firstChild.firstChild.checked = true;
                            }
                        }
                    }
                } else {
                    if (!this.Configs.dontSetClass) {
                        if (k%2) {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                        } else {
                            this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                        }
                    }
                    
                    if (this.Rows[k][2][j].firstChild) {
                        if (this.Rows[k][2][j].firstChild.firstChild) {
                            if (this.Rows[k][2][j].firstChild.firstChild.name == "_ToolsCkb") {
                                this.Rows[k][2][j].firstChild.firstChild.checked = false;
                            }
                        }
                    }                    
                }
            }
            k++;
        }
        this.TableCellSelectedId = cellid;
    }
    
    if (shiftPressed || ctrlPressed) 
    {
        if (window.AssoloUtils.Browser.isIE) {
            document.selection.empty();
        } else {
            window.getSelection().empty;
        }
    }
    return true;    
}

AssoloTable.prototype.SortIt = function(cellkey, ascdesc)
{
	if ((cellkey != this.Configs.sortedBy.key) || (ascdesc != this.Configs.sortedBy.dir)) 
    {
        var curCellId = this.TableID+"_THC_"+cellkey;
        var curDivId = this.TableID+"_THCD_"+cellkey;
        
        if (this.Configs.sortedBy.key) {
            document.getElementById(this.TableID+"_THC_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCell_Unsorted;
            document.getElementById(this.TableID+"_THCD_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCellDiv_Unsorted;
        }
        if (ascdesc == "asc") {
            this.Configs.sortedBy.key = cellkey;
            this.Configs.sortedBy.dir = "asc";
            document.getElementById(curCellId).className = this.Configs.TableHeadCell_SortedAsc;
            document.getElementById(curDivId).className = this.Configs.TableHeadCellDiv_SortedAsc;
        } else {
            this.Configs.sortedBy.key = cellkey;
            this.Configs.sortedBy.dir = "desc";
            document.getElementById(curCellId).className = this.Configs.TableHeadCell_SortedDesc;
            document.getElementById(curDivId).className = this.Configs.TableHeadCellDiv_SortedDesc;
        }
    
        this.TableRowSelectedId = "";
        this.TableCellSelectedId = "";
        var TabellaObj = this;
        var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
        
        if (this.Configs.filterForm) {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
            window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
        } else {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
            window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);	
        }
        
        return true;
    } else {
        return false;
    }
}

AssoloTable.prototype.TRHeadOnclick = function(cell)
{
	var curKey = window.AssoloUtils.str_replace(this.TableID+"_THC_", "", cell.id);
	var curDivId = this.TableID+"_THCD_"+curKey;
	
	//alert("cell=["+cell.id+"]["+cell.className+"]["+curDivId+"]   ["+curKey+"]==["+this.Configs.sortedBy.key+"]");
	
	if (curKey == this.Configs.sortedBy.key) {
		if (this.Configs.sortedBy.dir == "desc") {
			this.Configs.sortedBy.dir = "asc";
			cell.className = this.Configs.TableHeadCell_SortedAsc;
			document.getElementById(curDivId).className = this.Configs.TableHeadCellDiv_SortedAsc;
		} else {
			this.Configs.sortedBy.dir = "desc";
			cell.className = this.Configs.TableHeadCell_SortedDesc;
			document.getElementById(curDivId).className = this.Configs.TableHeadCellDiv_SortedDesc;
		}
	} else {
		if (this.Configs.sortedBy.key) {
            if (document.getElementById(this.TableID+"_THC_"+this.Configs.sortedBy.key))
                document.getElementById(this.TableID+"_THC_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCell_Unsorted;
            if (document.getElementById(this.TableID+"_THCD_"+this.Configs.sortedBy.key))
                document.getElementById(this.TableID+"_THCD_"+this.Configs.sortedBy.key).className = this.Configs.TableHeadCellDiv_Unsorted;
			this.Configs.sortedBy.key = curKey;
			this.Configs.sortedBy.dir = "asc";
			cell.className = this.Configs.TableHeadCell_SortedAsc;
			document.getElementById(curDivId).className = this.Configs.TableHeadCellDiv_SortedAsc;
		}
	}
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
    
    if (this.Configs.filterForm) {
        if (this.Configs.paginator) {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        if (this.Configs.paginator) {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);	
    }
	
	return false;	
}

AssoloTable.prototype.makePaginator = function()
{
	if (this.PaginatorDIV) 
	{
		var TabellaObj = this;
		this.PaginatorDIV.innerHTML = "";
		
		this.PaginatorID  = this.TableDIVID + "_pag";
		this.Paginator    = document.createElement("table");
		this.Paginator.id = this.PaginatorID;
		this.Paginator.className = this.Configs.paginator_table;
		this.PaginatorRow = this.Paginator.insertRow(0); 
		
		this.PaginatorNumRecs = this.PaginatorRow.insertCell(0);
		this.PaginatorPrima = this.PaginatorRow.insertCell(1);
		this.PaginatorPrecedente = this.PaginatorRow.insertCell(2);
		this.PaginatorPagine = this.PaginatorRow.insertCell(3);
		this.PaginatorProssima = this.PaginatorRow.insertCell(4);
		this.PaginatorUltima = this.PaginatorRow.insertCell(5);
		this.PaginatorRPP = this.PaginatorRow.insertCell(6);
		
		this.PaginatorNumRecs.nowrap = "nowrap";
		this.PaginatorPrima.nowrap = "nowrap";
		this.PaginatorPrecedente.nowrap = "nowrap";
		this.PaginatorPagine.nowrap = "nowrap";
		this.PaginatorProssima.nowrap = "nowrap";
		this.PaginatorUltima.nowrap = "nowrap";
		this.PaginatorRPP.nowrap = "nowrap";
        
        this.PaginatorNumRecsDiv = document.createElement("div");
		this.PaginatorNumRecsDiv.className = this.Configs.paginator_numrecs;
		this.PaginatorNumRecsDiv.id = this.PaginatorID+"_paginator_primapagina";
		this.PaginatorNumRecsDiv.innerHTML = this.Configs.TotaleMsg+this.CurrentData.totalRecords;
		this.PaginatorNumRecs.appendChild(this.PaginatorNumRecsDiv);
        
		this.PaginatorPrimaDiv = document.createElement("div");
		this.PaginatorPrimaDiv.className = this.Configs.paginator_primapagina;
		this.PaginatorPrimaDiv.id = this.PaginatorID+"_paginator_primapagina";
		this.PaginatorPrimaDiv.innerHTML = "&nbsp;";
		this.PaginatorPrecedenteDiv = document.createElement("div");
		this.PaginatorPrecedenteDiv.className = this.Configs.paginator_precedente;
		this.PaginatorPrecedenteDiv.id = this.PaginatorID+"_paginator_precedente";
		this.PaginatorPrecedenteDiv.innerHTML = "&nbsp;";
		if (this.CurrentData.startIndex != 0) { // prima pagina
			this.PaginatorPrimaDiv.onclick = function(){ TabellaObj.goToPrimaPagina(); }
			this.PaginatorPrecedenteDiv.onclick =  function(){ TabellaObj.goToPrecedente(); }
		}
		this.PaginatorPrima.appendChild(this.PaginatorPrimaDiv);
		this.PaginatorPrecedente.appendChild(this.PaginatorPrecedenteDiv);
		
		this.PaginatorPagineDiv = document.createElement("div");
		this.PaginatorPagineDiv.className = this.Configs.paginator_pagine;
		this.PaginatorPagineDiv.id = this.PaginatorID+"_paginator_pagine";
		
		var Half = parseInt(this.Configs.paginator.pageLinks / 2);
		if (!(this.Configs.paginator.pageLinks % 2)) {
			Half = Half + 1;
		}
		var FromIndex = (this.CurrentData.startIndex / this.Configs.paginator.rowsPerPage) - Half;
		if (FromIndex < 0) {
			FromIndex = 0;
		}
		var ToIndex = FromIndex + this.Configs.paginator.pageLinks;
		if (this.CurrentData.totalRecords%this.Configs.paginator.rowsPerPage) {
			var LastIndex = parseInt(this.CurrentData.totalRecords/this.Configs.paginator.rowsPerPage)+1;
		} else {
			var LastIndex = parseInt(this.CurrentData.totalRecords/this.Configs.paginator.rowsPerPage);
		}
		if (ToIndex > LastIndex) {
//			alert("exception ToIndex["+ToIndex+"] LastIndex["+LastIndex+"]");
			ToIndex = LastIndex;
			FromIndex = (ToIndex - this.Configs.paginator.pageLinks);
			if (FromIndex < 0) {
				FromIndex = 0;
			}
		}
		
		/*alert("this.Configs.paginator.pageLinks=["+this.Configs.paginator.pageLinks+
		"];  this.CurrentData.startIndex=["+this.CurrentData.startIndex+
		"];  this.Configs.paginator.rowsPerPage=["+this.Configs.paginator.rowsPerPage+
		"];  FromIndex=["+FromIndex+
		"];  ToIndex=["+ToIndex+
		"];  LastIndex=["+LastIndex+
		"]");*/
		
		if (this.Configs.paginator.rowsPerPage == "-1") {
			curspan = document.createElement("div");
			curspan.className = this.Configs.paginator_paginacorrente;
			curspan.innerHTML = "1";
			this.PaginatorPagineDiv.appendChild(curspan);
		} else {
			for (var i=FromIndex; i<ToIndex; i++) {
				if (this.CurrentData.startIndex == (i*this.Configs.paginator.rowsPerPage)) 
				{
					curspan = document.createElement("div");
					curspan.className = this.Configs.paginator_paginacorrente;
					curspan.innerHTML = (i+1);
					this.PaginatorPagineDiv.appendChild(curspan);
				} else 
				{
					curspan = document.createElement("div");
					curspan.className = this.Configs.paginator_pagina;
					curspan.id = this.PaginatorID+"paginator_pagina"+"_"+(i+1);
					curspan.innerHTML = (i+1);
					curspan.onclick =  function(){ TabellaObj.goToPage(this.id); }
					this.PaginatorPagineDiv.appendChild(curspan);
				}
			}
		}
		this.PaginatorPagine.appendChild(this.PaginatorPagineDiv);
		
		this.PaginatorProssimaDiv = document.createElement("div");
		this.PaginatorProssimaDiv.className = this.Configs.paginator_prossima;
		this.PaginatorProssimaDiv.id = this.PaginatorID+"_paginator_prossima";
		this.PaginatorProssimaDiv.innerHTML = "&nbsp;";				
		this.PaginatorUltimaDiv = document.createElement("div");
		this.PaginatorUltimaDiv.className = this.Configs.paginator_ultimapagina;
		this.PaginatorUltimaDiv.id = this.PaginatorID+"_paginator_ultimapagina";
		this.PaginatorUltimaDiv.innerHTML = "&nbsp;";

		var lastPage = (parseInt(this.CurrentData.totalRecords / this.Configs.paginator.rowsPerPage) * this.Configs.paginator.rowsPerPage);
		//alert("["+this.CurrentData.startIndex+"] < ["+lastPage+"]");
		
		if (this.Configs.paginator.rowsPerPage != "-1") {
			if (lastPage > this.CurrentData.startIndex) { // ultima pagina
				//alert("ultima pagina");
				this.PaginatorProssimaDiv.onclick = function(){ TabellaObj.goToProssima(); }
				this.PaginatorUltimaDiv.onclick =  function(){ TabellaObj.goToUltimaPagina(); }
			}
		}
		this.PaginatorProssima.appendChild(this.PaginatorProssimaDiv);
		this.PaginatorUltima.appendChild(this.PaginatorUltimaDiv);
		
		this.PaginatorRPPDiv = document.createElement("div");
		this.PaginatorRPPDiv.className = this.Configs.paginator_rowsPerPage;
		this.PaginatorRPPDiv.id = this.PaginatorID+"_paginator_rowsPerPage";
		this.PaginatorRPPSel = document.createElement("select");
		this.PaginatorRPPSel.id = this.PaginatorID+"_rowsPerPage";
		this.PaginatorRPPSel.onchange =  function(){ TabellaObj.changeRowPerPage(); }
		for (var i in this.Configs.paginator.rowsPerPageOptions) 
		{
			if (this.Configs.paginator.rowsPerPageOptions[i] == this.Configs.paginator.rowsPerPage) {
				this.PaginatorRPPSel.options[this.PaginatorRPPSel.length]= new Option((this.Configs.paginator.rowsPerPageOptions[i]=="-1")?"All":this.Configs.paginator.rowsPerPageOptions[i], this.Configs.paginator.rowsPerPageOptions[i], true, true);
			} else {
				this.PaginatorRPPSel.options[this.PaginatorRPPSel.length]= new Option((this.Configs.paginator.rowsPerPageOptions[i]=="-1")?"All":this.Configs.paginator.rowsPerPageOptions[i], this.Configs.paginator.rowsPerPageOptions[i]);
			}
		}
		this.PaginatorRPPDiv.appendChild(this.PaginatorRPPSel);
		this.PaginatorRPP.appendChild(this.PaginatorRPPDiv);
		this.PaginatorDIV.appendChild(this.Paginator);
		
		this.PaginatorPrimaDiv.style.cursor = "pointer";
		this.PaginatorPrecedenteDiv.style.cursor = "pointer";
		this.PaginatorPagineDiv.style.cursor = "pointer";
		this.PaginatorProssimaDiv.style.cursor = "pointer";
		this.PaginatorUltimaDiv.style.cursor = "pointer";
		this.PaginatorRPPDiv.style.cursor = "pointer";		
	}
}

AssoloTable.prototype.goToPrimaPagina = function()
{
	//alert("goToPrimaPagina");
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);
    }
    
	return false;
}
AssoloTable.prototype.goToPrecedente = function()
{
	//alert("goToPrecedente");
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
	this.CurrentData.startIndex = parseInt(this.CurrentData.startIndex) - parseInt(this.Configs.paginator.rowsPerPage);
    
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);		
    }
	
	return false;
}
AssoloTable.prototype.goToPage = function(pageId)
{
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
	var ThePage = (parseInt(window.AssoloUtils.str_replace(this.PaginatorID+"paginator_pagina"+"_", "", pageId))-1)*this.Configs.paginator.rowsPerPage;
	//alert("goToPage ThePage=["+ThePage+"]");
	
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+ThePage+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+ThePage+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);
    }
    
	return false;
}
AssoloTable.prototype.goToProssima = function()
{
	//alert("goToProssima");
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
	this.CurrentData.startIndex = parseInt(this.CurrentData.startIndex) + parseInt(this.Configs.paginator.rowsPerPage);
    
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);
	}
    
	return false;
}
AssoloTable.prototype.goToUltimaPagina = function()
{
	//alert("goToUltimaPagina");
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
	var lastPage = (parseInt(this.CurrentData.totalRecords / this.Configs.paginator.rowsPerPage) * this.Configs.paginator.rowsPerPage);
    
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+lastPage+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+lastPage+"&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);
    }
	
	return false;
}
AssoloTable.prototype.changeRowPerPage = function()
{
	//alert("changeRowPerPage");
	
	this.TableRowSelectedId = "";
	this.TableCellSelectedId = "";
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }
	
	this.Configs.paginator.rowsPerPage = this.PaginatorRPPSel.options[this.PaginatorRPPSel.selectedIndex].value;
    
    if (this.Configs.filterForm) {
        myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex=0&results="+this.Configs.paginator.rowsPerPage;
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);	
    }
	
	return false;
}
AssoloTable.prototype.refreshData = function()
{
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.getFetchedRows(o.responseText); }

	var startIndex = 0;
    if (this.CurrentData && this.CurrentData.startIndex) {
        startIndex = this.CurrentData.startIndex;
    }
	
    if (this.Configs.filterForm) {
        if (this.Configs.paginator) {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        if (this.Configs.paginator) {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);	
    }
    
	return false;
}

AssoloTable.prototype.reFetch = function()
{
	var TabellaObj = this;
	var TableCallback = function(o){ TabellaObj.replaceRowsReFetched(o.responseText); }
	
    if (this.Configs.filterForm) {
        if (this.Configs.paginator) {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "applyfilter=1&sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("POST", "" + this.Configs.datasource + myRequest + "", TableCallback, {}, this.Configs.filterForm);
    } else {
        if (this.Configs.paginator) {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir+"&startIndex="+this.CurrentData.startIndex+"&results="+this.Configs.paginator.rowsPerPage;
        } else {
            myRequest = "sort="+this.Configs.sortedBy.key+"&dir="+this.Configs.sortedBy.dir;
        }
        window.AssoloUtils.SendAsyncRequest("GET", "" + this.Configs.datasource + myRequest + "", TableCallback);	
    }
    
	return false;
}

AssoloTable.prototype.replaceRowsReFetched = function(responseText)
{
	var TabellaObj = this;
	var CurrentDataTemp = window.AssoloUtils.parse(responseText);

	var k = 0;
	for (var i in this.CurrentData.records) {
        for (var j in this.ColumnDefs) 
        {
            if (this.Configs.showColumnMultiselect && (!this.Configs.cellSingleSelect) && (this.ColumnDefs[j]["key"] == "_toolsCkb")) {
                // do nothing
            } else {
                if (this.ColumnDefs[j]["formatter"]) {
                    window.AssoloUtils.parse(""+this.ColumnDefs[j]["formatter"]+"(this.Rows[k][2][j], this.CurrentData.records[i]);");
                } else {
                    if ( this.CurrentData.records[i][this.ColumnDefs[j]["key"]] == undefined) {
                        this.Rows[k][2][j].innerHTML="";
                    } else {
                        this.Rows[k][2][j].innerHTML=this.CurrentData.records[i][this.ColumnDefs[j]["key"]];
                    }
                }
            }
        }
        this.CurrentData.records[i] = CurrentDataTemp.records[k];
        
		k++;
	}

    //this.fixHeadWidth();
  
	//if (this.Configs.afterFetchCallback) 
	//	this.Configs.afterFetchCallback(this);
		
	//if (this.CurrentData.query) // for debugging
	//	alert("query=["+this.CurrentData.query+"]");
}


AssoloTable.prototype.setFilterForm = function(theForm)
{
    this.Configs.filterForm = theForm;
}

AssoloTable.prototype.unselectAll = function()
{
    this.TableRowSelectedId = "";
    this.TableCellSelectedId = "";
    this.Configs.ForceSelected = 0;

    var k = 0;
    for (var i in this.CurrentData.records)
	{
        if (this.Rows[k][0]._ToolsCkb)
            this.Rows[k][0]._ToolsCkb.checked = false;

        if (!this.Configs.dontSetClass) {
            if (k%2) {
                for (var j in this.ColumnDefs) {
                    this.Rows[k][1][j].className =  this.Configs.unselectedClass1;
                }
            } else {
                for (var j in this.ColumnDefs) {
                    this.Rows[k][1][j].className =  this.Configs.unselectedClass2;
                }
            }
        }
        k++;
    }
}

