/*
** This file handles table manipulation such as
**  creating, sorting, removing rows, adding rows
*/

//FDD namespace
SKEL.TABLE = {

	test: function(){
		alert('test');
	},

	//pass in the tableId and the new table data (as a multi-dimensional array)
	importTable: function(tableId,rows,outputHead){
		table = document.getElementById(tableId);
		var row = 0;
		for(var key in rows){
			if(outputHead && row == 0){
				headRow = table.insertRow(row++);
			}
			tmpRow = table.insertRow(row);
			colCnt = 0;
			for(col in rows[key]){
				if(outputHead && row == 1){
					tmpHead = headRow.insertCell(colCnt);
					tmpHead.innerHTML=col;
				}
				tmp = tmpRow.insertCell(colCnt++);
				tmp.innerHTML=rows[key][col];
				
			}
			//x = tmpRow.insertCell('a');
			//y = tmpRow.insertCell(1);
			//x.innerHTML=rows[row]['a'];
			//y.innerHTML=rows[row]['propertyCity'];
			row++;
		}

	},

	//removes all rows from a table
	eraseTable: function(tableId){
		table = document.getElementById(tableId);
		rowLength = table.rows.length;

		/*for(i=(rowLength-1);i>0;i--){
			table.deleteRow(i);
		}*/
		for(i=0;i<rowLength;i++){
			table.deleteRow(0);
		}
	}

}
