/**
*** Javascript Default Routines
*** - Created by Eric Patrick
*** - Last Update 02/02/99
**/
var jsIE4 = (document.all);
var jsNN4 = (document.layers);
var jsVersion4 = (jsNN4 || jsIE4); 
var myWorkURL = "/manage/personFrame.asp?ReferringPage=personSearch.asp";

// Javascript error trapping
function trapError(theMessage) {
	alert(theMessage);
}

// Set the default value of a drop-down option list
function defaultOption(theField, theValue) {
	if (theField.options) for (i=0; i<theField.options.length; i++) {
		if (theField.options[i].value == theValue) {
			theField.options[i].selected = true; 
			break;
		}
	} else trapError(theField.type + " is not a select field.");
}
// Set the default value of a drop-down option list based on text values
function defaultOptionText(theField, theValue) {
	if (theField.options) for (i=0; i<theField.options.length; i++) {
		if (theField.options[i].text == theValue) {
			theField.options[i].selected = true;
			break;
		}
	} else trapError(theField.type + " is not a select field.");
}
// Set the default value of a check box
function defaultCheck(theField, theValue) {
	if (theValue > "") theField.checked = true;
	else theField.checked = false;
}
// Set the default value of a series of date fields
function defaultDate(theMonth, theDay, theYear, theValue) {
	theDate = new Date(theValue);
	defaultOption(theMonth, theDate.getMonth() + 1);
	defaultOption(theDay, theDate.getDate());
	defaultOption(theYear, 1900 + theDate.getYear());
}
// Set the default value of a text field 
function defaultText(theField, theValue) {
	theField.value = theValue;
}
// Get a form element based on a name
function getFormElement(theForm, theName) {
	for (i=0; i<theForm.elements.length; i++) {
		if (theForm.elements[i].name == theName) return theForm.elements[i];
	}
	return null;
}
// Set default date range
function setDateRange(theForm, theDays) {
	with (theForm) {
		jsBegin = new Date();
		jsEnd = new Date();
		jsEnd.setDate(jsEnd.getDate() + theDays);
		if (theDays < 0) {
			BeginDate.value = getDateString(jsEnd);
			EndDate.value = getDateString(jsBegin);
		} else {
			BeginDate.value = getDateString(jsBegin);
			EndDate.value = getDateString(jsEnd);
		}
		submit();
	}
}
// Set overdue date range
function setOverdueRange(theForm) {
	jsBeginDate = new Date("1/1/1990")
	jsEndDate = new Date()
	with (theForm) {
		BeginDate.value = getDateString(jsBeginDate);
		EndDate.value = getDateString(jsEndDate);
		submit();
	}
}
// Window status message
function setStatus(theMessage) {
	window.status=theMessage;
	return true;
}
// Popup window
function setPopup(theURL) {
	jsWindow = window.open(theURL, "popupWindow", "toolbar=no,scrollbars=yes,resizable=yes,width=600,height=500");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	} 
}
// Open popup window based on a link
function openPopup(theLink) {
	setPopup(theLink.href);
	return false;
}
function setWindow(theURL) {
	jsWindow = window.open(theURL, "popupWindow", "menubar=yes,toolbar=no,scrollbars=yes,resizable=yes,width=600,height=500");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}

}
// Open popup window based on a link
function openWindow(theLink) {
	setWindow(theLink.href);
	return false;
}
function setDialog(theURL) {
	alert(theURL);
	jsWindow = window.open(theURL, "dialogWindow", "toolbar=no,scrollbars=no,resizable=no,width=250,height=150");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}
}
function insertPersonFavorite() {
	alert(window.name);
}
// Track My Work screen
function gotoMyWork() {
	Content.location = myWorkURL;
}
// Toggle checkboxes in a list
checked = false;
function itemSelect(theForm, theName) {
	checked = !checked;
	with (theForm) for (i=0; i<elements.length; i++) {
		if (elements[i].name == theName) elements[i].checked = checked;
	}
}
// Determine if any checkboxes have been selected
function itemChecked(theForm, theName) {
	with (theForm) for (i=0; i<elements.length; i++) {
		if (elements[i].name == theName) {
			if (elements[i].checked) return true;
		}
	}
	return false;
}
