var xv=0;
function addRow(r)
{
	var root = r.parentNode;//the root
	var allRows = root.getElementsByTagName('tr');//the rows' collection
	var focusTR = document.activeElement.parentElement.parentElement;
	refTRIndex = focusTR.rowIndex;
	scount++;
 	var cRow = allRows[1].cloneNode(true)//the clone of the 1st row	
	var cInp = cRow.getElementsByTagName('input');//the inputs' collection of the 1st row
	var cIna = cRow.getElementsByTagName('a');//the links' collection of the 1st row
	for(var i=0;i<cInp.length;i++)
	{
		var maini=cInp[i].getAttribute('name').split("_");
		cInp[i].setAttribute('name',maini[0]+'_'+scount)
	}
	
	scount++;
	root.appendChild(cRow);//appends the cloned row as a new row
	if(allRows.length>1)clean_tr_special(cRow);
	return false;
}

function delete_tr(r)
{
	var root = r.parentNode;//the root
	var allRows = root.getElementsByTagName('tr');//the rows' collection
	if(allRows.length>2)
	{
		root.removeChild(r);
	}
	clean_tr(r);
	return false;
}

function clean_tr(r)
{
	var cInp = r.getElementsByTagName('input');//the inputs' collection of the 1st row
	for(var i=0;i<cInp.length;i++)
	{
		cInp[i].value='';
	}
	var cIns = r.getElementsByTagName('select');//the inputs' collection of the 1st row
	for(var i=0;i<cIns.length;i++)
	{
		cIns[i].value='';
	}
	return false;
}

function clean_tr_special(r)
{
	var cInp = r.getElementsByTagName('input');//the inputs' collection of the 1st row
	for(var i=0;i<cInp.length;i++)
	{
		var ar=cInp[i].name.split("_");
		if(ar[0]=='FileName')cInp[i].value='';
	}
	return false;
}
