/*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function inserts row in table, so table_name is the id of the target table, if you passed empty row_index, it will insert it at the end of the table
,then it creates the num_columns in this row.
if you want to fill this columns, you can pass array of content of columns, 
array length got to be equals num_columns passed, so each node in array will be inserted in the corresponding cell in the row
*/
function insert_row(table_name,row_index,num_columns,content_array)
{
	//alert(row_index);
	var table=document.getElementById(table_name);
	if(row_index!='')
	{
		var row = table.insertRow(row_index);
		for(var i=0;i<num_columns;i++)
		{
			var column=row.insertCell(i);
			if(content_array)
				column.innerHTML=content_array[i];
			
		}
	}
	else
	{
		var row = table.insertRow(table.rows.length);
		for(var i=0;i<num_columns;i++)
		{
			var column=row.insertCell(i);
			if(content_array)
				column.innerHTML=content_array[i];
		}
	}
	return row;
	
}
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function deletes row in the target table, so table_name is the id of the target table, and row_index is the row number in the table that you want to delete 
NOTICE: row index in tables is zero based, and when row is deleted the index of other rows will be regenerated so that they are indexed in sequence
*/
function delete_row(table_name,row_index)
{
	if(document.getElementById(table_name))
		document.getElementById(table_name).deleteRow(row_index);
	else
		return false;
}

/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function deletes row in the target table, so table_name is the id of the target table, and row_index is the row number in the table that you want to delete 
NOTICE: row index in tables is zero based, and when row is deleted the index of other rows will be regenerated so that they are indexed in sequence
*/
function delete_table_rows(table_name,start_row,count)
{
	var table = document.getElementById(table_name);
	if(count!='' && count!=0)
	{
		for(var i=start_row;i<table.rows.length && i<start_row+count;i++)
		{
			delete_row(table_name,i);
		}
	}
	else
	{
		for(var i=start_row;i<table.rows.length;i++)
		{
			delete_row(table_name,i);
		}
	}
	
}