// 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 hiLite(imgDocID,imgObjName) {

	if (((navigator.appName == "Netscape") && (parseInt (navigator.appVersion) >= 3 )) || ((navigator.appName == "Microsoft Internet Explorer") && (parseInt (navigator.appVersion) >=4 ))) {
		{	document.images[imgDocID].src = eval(imgObjName + ".src")	}
    }
	
}



function get_object (fieldName) {
	if (ie)
		temp = document.all[fieldName];
	else if (ns5plus)
		temp = document.getElementById(fieldName);
	else if (ns4)
		temp = document.layers[fieldName];

	return temp;
}



// limit chars entered into a textarea
function text_limiter_with_counter(field,maxlimit,cntfield, cntfieldtext) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	
	// otherwise, update 'characters left' counter
	else 
		cntfield.value = maxlimit - field.value.length + cntfieldtext;
}

function text_limiter_without_counter(field,maxlimit) {
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
}
