function emc_subcategories_validate() {
	var deleteCheckboxes = document.getElementsByName('delete_subcategory[]');
	var howManyCheckboxes = deleteCheckboxes.length;
	var howManyCatsToDel = 0;
	for (i=0;i<howManyCheckboxes;i++) {
		if (deleteCheckboxes[i].checked == true) howManyCatsToDel++;
	}
	if (howManyCatsToDel > 0) {
		if (howManyCatsToDel == 1) {
			confirmMsg = "You are about to delete a subcategory.  If any articles exist within the subcategory they will be deleted forever.  Are you sure you want to proceed?";
		} else if (howManyCatsToDel > 1) {
			confirmMsg = "You are about to delete "+howManyCatsToDel+" subcategories.  If any articles exist within the subcategories they will be deleted forever.  Are you sure you want to proceed?";
		}
		answer = confirm(confirmMsg);
		if (answer) return true;
		else return false;
	} else return true;
}
function emc_anotherNewSubcat(parentId,inputNum) {
	var newInputNum = inputNum + 1;
	var newInputName = 'new_subcategory_'+parentId+'_'+newInputNum;
	var existingSpanId = 'emc_addAnotherSubcat_'+parentId+'_'+inputNum;
	var newSpanId = 'emc_addAnotherSubcat_'+parentId+'_'+newInputNum;
	
	// create the new table row
	var tableRow = document.createElement("TR");
	
	// create the first table cell
	var td1 = document.createElement("TD");
	td1.className = "row1";
	td1.style.textAlign = "left";
	td1.style.width = "40%";
	// add text to the input box
	td1.appendChild(document.createTextNode(" "));
	
	// create the second table cell
	var td2 = document.createElement("TD");
	td2.className = "row1";
	td2.style.textAlign = "left";
	td2.style.width = "60%";
	
	// create the input box
	var input = document.createElement("INPUT");
	input.type = "text";
	input.id = newInputName;
	input.name = newInputName;
	input.style.width = "80%";
	td2.appendChild(input);
	
	// create the span with link to add another
	var span = document.createElement("SPAN");
	span.id = newSpanId;
	span.appendChild(document.createTextNode(" "));
	
	// create the anchor tag
	var link = document.createElement("A");
	link.href = 'javascript:emc_anotherNewSubcat('+parentId+','+newInputNum+')';
	link.title = "Add another subcategory to this category";
	
	// create the image
	var image = document.createElement("IMG");
	image.src = "design/pic/emc_add.png";
	image.alt = "Add another subcategory to this category";
	image.style.border = '0';
	image.style.verticalAlign = 'middle';
	
	// put everything together and add it to the 2nd table cell
	link.appendChild(image);
	span.appendChild(link);
	td2.appendChild(span);
	
	// add the table cells to the table row
	tableRow.appendChild(td1);
	tableRow.appendChild(td2);
	
	//remove the add another link from the existing last row
	document.getElementById(existingSpanId).innerHTML = '';
	
	// add in the table row
	document.getElementById('emc_parent_body'+parentId).appendChild(tableRow);
}
document.getElementsByClassName = function(cl) {
	var retnode = [];
	var myclass = new RegExp('\\b'+cl+'\\b');
	var elem = this.getElementsByTagName('*');
	for (var i = 0; i < elem.length; i++) {
		var classes = elem[i].className;
		if (myclass.test(classes)) retnode.push(elem[i]);
	}
	return retnode;
}
