function addChapters(course_select){
	//alert('addChapters('+course_select.id+')');
	var ch_order_el = $('course_id').clone();
	ch_order_el.set('id','chapter_order');
	ch_order_el.injectAfter('course_id');
}

var lineCt = 0;
function addRow(tableName, formName, numCells, rowNumFromBottom){//(codeArrStr, keyArrStr, categoryArrStr){
	//var categoryArr = categoryArrStr.split('|');
	lineCt++;
	document.forms[0].lineCt.value=lineCt;
	//alert('lineCt = '+document.forms[0].lineCt.value);
	var bgcolor = "#c3d3d9";
	var itemTable = document.getElementById(tableName);
	
	var formElement = document.getElementById(formName);
	var tagName = formElement.tagName;
	var formInputs = formElement.elements.length;
	//alert('lineCt = '+lineCt+' formInputs = '+formInputs+'\ntagName = '+tagName);
	
	var rowsLength=itemTable.rows.length;
	itemTable.insertRow(rowsLength-rowNumFromBottom);
	itemRow=itemTable.rows[rowsLength-rowNumFromBottom];
	itemRow.id = "row"+lineCt;
	itemRow.insertCell(0);
	itemRow.insertCell(1);
	itemRow.insertCell(2);
	itemRow.insertCell(3);
	itemRow.insertCell(4);
	itemRow.insertCell(5);
	itemCells = itemRow.cells;
	
	////Cell 1: Account Code select boxes:
	acctCodeCell = itemCells.item(0);
	acctCodeCell.bgColor = bgcolor;
	acctCodeCell.align="center";
	acctCodeCell.vAlign="top";
	acctCodeCell.width="30%";
	var categoryOptions="";
	for(var y=0;y<(categoryArr.length);y++){
		categoryOptions+='<option value="'+categoryArr[y]+'">'+categoryArr[y]+'</option>';
	}
	acctCodeText = document.createTextNode('<table><tr><td class="job" nowrap><a name="client">Category</a></td><td class="jobEntry"><select name="category'+lineCt+'" class="job" size="1" onChange="loadAcctCodes(\''+codeArrStr+'\',\''+keyArrStr+'\',this.value,\''+lineCt+'\');"><option value="">...</option>'+categoryOptions+'</select></td><td width="100%">&nbsp;</td></tr><tr><td class="job" nowrap>Code</td><td class="jobEntry"><select name="code'+lineCt+'" class="job" id="code'+lineCt+'" size="1" onChange="loadAcctService(this.value,'+lineCt+');"><option value="">...</option></select></td><td width="100%">&nbsp;</td></tr></table>');
	acctCodeCell.innerHTML = acctCodeText.data;
	
	////Cell 2: Description textarea:
	descripCell = itemCells.item(1);
	descripCell.bgColor = bgcolor;
	descripCell.align="center";
	descripCell.vAlign="top";
	descripCell.width="45%";
	descripElement = document.createElement('textarea');
	descripElement.setAttribute("name", "descrip"+lineCt);
	//descripElement.name = "descrip"+lineCt;
	descripElement.setAttribute("id", "descrip"+lineCt);
	//descripElement.id = "descrip"+lineCt;
	descripElement.cols="60";
	descripElement.rows = "3";
	descripElement.setAttribute("class", "job");
	descripCell.appendChild(descripElement);
	
	//formElement.appendChild(descripElement);
	
	////Cell 3: Quantity field
	qtyCell = itemCells.item(2);
	qtyCell.bgColor = bgcolor;
	qtyCell.align="center";
	qtyCell.vAlign="top";
	qtyCell.width="5%";
	qtyElement = document.createElement('input');
	qtyElement.type = "text";
	qtyElement.align = "right";
	qtyElement.name = "qty"+lineCt;
	qtyElement.id = "qty"+lineCt;
	qtyElement.size="6";
	qtyElement.maxlength = "6";
	qtyElement.text = "$";
	qtyElement.setAttribute("class", "job");
	qtyElement.setAttribute("onBlur", "calcQty(this.value,"+lineCt+");calcSubtotal("+lineCt+");");
	qtyCell.appendChild(qtyElement);
}