function FilterDays(monthObj, dayObj, yearObj)
{
	var daysInMonth = 31;
	if (monthObj.value == 4 || monthObj.value == 6 || monthObj.value == 9 || monthObj.value == 11)
	{
		daysInMonth = 30;
	}
	else if (monthObj.value == 2)
	{
		if (yearObj.value % 400 == 0 || (yearObj.value % 4 == 0 && yearObj.value % 100 != 0))
		{
			daysInMonth = 29;
		}
		else
		{
			daysInMonth = 28;
		}
	}

	var currentDay = dayObj.selectedIndex;
	ClearOptions(dayObj)
	{
		for (var day = 1; day <= daysInMonth; ++day)
		{
			AddOption(dayObj, day, day);
		}
	}
	if (currentDay < daysInMonth)
	{
		dayObj.selectedIndex = currentDay;
	}
	else
	{
		dayObj.selectedIndex = daysInMonth - 1;
	}
}

function ClearOptions(obj)
{
	while (obj.options.length > 0)
	{
		obj.options.remove(obj.options.length - 1);
	}
}

function AddOption(obj, text, value)
{
	var opt = document.createElement("OPTION");
	opt.text = text;
	opt.value = value;
	obj.options.add(opt);
}

function SortOptions(obj)
{
	var copy = new Array();
	for (i = 0; i < obj.options.length; i++)
	{
		copy[i] = new Array(obj[i].text, obj[i].value);
	}

	var inOrder = true;
	do
	{
		inOrder = true;
		for (i = 0; i < copy.length - 1; ++i)
		{
			if (copy[i][0] > copy[i + 1][0])
			{
				var temp = copy[i];
				copy[i] = copy[i + 1];
				copy[i + 1] = temp;
				inOrder = false;
			}
		}
	} while (!inOrder);
	
	ClearOptions(obj);
	for (i = 0; i < copy.length; ++i)
	{
		AddOption(obj, copy[i][0], copy[i][1]);
	}
}

function DeleteCalendarEntry(entry, evt, month, day)
{
	if (window.confirm("Delete calendar entry for " + evt + " on " + month + "/" + day + "?"))
	{
		window.location = "ParishCalendar.aspx?del=" + entry;
	}
}

function UpdateSpellCheck()
{
	var scc = document.getElementById("_spellCheckedContent");
	if (scc != null)
	{
		scc.value = document.getElementById("_spellCheckContent").innerHTML;
	}
	return true;
}

function CreateLink(ou, linkInfo)
{
	var link = "";
	if (linkInfo == "")
	{
		return;
	}
	if (linkInfo.substr(0, 4) == "URL:")
	{
		link = linkInfo.substr(4);
		if (link.substr(0, 7) != "http://")
		{
			link = "http://" + link;
		}
	}
	else if (linkInfo.search(/aspx$/) != -1)
	{
		link = linkInfo;
	}
	else
	{
		link = "WebPage.aspx?page=" + linkInfo;
	}
	ou.obj.insertLink(link);
}
