// work out which browser type is needed
var ns4 = false;
var ns5plus = false;
var ie = false;
if (document.layers)
	ns4 = true;
else if ((parseInt(navigator.appVersion) >= 5) && (navigator.appName=="Netscape"))
	ns5plus = true;
else if (document.all)
	ie = true;


// make the user confirm their action before proceeding (used when deleting things,  etc)
function confirm_action (message, urllocation) {
	if (!confirm (message)) {
		return (false);
	}
	else {
		document.location.href = urllocation;
	}
}

// record in a hidden field that a form on the page has been updated
function form_changed () {
	document.formChanges.changesMade.value = 'Y';
}

// record in a hidden field that a form on the page has been updated
function go_to (urllocation) {
	if (document.formChanges.changesMade.value == 'Y')
		confirm_action ("You have made changes to a form on this page.  Do you wish to continue,  losing any changes?", urllocation);
//		alert ("You have made changes to the form on this page.\nPlease save this information before continuing.");
	else
		document.location.href = urllocation;
}

// toggle a checkbox's value
function toggle_checkbox (fieldName, arrayPosition) {
	if (ie)
		toggle_checkbox_temp = document.all[fieldName];
	else if (ns5plus)
		toggle_checkbox_temp = document.getElementById(fieldName);
	else if (ns4)
		toggle_checkbox_temp = document.layers[fieldName];

	// check to see if javascript thinks this is an object (array) or not
	if (typeof (toggle_checkbox_temp[arrayPosition]) != 'undefined') {
		if (toggle_checkbox_temp[arrayPosition].checked == false)
			toggle_checkbox_temp[arrayPosition].checked = true;
		else
			toggle_checkbox_temp[arrayPosition].checked = false;
	}
	else {
		if (toggle_checkbox_temp.checked == false)
			toggle_checkbox_temp.checked = true;
		else
			toggle_checkbox_temp.checked = false;
	}
	return true;
}

// toggle a checkbox's value
function set_radio_button (fieldName, arrayPosition) {
	if (ie)
		set_radio_button_temp = document.all[fieldName];
	else if (ns5plus)
		set_radio_button_temp = document.getElementById(fieldName);
	else if (ns4)
		set_radio_button_temp = document.layers[fieldName];

	// check to see if javascript thinks this is an object (array) or not
	if (typeof (set_radio_button_temp[arrayPosition]) != 'undefined')
		set_radio_button_temp[arrayPosition].checked = true;
	else
		set_radio_button_temp.checked = true;

	return true;
}

// display or hide a div
function flip_div (divName) {
	if (ie)
		temp = document.all[divName];
	else if (ns5plus)
		temp = document.getElementById(divName);
	else if (ns4)
		temp = document.layers[divName];

	current=(temp.style.display == 'none') ? 'inline' : 'none';
	temp.style.display = current;
}

// display a div
function display_div (divName) {
	if (ie)
		temp = document.all[divName];
	else if (ns5plus)
		temp = document.getElementById(divName);
	else if (ns4)
		temp = document.layers[divName];

	temp.style.display = 'inline';
}

// hide a div
function hide_div (divName) {
	if (ie)
		temp = document.all[divName];
	else if (ns5plus)
		temp = document.getElementById(divName);
	else if (ns4)
		temp = document.layers[divName];

	temp.style.display = 'none';
}



// 
function get_parent_window_object (fieldName) {
//alert (window.opener.document.form01.fieldName);
	if (ie)
		temp = window.opener.document.all[fieldName];
	else if (ns5plus)
		eval ("temp = window.opener.document.form01." + fieldName + ";");
//		temp = window.opener.document.getElementById(fieldName);
	else if (ns4)
		temp = window.opener.document.layers[fieldName];

	return temp;
}