<!--
function openPopup(destinationURL, windowName, windowWidth, windowHeight) {

	if (!windowName) windowName = 'popup';
	if (!windowWidth) windowWidth = 600;
	if (!windowHeight) windowHeight = 450;

	windowLeft = (screen.width - windowWidth) / 2;
	windowTop = (screen.height - windowHeight) / 2;
	if (windowLeft < 0) windowLeft = 0;
	if (windowTop < 0) windowTop = 0;

	windowOptions = 'width=' + windowWidth + ',height=' + windowHeight + ',top=' + windowTop + ',left=' + windowLeft + ',location=no,status=no,resizable=no,menubars=no,toolbars=no,scrollbars=yes';
	window.open(destinationURL, windowName, windowOptions);

}

function swapImage(elementID, newImgSrc) {

	if (document.getElementById) {
		theElement = document.getElementById(elementID);
	} else if (document.all) {
		theElement = document.all[elementID];
	}

	if (theElement) {
		theElement.src = newImgSrc;
	}

}

/*
	Toggles an element on the page, based on the current state of a checkbox.
	checkboxId = the ID attribute of the checkbox to check
	elementIdToToggle = the ID attribute of the element to toggle
	displayAttribute = the display attribute to use (typically 'block') when
		the value of the checkbox element is set to the requiredValue arg.
*/
function toggleElementDisplayIfCheckboxChecked(checkboxId, requiredValue, elementIdToToggle, displayAttribute) {

	if (!displayAttribute) displayAttribute = 'block';

	checkboxElement = document.getElementById(checkboxId);
	elementToToggle = document.getElementById(elementIdToToggle);

	if (checkboxElement && elementToToggle) {

		if ((checkboxElement.checked && requiredValue == 1) || (!checkboxElement.checked && requiredValue != 1)) {
			var displayValue = displayAttribute;
		} else if ((checkboxElement.checked && requiredValue != 1) || (!checkboxElement.checked && requiredValue == 1)) {
			var displayValue = 'none';
		}

		elementToToggle.style.display = displayValue;

	}

}

function toggleElementDisplay(elementIdToToggle, displayAttribute) {

	if (!displayAttribute) displayAttribute = '';

	elementToToggle = document.getElementById(elementIdToToggle);
	if (elementToToggle) {

		var currentValue = elementToToggle.style.display;
		if (currentValue == displayAttribute) {
			displayValue = 'none';
		} else {
			displayValue = displayAttribute;
		}

		elementToToggle.style.display = displayValue;

	}

}

function toggleElementText(elementIdToToggle, text1, text2) {

	elementToToggle = document.getElementById(elementIdToToggle);
	if (elementToToggle) {

		if (elementToToggle.innerHTML == text1) {
			textValue = text2;
		} else {
			textValue = text1;
		}

		elementToToggle.innerHTML = textValue;

	}

}

function setHelpText(helpText, helpTextElementId) {

	if (helpTextElementId == null) {
		helpTextElementId = 'help-text';
	}

	helpTextElement = document.getElementById(helpTextElementId);
	if (helpTextElement) {
		helpTextElement.innerHTML = helpText;
	}

}

function clearHelpText(helpTextElementId) {

	setHelpText('<p>Help with this form is available by moving your mouse over the part of the form you are stuck on.</p>', helpTextElementId);

}

function tabSwitch(name) {
	var selectedTab = document.getElementById('tab-' + name);
	var selectedTabContent = document.getElementById('tabcontents-' + name);

	if (selectedTab && selectedTabContent) {
		// get the parent DIV of the tabcontents and the tab uls
		var tabUL = selectedTab.parentNode;
		var contentsContainer = selectedTabContent.parentNode;

		var tabs = tabUL.getElementsByTagName('li');
		var contents = contentsContainer.getElementsByTagName('div');

		for (var c = 0; c < tabs.length; c++) {
			var tab = tabs[c];
			if (tab.id == 'tab-' + name) {
				tab.className = 'current-tab';
			} else {
				tab.className = '';
			}
		}

		for (var c = 0; c < contents.length; c++) {
			var content = contents[c];
			if (content.id.substr(0, 12) == "tabcontents-") {
				if (content.id == 'tabcontents-' + name) {
					content.style.display = '';
				} else {
					content.style.display = 'none';
				}
			}
		}
	}
}

function clearTextBox(inputBox, textString, cssClass) {
	if (inputBox) {
		if (!textString || inputBox.value == textString) {
			inputBox.value = '';
		}
		if (cssClass) {
			inputBox.className = cssClass;
		}
	}
	return true;
}

function setTextBox(inputBox, textString, cssClass) {
	if (inputBox) {
		if (inputBox.value == '') {
			inputBox.value = textString;
			if (cssClass) {
				inputBox.className = cssClass;
			}
		}
	}

	return true;
}

//-->
