/* standard dumb javascript */
function setFormField(oField, v) {
	if (oField) {
		oField.value = v;
		return 1;
	}
	return 0;
}


/* swaps the value of the indicated form field */
function swapFormValue(oForm, strFieldName, newValue) {
	if (oForm && oForm.elements[strFieldName]) {
		oForm.elements[strFieldName].value = newValue;
	}
}


/*
This function assembles a MS-SQL date from 6 pulldowns. The result is jammed 
into the input object 'strTargetName'. The individual elements of the date
come from pulldowns which are named according to a predefined convention.

resulting format:
2004-03-03 20:33:13.0
*/
function calculateDate(oForm, strTargetName) {
	if (oForm) {

		// find the target
		var oInput = oForm.elements[strTargetName];
		if (oInput) {

			// get all the parts
			var oMonth = oForm.elements[strTargetName + '_month'];
			var oYear = oForm.elements[strTargetName + '_year'];
			var oDay = oForm.elements[strTargetName + '_day'];
			var oHour = oForm.elements[strTargetName + '_hour'];
			var oMinute = oForm.elements[strTargetName + '_minute'];
			var oSecond = oForm.elements[strTargetName + '_second'];

			if (oInput && oMonth && oYear && oDay && oHour && oMinute && oSecond) {
				
				var strResult = "";
				
				// assemble string result
				strResult =
					oYear.options[oYear.selectedIndex].value + '-' +
					oMonth.options[oMonth.selectedIndex].value + '-' +
					oDay.options[oDay.selectedIndex].value + ' ' +
					oHour.options[oHour.selectedIndex].value + ':' +
					oMinute.options[oMinute.selectedIndex].value + ':' +
					oSecond.options[oSecond.selectedIndex].value + '.0';
					
				setFormField(oInput, strResult);
			}
			
		}
	}
}