		//show learning topics for a parent content
		function viewLearningTopics(ParentID) {
		var thisparentID	= document.getElementById("learningtopics_"+ParentID);
		xmlhttp.open("GET", "/inc/viewLearningTopics.php?ParentID="+ParentID+"&Show=Y", true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                thisparentID.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}	
		
		//show learning topics for a parent content
		function closeLearningTopics(ParentID) {
		var thisparentID	= document.getElementById("learningtopics_"+ParentID);
		xmlhttp.open("GET", "/inc/viewLearningTopics.php?ParentID="+ParentID+"&Show=N", true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                thisparentID.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}	
		
		
		//check all checkboxes
		function SetAllCheckBoxes(FormName, FieldName, CheckValue)
		{
			if(!document.forms[FormName])
				return;
			var objCheckBoxes = document.forms[FormName].elements[FieldName];
			if(!objCheckBoxes)
				return;
			var countCheckBoxes = objCheckBoxes.length;
			if(!countCheckBoxes)
				objCheckBoxes.checked = CheckValue;
			else
				// set the check value for all check boxes
				for(var i = 0; i < countCheckBoxes; i++)
					objCheckBoxes[i].checked = CheckValue;
		}
		
		//manage exclusions list
		function getExclusionList(ChildID, ParentID) {
		var categoryList	= document.getElementById("categoryList");
		xmlhttp.open("GET", "/inc/categoryOrder.php?FormAdmin="+Admin+"&View=ExclusionList&ParentID="+ParentID+"&ChildID="+ChildID+"&StaffID="+StaffID, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                categoryList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}	
				
		//edit library catalog entries
		function editLib(catalogID, ParentID, ContentType) {
		var List	= document.getElementById("editLib_"+catalogID);
		xmlhttp.open("GET", "/inc/child_subjectpages.php?FormAdmin="+Admin+"&catalogID="+catalogID+"&ParentID="+ParentID+"&ContentType="+ContentType, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                List.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}	
		
		//save order of re-arranged subject categories
		function savedOrder() {
		    var list 		= document.getElementById('phonetic1');
		    var items 		= list.getElementsByTagName('li');
		    var ids 		= '';
		    var hiddeninput = document.getElementById('OrderValue'); // the input field storing the order
			var categoryList=document.getElementById("categoryList");
			
		    for (var i = 0; i <items.length; i++)  {
		        if (i > 0) ids += '|';
		        var id = items[i].getAttribute("listId");
				ids += id;
		    }
		return ids;
		}
		
		//display all content for a child content category
		function getAllContent(ChildID, ParentID) {
		var categoryList	= document.getElementById("categoryList");
		xmlhttp.open("GET", "/inc/categoryOrder.php?FormAdmin="+Admin+"&View=Single&ParentID="+ParentID+"&ChildID="+ChildID+"&StaffID="+StaffID, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                categoryList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}	
						
		//re arranges order from side menu
		function reArrangeOrder(IDs, Admin) {
		var categoryList	= document.getElementById("categoryList");
		var ContentID 		= document.getElementById('ContentID').value;
		xmlhttp.open("GET", "/inc/categoryOrder.php?Order="+IDs+"&ContentID="+ContentID+"&FormAdmin="+Admin+"&View=All"+"&StaffID="+StaffID, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                categoryList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}
		
		//display content list
		function displayArrangeOrder() {
		//var Admin;
		if (!Admin) Admin = '0';
		//if (ContentID){
		
		var categoryList	= document.getElementById("categoryList");
		var ContentID 		= document.getElementById('ContentID').value;
		//var FormAdmin 		= document.getElementById('MyFormAdmin').value;
		xmlhttp.open("GET", "/inc/categoryOrder.php?ContentID="+ContentID+"&FormAdmin="+Admin+"&StaffID="+StaffID, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                categoryList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)
		//}
		}
		
		//display content list
		function displayArrangeOrderPublic(Admin, ContentID) {
		if (!Admin) Admin = '0';
		if (!StaffID) StaffID = '0';
		var categoryList	= document.getElementById("categoryList");
		//var ContentID 		= document.getElementById('ContentID').value;
		//var FormAdmin 		= document.getElementById('MyFormAdmin').value;
		xmlhttp.open("GET", "/inc/categoryOrder.php?ContentID="+ContentID+"&FormAdmin="+Admin+"&StaffID="+StaffID, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                categoryList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}
		
				
		//display search results
		function meshSearch(ID) {
		var searchList=document.getElementById("search");
		var string = escape(document.getElementById("String").value);
		//var xmlhttp = GetXMLHttp();
		//alert("empty");
		xmlhttp.open("GET", "/inc/meshtreeSearch.php?String="+string, true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                searchList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)

		}
		
		//display MeSH content on entry form
		function displayContent() {
		var meshList=document.getElementById("meshdisplay2");
		//var xmlhttp = GetXMLHttp();
		if (meshList.innerHTML == "") {
		//alert("empty");
		xmlhttp.open("GET", "/inc/meshtree3.php?", true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                meshList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)
		} else {
		 Toggle(item);
		//alert(div);
		}
		}
		
	
		
		//display MeSH content on entry form
		function displayMesh() {
		//var meshList=document.all("meshdisplay");
		var meshList=document.getElementById("meshdisplay");
		//meshList = new getObj("meshdisplay")
		//var xmlhttp = GetXMLHttp();
		if (meshList.innerHTML == "") {
		//alert("empty");
		xmlhttp.open("GET", "/inc/meshtree3.php?", true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                meshList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)
		} else {
		xmlhttp.open("GET", "/inc/meshtree3.php?", true);
        xmlhttp.onreadystatechange=function() 
        {
            if (xmlhttp.readyState==4)
            {
                // DEBUG: alert(xmlhttp.responseText);
                meshList.innerHTML = xmlhttp.responseText;
                //Toggle(item);
            }
        }
        xmlhttp.send(null)
		//alert(div);
		}
		
		}
		
		function expandTree(operation, categoryID, domObjID, meshUID) {
				if (!meshUID) meshUID = '00000000';
				
				xmlhttp.open("GET", "/inc/meshtree.php?op="+operation+'&amp;find='+categoryID+"&amp;uid="+meshUID, true);
				xmlhttp.onreadystatechange = function() {
					if (xmlhttp.readyState == 4) {
						resp = xmlhttp.responseText;
						dListObj = new getObj(domObjID);
						dListObj.obj.innerHTML = resp;
					}
				}
				xmlhttp.send(null);
			}
		
			
		  function retractTree(domObjID, returndomObjID, Name) {
				var div=document.getElementById(domObjID);
				
				//make children not visible
				div.style.display="none";
				
				
				xmlhttp.open("GET", "/inc/meshtree.php?op=heading2&amp;ID="+returndomObjID, true);
				xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4) {
				resp = xmlhttp.responseText;
				dListObj = new getObj(returndomObjID);
				dListObj.obj.innerHTML = resp;
					}
				}
				xmlhttp.send(null);
			}
		
		  function retractTreeRoot() {
				var meshList=document.getElementById("meshdisplay");
				xmlhttp.open("GET", "/inc/meshtree3.php?", true);
				xmlhttp.onreadystatechange = function() {
				if (xmlhttp.readyState == 4) {
				resp = xmlhttp.responseText;
				//dListObj = new getObj(domObjID);
				//alert(resp);
				meshList.innerHTML = resp;
					}
				}
				xmlhttp.send(null);
			}
			
		//show the mesh terms for a specific content item	
		function pick(action, ID) {
				//var StaffID = '<xsl:value-of select="$staffID"/>';
			    xmlhttp.open("GET", "/inc/meshtree2.php?action="+action+'&ID='+ID+'&StaffID='+StaffID, true);
				xmlhttp.onreadystatechange = showTerms;
			    xmlhttp.send(null);
			}
		
		function pickChild(action, ChildID, ParentID, ContentType, Both) {
				//this is if both child and parent mesh terms are needed.
				if (!Both) Both = '0';
			    xmlhttp.open("GET", "/inc/meshtree2.php?action="+action+'&ChildID='+ChildID+'&StaffID='+StaffID+'&ContentType='+ContentType+'&ParentID='+ParentID+'&Both='+Both, true);
				//if (xmlhttp.channel instanceof Components.interfaces.nsISupportsPriority) {
  				///xmlhttp.channel.priority = Components.interfaces.nsISupportsPriority.PRIORITY_LOWEST;
				//}
				xmlhttp.onreadystatechange = showTerms;
			    xmlhttp.send(null);
			}
		
		function showTerms() {
			    if(xmlhttp.readyState == 4){
			        var response = xmlhttp.responseText;
					ShowObj = new getObj("metaHidden");
					ShowObj.obj.innerHTML = response;
			}
		}
		
		
		function addOther(action, ID) {
		 		xmlhttp.open("GET", "/inc/meshtree2.php?action="+action+'&ID='+ID+'&StaffID='+StaffID, true);
				xmlhttp.onreadystatechange = showTerms;
			    xmlhttp.send(null);
		}
		
		//delete all terms from txt file
		function deleteMesh(action, ID) {
				if (!ID) ID = '0';
				//var StaffID = '<xsl:value-of select="$staffID"/>';
				xmlhttp.open("GET", "/inc/meshtree2.php?action="+action+'&StaffID='+StaffID+'&ID='+ID, true);
				xmlhttp.onreadystatechange = showTerms;
			    xmlhttp.send(null);
		}