




function tbgetbody(tbele) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(!(tbele.tagName=='TABLE'||tbele.tagName=='table')) return -1;
	return tbele.getElementsByTagName('tbody')[0];
}
function tbgetrow(tbele,rowno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(rowno<1) return -1;
	if(tbele.rows.length<rowno) return -1;
	return tbele.rows[rowno-1];
}
function tbgetcell(tbele,rowno,cellno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(rowno<1||cellno<1) return -1;
	if(tbele.rows.length<rowno) return -1;
	if(tbele.rows[rowno-1].cells.length<cellno) return -1;
	return tbele.rows[rowno-1].cells[cellno-1];
}
function tbgettotalrow(tbele) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	return tbele.rows.length;
}
function tbgettotalcell(tbele,rowno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(tbele.rows.length<1||tbele.rows.length<rowno) return -1;
	return tbele.rows[rowno-1].cells.length;
}
function tbinsertrow(tbele,after,totalcell) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	var tbbody=tbgetbody(tbele); if(tbbody==-1) return -1;
	if(tbele.rows.length<after) return -1;
	var tr=document.createElement('tr');
	for(var c1=0;c1<totalcell;c1++) {
		var td=document.createElement('td');
		tr.appendChild(td);
	}
	if(after==0) tbbody.insertBefore(tr,tbele.rows[0]);
	else if(after>0) insertAfter(tbbody,tr,tbele.rows[after-1]);
	else tbbody.appendChild(tr);
}
function tbinsertcell(tbele,rowno,after,totalcell) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(tbele.rows.length<1||tbele.rows.length<rowno) return -1;
	var tr=tbele.rows[rowno-1];
	if(tr.length<after) return -1;
	for(var c1=0;c1<totalcell;c1++) {
		var td=document.createElement('td');
		if(after==0) tr.insertBefore(td,tr.cells[0]);
		else if(after>0) insertAfter(tr,td,tr.cells[after-1]);
		else tr.appendChild(td);
	}
}
function tbremoverow(tbele,rowno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(rowno<1) return -1;
	if(tbele.rows.length<rowno) return -1;
	removeele(tbele.rows[rowno-1]);
}
function tbremovecell(tbele,rowno,cellno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(rowno<1||cellno<1) return -1;
	if(tbele.rows.length<rowno) return -1;
	if(tbele.rows[rowno-1].cells.length<cellno) return -1;
	removeele(tbele.rows[rowno-1].cells[cellno-1]);
	if(tbele.rows[rowno-1].cells.length<1) removeele(tbele.rows[rowno-1]);
}
function tbemptycell(tbele,rowno,cellno) {
	if(typeof(tbele)=='string') tbele=document.getElementById(tbele); if(!tbele) return -1;
	if(rowno<1||cellno<1) return -1;
	if(tbele.rows.length<rowno) return -1;
	if(tbele.rows[rowno-1].cells.length<cellno) return -1;
	emptyele(tbele.rows[rowno-1].cells[cellno-1]);
}





