//Code for FPA Updater form
var nowdate = new Date();
var delimIDs = "^"
var delimFields = "#"
var delimParams = "|"

function selectoption(thisID) {
	//thisID should be the id of an option element within a select in a form
	if (!thisID==''){document.getElementById(thisID).selected = true;}
}
function placetext(thisID,thisText) {
	//thisID should be the id of an text input element in a form
	document.getElementById(thisID).value = thisText;
}
function checkbool(thisID,bool) {
	//thisID should be the id of a checkbox input element in a form
	document.getElementById(thisID).checked = bool;
}
function checkit(thisID,val) {
	//thisID should be the id of a checkbox input element in a form
	document.getElementById(thisID).checked = (val=='on');
}
//FORM VALIDATION ROUTINES
function getselect(thisID) {
	//thisID should be the id of an select element in a form
	return document.getElementById(thisID).value;
}
function gettext(thisID) {
	//thisID should be the id of an text input element in a form
	return document.getElementById(thisID).value;
}
function getchecked(thisID) {
	//thisID should be the id of a checkbox input element in a form
	return document.getElementById(thisID).checked;
}
function getbool(thisID) {
	//thisID should be the id of a checkbox input element in a form
	return document.getElementById(thisID).value;
}
function getval(thisID) {
	//thisID can be the ID of any element with a valu attribute
	return document.getElementById(thisID).value;
}
function setbool(thisID,thisvalue) {
	//thisID should be the id of a checkbox input element in a form
	document.getElementById(thisID).value = thisvalue
}
function testselect(thisID,title,section) {
	//thisID should be the id of a select element in a form
	if (getselect(thisID)=="") {
		alert("A required selection has not been made in Section "+section+": "+title+".")
		return false
	} else {return true}
}
function testtext(thisID,title,section) {
	//thisID should be the id of an text input element in a form
	if (gettext(thisID)=="") {
		alert("A required field is missing in Section "+section+": "+title+".")
		return false
	} else {return true}
}
function conditionalTextbox(boxID,nextID) {
    if (!getchecked(boxID)) {
		//document.getElementById(textID).value='';
		document.getElementById(nextID).focus();
		//document.getElementById(boxID).checked=true;
	}
}
function autocheckbox(boxID) {
		document.getElementById(boxID).checked=true;
		document.getElementById(nextID).focus();
}
function checkOnNonempty(boxID,textID) {
	if (!gettext(textID)=='') {
		document.getElementById(boxID).checked=true;
	}
}
function boxOnNonemptyField(boxID,textID) {
		document.getElementById(boxID).checked=(!gettext(textID)=='');
}
function fieldOnNonemptyField(toggleID,triggerID) {
		if (gettext(triggerID)=='') {
			document.getElementById(toggleID).value='';
		} else {
			document.getElementById(toggleID).value='on';
		}
}
function urllink(tag) {
	// expects a checkbox id tag+'link' and a field id tag+'url'
	if (document.getElementById(tag+'url').value=='') {
	document.getElementById(tag+'link').style.display="none"
	} else {
	document.getElementById(tag+'link').href = document.getElementById(tag+'url').value
	document.getElementById(tag+'link').style.display="screen"
	}
}