function ShowSubSelect(classcode)
{
	if(classcode != "")
	{
		var strClassCode = document.all("strNavigatorValue").value;
		var arrClassCode = strClassCode.substring(1,strClassCode.length).split(",");
		var arrChkBox = document.all.item("selectbox");
		var bAll = true;
		var bcheck = false;
		var strFather = "";
		for(i=0;i<arrClassCode.length;i++)
		{
			if(i<arrChkBox.length && arrChkBox[i].value == classcode)
				bcheck = arrChkBox[i].checked;
			if(i<arrChkBox.length && classcode.indexOf(arrChkBox[i].value) == 0 && arrChkBox[i].value != classcode && arrChkBox[i].checked == true)
			{
				if(!bcheck)
					{strFather += ',' + i;
					arrChkBox[i].checked = false;}
			}
			if(i<arrChkBox.length && arrChkBox[i].value.indexOf(classcode) == 0 && arrChkBox[i].value != classcode)
			{
				if(bcheck)
					arrChkBox[i].checked = true;
				else
					arrChkBox[i].checked = false;
				if(!arrChkBox[i].checked)
					bAll = false;
			}
		}
		var arrFather = strFather.substring(1,strClassCode.length).split(",");
		if(arrFather.length != 0 && strFather != "") 
		{
			for(k=arrFather.length-1;k>=0;k--)
			{
					
					for(j=0;j<arrClassCode.length;j++)
					{
						if(j<arrChkBox.length && arrChkBox[j].value.indexOf(arrChkBox[arrFather[k]].value) == 0 && arrChkBox[arrFather[k]].value != arrChkBox[j].value)
						{
							arrChkBox[j].checked = true;
						}
					}
					arrChkBox[arrFather[k]].checked = true;
			}
		}
	
	}
}

function SetAllChildBoxCheckState(bChecked,groupName,valueList)
{
	var i;
	var group = document.all.item(groupName);
	if (group == null)
	{
		return;
	}
	if (group.length == null)
	{
		group.checked = bChecked;
		return;
	}
	for (i=0;i<group.length;i++)
	{
		if (valueList.indexOf("+" +group[i].value + "+") > -1)
		{
			group[i].checked = bChecked;
		}
	}	
}
function SetAllBoxCheckState(bChecked,groupName)
{	
	var i;
	var group = document.all.item(groupName);
	if (group == null)
	{
		return;
	}
	if (group.length == null)
	{
		group.checked = bChecked;
		return;
	}
	for (i=0;i<group.length;i++)
	{
		group[i].checked = bChecked;		
	}	
}

function SetFatherBoxCheckState(fatherName,groupName,valueList)
{
	var i;
	var all = true;	
	var father = document.all.item(fatherName);
	var group = document.all.item(groupName);
	if (group == null)
	{
		return;
	}
	if (group.length == null)
	{
		father.checked = valueList.index(group.value) > -1;
		return;
	}
	
	for (i=0;i<group.length;i++)
	{
		if (valueList.indexOf("+" +group[i].value + "+") > -1
		&& group[i].checked == false)
		{
			all = false;			
			break;
		}
	}	
	father.checked = all;		
}

function SetAllCheckedFlags(flagName,groupName)
{
	var i;
	var all = true;
	var flag = document.all.item(flagName);
	var group = document.all.item(groupName);
	
	if (group == null)
	{
		return;
	}
	
	
	if (group.length == null)
	{
		all = group.checked;		
	}
	else
	{
		for (i=0;i<group.length;i++)
		{			
			if (group[i].type == 'checkbox')
			{
				if (group[i].checked == false)
				{
					all = false;					
					break;
				}
			}
			else
			{				
				all = false;
				break;
			}
		}
	}
	if (all)
	{
		flag.value = "true";
	}
	else
	{
		flag.value = "false";
	}
}

function ShowAll(trPostfix)
{
	var i;
	for (i=1;;i++)
	{
		
		var testtest = document.all(trPostfix + i);		
		if (testtest != null)
		{			
			if (testtest.style.display == "none")
			{
				testtest.style.display = "";
			}						
		}
		else
		{
			break;
		}
	}
}

	
function ShowTree(treeName,buttonName)
{	
	var objLookingFor = document.all(buttonName);
	var posX = objLookingFor.offsetLeft;
	var posY = objLookingFor.offsetTop;
	var aBox = objLookingFor;
	do {
			aBox = aBox.offsetParent;
			posX += aBox.offsetLeft;
			posY += aBox.offsetTop;
		} while( aBox.tagName != "BODY" );
	document.all(treeName).style.top = posY+25;
	document.all(treeName).style.left = posX;
	document.all(treeName).style.width = screen.width - posX - 100;
	MM_showHideLayers(treeName,'','show');
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,d,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { d=v=args[i+2]; 
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; d=(d=='show')?'block':(d=='hide')?'none':d;}
    obj.visibility=v; obj.display=d;}
}	
function MM_openBrWindow(theURL,winName,features) { //v2.0
	var openwin	=	window.open(theURL,winName,features + ",scrollbars=yes");
	openwin.focus();
	openwin.moveTo(30,20);
}

function GetSelectedName(dbName,selectedName,showName)
{
	var selectedString = "<table border='0' width='100%'>\r\n";
	var count = 5;
	var width = 100/count + "%";	
	var bSelected = false;
	var currentRowTdCount = 0;
	var selectedNaviList = new Array();
	try
	{
		count = parseInt(document.all(dbName + "ColumnCount").value);
	}
	catch(err){}
	selectedString += "<tr>\r\n";
	for(var i=0; i<document.all(selectedName).length; i++)
	{
		var checkbox = document.all(selectedName)[i];
		if (checkbox.checked == true)
		{
			var shouldAdd = true;
			for (var kk=0;kk<selectedNaviList.length;kk++)
			{
				if (checkbox.value.indexOf(	selectedNaviList[kk]) == 0)
				{
					shouldAdd = false;
					break;
				}
			}
			if (shouldAdd == false)
			{
				continue;
			}
			selectedNaviList.push(checkbox.value);			
			bSelected = true;
			selectedString += "<td nowrap width=" + width + "><input type=checkbox name=" + showName + " value=" + checkbox.value + " checked>";
			selectedString += checkbox.id;		
			selectedString += "</td>\r\n";
			currentRowTdCount ++;
			if (currentRowTdCount == count)
			{
				currentRowTdCount = 0;
				selectedString += "</tr>\r\n<tr>\r\n";								
			}
		}
	}
	var ii;
	for (ii=currentRowTdCount; ii<count; ii++)
	{
		selectedString += "<td width='"+width+"'>&nbsp;</td>\r\n";		
	}
	selectedString += "</tr>\r\n";
	selectedString += "</table>";	
	if (bSelected)
	{
		document.all("tdSelectedContent" + dbName).innerHTML = selectedString;	
	}
}
function SelectedChild(groupName,boxValue,bChecked)
{
	var group = document.all.item(groupName);	
	if (group == null)
	{
		return;
	}
	for (var i=0;i<group.length;i++)
	{
		if (group[i].value.indexOf(boxValue) == 0)
		{
			group[i].checked = bChecked;
		}
	}
}
function SetFathorState1(groupName,code)
{
	if (code == null || code == "")
	{
		return;
	}
	var group = document.all.item(groupName);	
	if (group == null)
	{
		return;
	}	
	for (var i=0;i<group.length;i++)
	{
		if (group[i].value == code)
		{
			return;		
		}
		if (code.indexOf(group[i].value) == 0)
		{			
			SetFathorState2(groupName,group[i].value);			
		}
	}	
}
function SetFathorState2(groupName,fathorCode)
{
	if (fathorCode == null || fathorCode == "")
	{
		return;
	}
	var group = document.all.item(groupName);	
	if (group == null)
	{
		return;
	}
	var bAllChecked = true;
	var fathorIndex = 0;
	for (var i=0;i<group.length;i++)
	{
		if (group[i].value == fathorCode)
		{
			fathorIndex = i;
			continue;			
		}
		if (group[i].value.indexOf(fathorCode) == 0 && group[i].checked == false)
		{
			bAllChecked = false;			
		}
	}
	group[fathorIndex].checked = bAllChecked;
}
