<!--
var classes;
// list is the current list object
// if forsearch is true then this is being used for a public search and requires 'ALL' options
// if it is false it is being used by the classifications editing 
function swaplist(list, strand, stage, nStages, forsearch) 
{
	var i;
	var j;
	var n;
	
// This is called by a list to change the values displayed by the child
	var save;
	var parentval;
	var childList;
	var found=-1;
	// used by class editing
	var sisterEdit;
	sisterEdit="edit"+strand+stage;
	if(stage < nStages-1)
	{
		childList=list.childList;
		n=stage+1;
		if(list.length > 0)
		{
			save= list.selectedIndex; 
			if(save <0)
			{
				save=0;
			}
			parentval=list.options[save].value; 
			pclasses=list.classes;
			// used by class editing
			if(document.forms['addform'].elements[sisterEdit] != null)
			{
				document.forms['addform'].elements[sisterEdit].value=list.options[save].text; 
			}
			if(pclasses != null)
			{
				// the parentval may be blank in which case we should empty the child list
				if(parentval >0)
				{
					// find the classes member that has the correct ID
					for(i=0;i<pclasses.length && (found<0);i++)
					{	
						if(pclasses[i].ID == parentval)
						{
							childList.options.length=0;
							// add in a blank line
							if(forsearch)
							{
								childList.options[0]=new Option("",-1);
							}
							for(j=0; j<((pclasses[i]).classes).length;j++)
							{
								if(forsearch)
								{
									l=j+1;
								}
								else
								{
									l=j;
								}
								childList.options[l]=new Option(((pclasses[i]).classes[j]).Name,((pclasses[i]).classes[j]).ID);
							}
							found=i;
							childList.classes=pclasses[i].classes;
						}
					}
				}
				else
				{
					childList.options.length=0;
					childList.classes=null;
				}
			}
			else
			{
				childList.options.length=0;
				childList.classes=null;
			}
		}
		else
		{
			childList.options.length=0;
			childList.classes=null;
		}
			
	}
	else if(!forsearch)
	{
		editchange(list, strand, stage);
	}

	// this can be called when we have just set the parent list to be empty (forsearch case) so there is nothing selected
	if(forsearch && stage < nStages-1 && childList.childList != null)
	{
		swaplist(childList, strand, stage+1, nStages);
	}
	else if(!forsearch && stage < nStages && childList!= null)
	{
		swaplist(childList, strand, stage+1, nStages);
	}

	return true;
}
// The first argument is the select 
function editchange(list, strand, stage)
{
	var sisterEdit;
	sisterEdit="edit"+strand+stage;
	var save;
	save= list.selectedIndex; 
	if(document.forms['addform'].elements[sisterEdit] != null)
	{
		if(save >=0)
		{
			document.forms['addform'].elements[sisterEdit].value=list.options[save].text; 
		}
		else
		{
			document.forms['addform'].elements[sisterEdit].value=""; 
		}		
	}
    return (true);
}
function deleteconfirm()
{
	var msg;
	msg = "Warning: Deleting this class will also delete any of its subclasses. Some classifications may also need to be removed by this action. Are you sure you want to delete the indicated class? ";
	return (confirm(msg));
}
//-->

