
//======================================================
//==用于 AddUserAccount.aspx 和 ModifyUserAccount.aspx，在 UserAccountUI 中用来对某些权限全选，全不选
//==2010-11-24：该 js 集不再使用 （UserForums 机制停用）
//======================================================

function ReadEnabledCheckAll(Forums,CommunityUserRole)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkReadEnabled" + i;		
		document.getElementById(checkBoxName).checked=true;
	}
	
	var oCommunityUserRole=document.getElementById("checkUserRole" + CommunityUserRole);
	oCommunityUserRole.checked=true;
}

function ReadEnabledCheckNone(Forums)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkReadEnabled" + i;		
		document.getElementById(checkBoxName).checked=false;

		var checkBoxNameTopicWriteEnabled;
		checkBoxNameTopicWriteEnabled="checkTopicWriteEnabled" + i;		
		document.getElementById(checkBoxNameTopicWriteEnabled).checked=false;

		var checkBoxNameFollowUpWriteEnabled;
		checkBoxNameFollowUpWriteEnabled="checkFollowUpWriteEnabled" + i;		
		document.getElementById(checkBoxNameFollowUpWriteEnabled).checked=false;
	}
}

function TopicWriteEnabledCheckAll(Forums,CommunityUserRole)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkTopicWriteEnabled" + i;
		document.getElementById(checkBoxName).checked=true;
		
		var checkBoxNameReadEnabled;
		checkBoxNameReadEnabled="checkReadEnabled" + i;
		document.getElementById(checkBoxNameReadEnabled).checked=true;
	}

	var oCommunityUserRole=document.getElementById("checkUserRole" + CommunityUserRole);
	oCommunityUserRole.checked=true;
}

function TopicWriteEnabledCheckNone(Forums)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkTopicWriteEnabled" + i;
		document.getElementById(checkBoxName).checked=false;
	}
}

function FollowUpWriteEnabledCheckAll(Forums,CommunityUserRole)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkFollowUpWriteEnabled" + i;
		document.getElementById(checkBoxName).checked=true;
	
		var checkBoxNameReadEnabled;
		checkBoxNameReadEnabled="checkReadEnabled" + i;
		document.getElementById(checkBoxNameReadEnabled).checked=true;
	}

	var oCommunityUserRole=document.getElementById("checkUserRole" + CommunityUserRole);
	oCommunityUserRole.checked=true;
}

function FollowUpWriteEnabledCheckNone(Forums)
{
	for (i=0; i<=Forums-1; i++)
	{
		var checkBoxName;
		checkBoxName="checkFollowUpWriteEnabled" + i;
		document.getElementById(checkBoxName).checked=false;
	}
}


//======================================================
//==在点击 Forum 的 checkTopicWriteEnabled, checkFollowUpWriteEnabled 的时候，选中了二者或二者之一，则必须同时选中 checkReadEnabled （就是说：一个论坛，但凡允许发帖子或会帖子，则必定也允许浏览了）
//======================================================
function ReadEnabledAutoCheck(Forum)
{
	var oReadEnabled=document.getElementById("checkReadEnabled" + Forum);
	var oTopicWriteEnabled=document.getElementById("checkTopicWriteEnabled" + Forum);
	var oFollowUpWriteEnabled=document.getElementById("checkFollowUpWriteEnabled" + Forum);
	
	if (oTopicWriteEnabled.checked==true || oFollowUpWriteEnabled.checked==true)
	{
		oReadEnabled.checked=true;
	}	
}

//======================================================
//==当 checkReadEnabled 被 Check Off 的时候，强迫 checkTopicWriteEnabled 和 checkFollowUpWriteEnabled 同时 Check Off
//======================================================
function ReadEnabledCheckOff(Forum,ReadEnabledCheckBox)
{
	var oTopicWriteEnabled=document.getElementById("checkTopicWriteEnabled" + Forum);
	var oFollowUpWriteEnabled=document.getElementById("checkFollowUpWriteEnabled" + Forum);
	
	if (ReadEnabledCheckBox.checked==false)
	{
		oTopicWriteEnabled.checked=false;
		oFollowUpWriteEnabled.checked=false;
	}
}

//======================================================
//==在点击 Forum 的 checkReadEnabled, checkTopicWriteEnabled, checkFollowUpWriteEnabled 的时候，三者中哪怕有任一个被选中，则 Community 觉得自动被选中）
//======================================================
function CommunityUserRoleAutoCheck(Forums,CommunityUserRole)
{
	var oCommunityUserRole=document.getElementById("checkUserRole" + CommunityUserRole);

	for (i=0; i<=Forums-1; i++)
	{
		var oReadEnabled=document.getElementById("checkReadEnabled" + i);
		var oTopicWriteEnabled=document.getElementById("checkTopicWriteEnabled" + i);
		var oFollowUpWriteEnabled=document.getElementById("checkFollowUpWriteEnabled" + i);	
		
		if (oReadEnabled.checked==true || oTopicWriteEnabled.checked==true || oFollowUpWriteEnabled.checked==true)
		{
			oCommunityUserRole.checked=true;
		}
	}
}

//======================================================
//==在点击 Forum 的 checkReadEnabled, checkTopicWriteEnabled, checkFollowUpWriteEnabled 的时候，三者中哪怕有任一个被选中，则 Community 觉得自动被选中）
//======================================================
function CommunityUserRoleCheckOff(Forums,CommunityUserRoleCheckBox)
{
	if (CommunityUserRoleCheckBox.checked==false)
	{
		for (i=0; i<=Forums-1; i++)
		{
			var oReadEnabled=document.getElementById("checkReadEnabled" + i);
			var oTopicWriteEnabled=document.getElementById("checkTopicWriteEnabled" + i);
			var oFollowUpWriteEnabled=document.getElementById("checkFollowUpWriteEnabled" + i);	
			
			oReadEnabled.checked=false;
			oTopicWriteEnabled.checked=false;
			oFollowUpWriteEnabled.checked=false;
		}
	}
}

