function show_child_menu_for(idofchild, show_action, hide_action) {
	var item = document.getElementById(idofchild);
	newid = 'l_'+idofchild;
	var item2 = document.getElementById(newid);	
	newid = 't_'+idofchild;
	var item3 = document.getElementById(newid);		
	if (item.style.display == 'none') {
		item.style.display = "";
		item2.style.display = "";
		item2.innerHTML = hide_action + " &uarr;";
		item3.style.display = "none";
	} else {
		item.style.display = 'none';		
		item2.style.display = "";
		item2.innerHTML = show_action + " &darr;";
		item3.style.display = "";
	}
	return true;
}

var increment_wikiviewed_count = (function() {
	var counted = false;
	var xhrfactories = [
		function () {return new XMLHttpRequest()},
		function () {return new ActiveXObject("Msxml2.XMLHTTP")},
		function () {return new ActiveXObject("Msxml3.XMLHTTP")},
		function () {return new ActiveXObject("Microsoft.XMLHTTP")},
	];
	
	var increment = function(materialid) {
		if (counted) return;
		var xhr = false;
		for (var i=0;i<xhrfactories.length;i++) {
			try {
				xhr = xhrfactories[i]();
			}
			catch (e) {
				continue;
			}
			break;
		}
		if (!xhr) return;
		xhr.open('POST', '/bills/wikicount/'+materialid, true);
		xhr.send(null);
		xhr = null;
		counted = true;
		return;
	}
	return increment;
})();

function show_and_count_child_menu_for(materialid, idofchild, show_action, hide_action) {
	increment_wikiviewed_count(materialid);
	show_child_menu_for(idofchild, show_action, hide_action);
}

function show_child_toc_link(idofchild, show_action, hide_action) {
	var item = document.getElementById(idofchild);
	if (item.style.display == 'none') {
		item.style.display = "";
		newid = 'l_'+idofchild;
		var item2 = document.getElementById(newid);
		item2.style.display = "";
		item2.innerHTML = hide_action + " &uarr;";		
	} 
	return true;
}

function hide_text_on_load(idofchild, show_action, hide_action) {
	var item = document.getElementById(idofchild);
	if (item) {
		item.style.display = 'none';
		newid = 'l_'+idofchild;
		var item2 = document.getElementById(newid);
		item2.style.display = "";
		item2.innerHTML = show_action + " &darr;";	
		return true;
	}
	return false;
}