﻿// Toggle the visibility of an object
function toggleVisbility(o) {
	if (o.style.display == 'none') {
		o.style.display = 'block';
	} else {
		o.style.display = 'none';
	}
}

// Toggle the visibility of a DD in a DL
function toggleDDVisbility(dt) {
	var dd = dt.nextSibling;
	
	if (dd.nodeType == 3) {
		dd = dd.nextSibling;
	}
	
	if (dd.style.display == 'none') {
		dd.style.display = 'block';
	} else {
		dd.style.display = 'none';
	}
}

// Initialize a DL to toggle the DD whenever the DT is clicked
function initializeDL() {
	var dtList = document.getElementsByTagName('dt');
	
	for (var i = 0; i < dtList.length; i++) {
		dtList[i].onclick = function() {toggleDDVisbility(this)};
		dtList[i].style.cursor = 'pointer';
		toggleDDVisbility(dtList[i]);
	}
}

// Change the state of a checkbox
function changeCheckBoxState(id, checked) {
	var checkBox = document.getElementById(id);
	
	if (checkBox != null) {
		checkBox.checked = checked;
	}
}

// Change the state of an array of checkboxes
function changeCheckBoxArrayState(checkBoxIds, checked) {
	if (checkBoxIds != null) {
		for (var i = 0; i < checkBoxIds.length; i++) {
			changeCheckBoxState(checkBoxIds[i], checked);
		}
	}
}
