
	function cbAllClick()
	{
		return _cbAllClick(document.frmMain.cbAll, 'cbAll', null);
	}
	
	function _cbAllClick(cbAll, cbAllName, Pref)
	{
		checked = cbAll.checked;
		for(i=0; i< frmMain.length;i++)
		{
			elem = frmMain.elements[i];
			if (elem.type=='checkbox' && elem.name != cbAllName && elem.checked != checked && !elem.disabled && 
				((Pref != null && elem.name.indexOf(Pref) == 0) || (Pref == null && elem.name.substring(0,1) != '_')))
			{
				elem.checked = checked;	
			}
		}
	}
	
	function cbClick()
	{
		return _cbClick(document.frmMain.cbAll, 'cbAll');
	}
	
	function _cbClick(cbAll, cbAllName)
	{
		cbAll.checked = (GetCheckedCount(cbAll, cbAllName, null) == GetCheckBoxesCount(cbAll, cbAllName, null));
		return true;
	}
	
	function GetCheckedCount(cbAll, cbAllName, Pref)
	{
		var count=0;
		for(i=0; i< frmMain.length;i++)
		{
			elem = frmMain.elements[i];
			if (elem.type=='checkbox' && elem.id != cbAllName && elem.checked && !elem.disabled && 
				((Pref != null && elem.name.indexOf(Pref) == 0) || (Pref == null && elem.name.substring(0,1) != '_')))
				count++;	
		}
		return count;
	}
	function GetCheckBoxesCount(cbAll, cbAllName, Pref)
	{
		var count=0;
		for(i=0; i< frmMain.length;i++)
		{
			elem = frmMain.elements[i];
			if (elem.type=='checkbox' && elem.id != cbAllName && !elem.disabled && 
				((Pref != null && elem.name.indexOf(Pref) == 0) || (Pref == null && elem.name.substring(0,1) != '_')))
				count++;	
		}
		return count;
	}
	
	// Second table in Page
	
	function Second_cbClick(cbAllID, Pref)
	{
		cbAll = document.getElementById(cbAllID);
		cbAll.checked = (GetCheckedCount(cbAll, cbAllID, Pref) == GetCheckBoxesCount(cbAll, cbAllID, Pref));
		return true;
	}
	
	function Second_cbAllClick(cbAllID, Pref)
	{
		cbAll = document.getElementById(cbAllID);
		return _cbAllClick(cbAll, cbAllID, Pref);
	}
	