/**
+	isIE()
+
+	@requires
+		none
+
+	@arguments
+		none
*/
function isIE() {
	if (navigator.appName.indexOf("Microsoft Internet Explorer") != -1) { return true; }
	else { return false; }
}

/**
+	toggle()
+
+	@requires
+		isIE()
+
+	@arguments
+		id - the id of the DOM object you wish to toggle
*/
function toggle(id) {
	var e = document.getElementById(id);
	var d = "block";
	if (!isIE()) {
		if (e.insertRow) { d = "table"; }
		else if (e.insertCell) { d = "table-row"; }
	}
	if (e.style.display == "none" || e.style.display == "") { e.style.display = d; }
	else { e.style.display = "none"; }
	return;
}

/**
+	clearField()
+
+	@requires
+		none
+
+	@arguments
+		field - the DOM object whose value you wish to clear (will almost always be the self-reference of this)
+		text - the default text of the field
*/
function clearField(field, text) {
	if (field.value == text) { field.value = ""; }
	return;
}

/**
+	fillField()
+
+	@requires
+		isblank()
+
+	@arguments
+		field - the DOM object whose value you wish to fill (will almost always be the self-reference of this)
+		text - the default text of the field
*/
function fillField(field, text) {
	if (isblank(field.value)) { field.value = text; }
	return;
}

// finds if a string is blank (nothing but spaces)
function isblank(x) {
	var blank = true;
	for (i = 0; i < x.length; i++) {
		if (x.charAt(i) != ' ') { blank = false; }
	}
	return blank;
}

// finds if a form value is empty
function isempty(x) {
	if (x == "" || isblank(x)) { return true; }
	else { return false; }
}

// finds if a select box has not been changed
function unchanged(x) {
	if (x.selectedIndex == 0) { return true; }
	else { return false; }
}


// Toggle div that only shows one at a time
function toggleone(thechosenone) {
	var togglebox = document.getElementsByTagName("div");
			for(var x=0; x<togglebox.length; x++) {
			name = togglebox[x].getAttribute("name");
			if (name == 'togglebox') {
				if (togglebox[x].id == thechosenone) {
					togglebox[x].style.display = 'block';
				}
				else {
					togglebox[x].style.display = 'none';
				}
			}
	}
}