﻿/*alert('loading misc.js');*/
function SelectSignupRow(code)
{
	var rowId = 'row' + code;
	var row = document.getElementById(rowId); 
	
	row.cells[0].style.backgroundColor = '#FFD2DF';
	row.cells[1].style.backgroundColor = '#FFD2DF';
	row.cells[2].style.backgroundColor = '#FFD2DF';
	row.cells[3].style.backgroundColor = '#FFD2DF';

	var undoId = 'undo' + code;
	var undo = document.getElementById(undoId);
	
	undo.style.display = 'inline';
}
function DeselectSignupRow(code, restoreBackgroundColor)
{
	var rowId = 'row' + code;
	var row = document.getElementById(rowId); 
	
	row.cells[0].style.backgroundColor = restoreBackgroundColor;
	row.cells[1].style.backgroundColor = restoreBackgroundColor;
	row.cells[2].style.backgroundColor = restoreBackgroundColor;
	row.cells[3].style.backgroundColor = restoreBackgroundColor;

	var rbId = 'rb' + code + 'C';
	var rb = document.getElementById(rbId); 
	rb.checked = false;
	
	var rbId = 'rb' + code + 'J';
	var rb = document.getElementById(rbId); 
	rb.checked = false;
	
	var rbId = 'rb' + code + 'M';
	var rb = document.getElementById(rbId); 
	rb.checked = false;

	var undoId = 'undo' + code;
	var undo = document.getElementById(undoId);
	
	undo.style.display = 'none';
}

function HideShowDiv(divIdToHide, divIdToShow)
{
	var divIdToHide = document.getElementById(divIdToHide);
	var divIdToShow = document.getElementById(divIdToShow);
	if (!divIdToShow || !divIdToHide)
		alert('divIdToHide or divIdToShow not found');
	else
	{
		divIdToHide.style.display = 'none';
		divIdToShow.style.display = 'block';
	}
}


function ShowMinistry(pSelectedChildId)
{
	var divMain = document.getElementById('divMain');
	if (!divMain)
	{
		alert('divMain not found');
		return;
	}

	var children = divMain.getElementsByTagName('DIV');
	if (children)
	{
		var iImmediateChildren = 0;
		for (var j=0; j<children.length; j++)
		{
			var child = children[j];
			if (child.parentNode.id == 'divMain')
			{
				iImmediateChildren++;
				if (child.id == pSelectedChildId + 'TopNav')
					child.className = 'cssMainNav';
				else if (child.id == pSelectedChildId + 'BottomNav')
					child.className = 'cssMainNav';
				else if (child.id == pSelectedChildId)
					child.className = '';
				else
					child.className = 'cssDisplayNone';
			}
		}
		//alert('all children of ' + pParentId + ':' + children.length)
		//alert('immediate children:' + iImmediateChildren);
	}
}

function SetClassOnChildren(pParentId, pSelectedChildId, pChildDefaultClassName, pChildSelectedClassName)
{
	var vParent = document.getElementById(pParentId);
	if (!vParent)
	{
		alert('pParentId not found');
		return;
	}

	var children = vParent.getElementsByTagName('DIV');
	if (children)
	{
		var iImmediateChildren = 0;
		for (var j=0; j<children.length; j++)
		{
			var child = children[j];
			if (child.parentNode.id == pParentId)
			{
				iImmediateChildren++;
				if (child.id.substr(0,pSelectedChildId.length) == pSelectedChildId)
					child.className = pChildSelectedClassName;
				else
					child.className = pChildDefaultClassName;
			}
		}
		//alert('all children of ' + pParentId + ':' + children.length)
		//alert('immediate children:' + iImmediateChildren);
	}
}

function ShowSingleChildDiv(senderParentId, senderId, parentDivId, childDivId)
{
	if (senderParentId != '' && senderId != '')
	{
		var divSenderParent = document.getElementById(senderParentId);;
		if (!divSenderParent)
		{
			alert('divSenderParent not found');
			return;
		}
		var senderParentChildrenDivs = divSenderParent.getElementsByTagName('A');
		if (!senderParentChildrenDivs)
		{
			alert('senderParentChildrenDivs not found');
			return;
		}
		for (var i=0; i<senderParentChildrenDivs.length; i++)
		{
			if (senderParentChildrenDivs[i].id == senderId)
				senderParentChildrenDivs[i].className ='cssSilverBullet cssSilverBulletSelected';
			else
				senderParentChildrenDivs[i].className ='cssSilverBullet';
		}
	}

	var parentDiv = document.getElementById(parentDivId);
	if (!parentDiv)
	{
		alert('parentDiv not found');
		return;
	}

	var childrenDivs = parentDiv.getElementsByTagName('DIV');
	if (childrenDivs)
	{
		var iImmediateChildren = 0;
		for (var j=0; j<childrenDivs.length; j++)
		{
			var childDiv = childrenDivs[j];
			if (childDiv.parentNode.id == parentDivId)
			{
				iImmediateChildren++;
				if (childDiv.id == childDivId)
					childDiv.className = '';
				else
					childDiv.className = 'cssDisplayNone';
			}
		}
		//alert('all children of ' + parentDivId + ':' + childrenDivs.length)
		//alert('immediate children:' + iImmediateChildren);
	}
}


