function ConfirmTimeout () {
    if(window.confirm( 'You will automatically be logged out in five minutes due to inactivity! Please click "OK" below if you wish to continue working in the system. Thank you.' )) {
    	var objHTTP = new ActiveXObject("MSXML2.XMLHTTP")
	objHTTP.open("POST", "/common/programs/sessionReset.asp", false);
  	objHTTP.send();
  	alert("Your Session Timeout has been reset to " + objHTTP.responseText + " minutes.");
    }
}

if (document.all)
var bversion=/ \d+/;
var xalert =("Browser Conflict Detected:\n\nPlease verify that you are using Internet Explorer 5.0 or greater.\nParts of this site only work with Internet Explorer 5.0 or greater.\n\nFinancial Asset Services, Inc.");
if (navigator.appVersion.match(bversion) <= 4) alert(xalert)

setTimeout( 'ConfirmTimeout();', 3300000);
//30 = 1500000
//60 = 3300000
//90 = 5100000

var jsIE4 = (document.all);
var jsNN4 = (document.layers);
var jsVersion4 = (jsNN4 || jsIE4); 
var jsDateFormat = "MM/DD/YYYY";

//get domain
var jsPrefix = (new String(document.URL)).match(/^(\w*)\:/)
var httpType = RegExp.$1
var jsDomain = httpType + "://" + document.domain;

var jsMainTitle = "";
var jsPageTitle = "";
var jsPageMessage = "Welcome to FAS WorkFlow";
var jsPagePopup = "";
var jsButtonBar = "";
var jsbHelp = 0;
var jsbInsert = 1;
var jsbNote = 2;
var jsbDocument = 3;
var jsbSpreadsheet = 4;
var jsbAudit = 5;
var jsbUpdate = 6;
var jsbField = 7
var jsbWizard = 8;
var jsbCopy = 9;
var jsbAdmin = 10;
var jsbAccounting = 11;
var jsbFavorite = 12;
var jsbWebPage = 13;
var jsbInstruction = 14;
var jsbDesign = 15;
var jsbUpload = 16;
var jsbDownload = 17;
var jsbLookup = 18;
var jsbMultiple = 19;
var jsbCheckin = 20;
var jsbCheckout = 21;

var buttonArray = new Array();
buttonArray[jsbHelp] = "help";
buttonArray[jsbInsert] = "insert";
buttonArray[jsbNote] = "note";
buttonArray[jsbDocument] = "document";
buttonArray[jsbSpreadsheet] = "spreadsheet";
buttonArray[jsbAudit] = "audit";
buttonArray[jsbUpdate] = "update";
buttonArray[jsbField] = "field";
buttonArray[jsbWizard] = "wizard";
buttonArray[jsbCopy] = "copy";
buttonArray[jsbAdmin] = "admin";
buttonArray[jsbAccounting] = "accounting";
buttonArray[jsbFavorite] = "favorite";
buttonArray[jsbWebPage] = "webPage";
buttonArray[jsbInstruction] = "instruction";
buttonArray[jsbDesign] = "design";
buttonArray[jsbUpload] = "upload";
buttonArray[jsbDownload] = "download";
buttonArray[jsbLookup] = "lookup";
buttonArray[jsbMultiple] = "multiple";
buttonArray[jsbCheckin] = "checkin";
buttonArray[jsbCheckout] = "checkout";

helpOn = new Image();
helpOn.src = "/common/images/buttons/helpOn.gif";
helpOff = new Image();
helpOff.src = "/common/images/buttons/helpOff.gif";

insertOn = new Image();
insertOn.src = "/common/images/buttons/insertOn.gif";
insertOff = new Image();
insertOff.src = "/common/images/buttons/insertOff.gif";

noteOn = new Image();
noteOn.src = "/common/images/buttons/noteOn.gif";
noteOff = new Image();
noteOff.src = "/common/images/buttons/noteOff.gif";

documentOn = new Image();
documentOn.src = "/common/images/buttons/documentOn.gif";
documentOff = new Image();
documentOff.src = "/common/images/buttons/documentOff.gif";

spreadsheetOn = new Image();
spreadsheetOn.src = "/common/images/buttons/spreadsheetOn.gif";
spreadsheetOff = new Image();
spreadsheetOff.src = "/common/images/buttons/spreadsheetOff.gif";

auditOn = new Image();
auditOn.src = "/common/images/buttons/auditOn.gif";
auditOff = new Image();
auditOff.src = "/common/images/buttons/auditOff.gif";

updateOn = new Image();
updateOn.src = "/common/images/buttons/updateOn.gif";
updateOff = new Image();
updateOff.src = "/common/images/buttons/updateOff.gif";

fieldOn = new Image();
fieldOn.src = "/common/images/buttons/fieldOn.gif";
fieldOff = new Image();
fieldOff.src = "/common/images/buttons/fieldOff.gif";

wizardOn = new Image();
wizardOn.src = "/common/images/buttons/wizardOn.gif";
wizardOff = new Image();
wizardOff.src = "/common/images/buttons/wizardOff.gif";

copyOn = new Image();
copyOn.src = "/common/images/buttons/copyOn.gif";
copyOff = new Image();
copyOff.src = "/common/images/buttons/copyOff.gif";

adminOn = new Image();
adminOn.src = "/common/images/buttons/adminOn.gif";
adminOff = new Image();
adminOff.src = "/common/images/buttons/adminOff.gif";

accountingOn = new Image();
accountingOn.src = "/common/images/buttons/accountingOn.gif";
accountingOff = new Image();
accountingOff.src = "/common/images/buttons/accountingOff.gif";

favoriteOn = new Image();
favoriteOn.src = "/common/images/buttons/favoriteOn.gif";
favoriteOff = new Image();
favoriteOff.src = "/common/images/buttons/favoriteOff.gif";

webPageOn = new Image();
webPageOn.src = "/common/images/buttons/webPageOn.gif";
webPageOff = new Image();
webPageOff.src = "/common/images/buttons/webPageOff.gif";

instructionOn = new Image();
instructionOn.src = "/common/images/buttons/instructionOn.gif";
instructionOff = new Image();
instructionOff.src = "/common/images/buttons/instructionOff.gif";

designOn = new Image();
designOn.src = "/common/images/buttons/designOn.gif";
designOff = new Image();
designOff.src = "/common/images/buttons/designOff.gif";

uploadOn = new Image();
uploadOn.src = "/common/images/buttons/uploadOn.gif";
uploadOff = new Image();
uploadOff.src = "/common/images/buttons/uploadOff.gif";

downloadOn = new Image();
downloadOn.src = "/common/images/buttons/downloadOn.gif";
downloadOff = new Image();
downloadOff.src = "/common/images/buttons/downloadOff.gif";

lookupOn = new Image();
lookupOn.src = "/common/images/buttons/lookupOn.gif";
lookupOff = new Image();
lookupOff.src = "/common/images/buttons/lookupOff.gif";

multipleOn = new Image();
multipleOn.src = "/common/images/buttons/multipleOn.gif";
multipleOff = new Image();
multipleOff.src = "/common/images/buttons/multipleOff.gif";

checkinOn = new Image();
checkinOn.src = "/common/images/buttons/checkinOn.gif";
checkinOff = new Image();
checkinOff.src = "/common/images/buttons/checkinOff.gif";

checkoutOn = new Image();
checkoutOn.src = "/common/images/buttons/checkoutOn.gif";
checkoutOff = new Image();
checkoutOff.src = "/common/images/buttons/checkoutOff.gif";

function setPageTitle() {
	theElement = arguments[0];
	if (arguments.length >= 2) {
		theItem = "<a href=" + arguments[1] + ">" + theElement + "</a>";
	} else {
		theItem = theElement;
	}
	if (jsPageTitle > "") {
		jsPageTitle += " > " + theItem;
		jsMainTitle += " > " + theElement;
	} else {
		jsPageTitle = theItem;
		jsMainTitle = theElement
	}
	document.title = jsMainTitle;
}

function drawHome() {
	document.write("<th rowspan=3><a href=\"/login.asp?logout=2\" target=_top>Logout</a><br /></th>");
}

function drawMainTitle() {
	document.write("<td valign=top align=left nowrap width=0%>&nbsp</td>"); //<img border=0 src=/common/images/aspenHorizontal.gif></td>");
}

function drawMainMenu(theMenu, theLabel) {
	if (theLabel == null) theLabel = "Matter";
	document.write("<td valign=top align=right nowrap class=menu width=100%>");
	if (theMenu == "Training") {
	} else if (theMenu == "login") {
		document.write("<a href=/login.asp>Login</a>");
	} else if (theMenu == "Design") {
		document.write("<a href=/matter/matterSearch.asp>" + theLabel + "</a>");
		document.write(" | <a href=/manage/myWorkList.asp>Manage</a>");
		document.write(" | <a href=/lookup/index.asp>Lookup</a>");
		document.write(" | <a href=/report/index.asp>Reports</a>");
		document.write(" | <a href=/admin/index.asp>Design</a>");
	} else {
		document.write("<a href=/matter/matterSearch.asp>" + theLabel + "</a>");
		document.write(" | <a href=/manage/myWorkList.asp>Manage</a>");
		document.write(" | <a href=/lookup/index.asp>Lookup</a>");
		document.write(" | <a href=/report/index.asp>Reports</a>");
	}
	document.write(" </td>");
}

function drawPageTitle() {
	document.write("<td> " + jsPageTitle + "</td>");	
}

var jsPageMenu = new Array;
var jsPageMenuCount = 0;

function addPageMenu(theName, theURL, isSelected) {
	jsPageMenu[jsPageMenuCount] = new Array;
	jsPageMenu[jsPageMenuCount][0] = theName;
	jsPageMenu[jsPageMenuCount][1] = theURL;
	if (isSelected) jsPageMenu[jsPageMenuCount++][2] = " selected";
	else jsPageMenu[jsPageMenuCount++][2] = "";
}

function drawPageMenu() {
	document.write("<td align=right>");
	if (jsPageMenuCount > 0) {
		document.write("<select name=PageMenu size=1 onChange=\"document.location=this[this.selectedIndex].value;\">");
		for (i=0; i<jsPageMenuCount; i++) {
			document.write("<option value=\"" + jsPageMenu[i][1] + "\"" + jsPageMenu[i][2] + ">" + jsPageMenu[i][0]);
		}
		document.write("</select>");
		//document.write("<input type=image name=go src=/common/images/bullets/go.gif align=absbottom border=0>");
	}
	document.write("</td>");	
}

function changeImages() { 
	if (document.images) { 
		for (var i=0; i<changeImages.arguments.length; i+=2) { 
			document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src"); 
		} 
	} 
} 

function addButton(theType, theURL, theName, theTitle, isPopup) {
	theText = "<a href=" + theURL;
	theText += " onMouseOver=\"changeImages('" + theName + "', '" + buttonArray[theType] + "On');\"";
	theText += " onMouseOut=\"changeImages('" + theName + "', '" + buttonArray[theType] + "Off');\"";
	if (isPopup) theText += " onClick=\"return openPopup(this);\">";
	else theText += ">";
	theText += "<img border=0 src=" + eval(buttonArray[theType] + "Off.src") + " name=" + theName;
	theText += " alt=\"" + theTitle + "\" width=23 height=22></a>";
	jsButtonBar += theText;
}

function drawToolBar() {
	document.write("<td valign=top class=menuBar width=75%>" + " " + jsPageMessage + "</td>");
	document.write("<td valign=top align=right class=menuBar width=25%>" + jsButtonBar + "</td>");
}

function drawHeader(theMenu, theLabel) {
	document.write("<form><table border=0 width=100% cellspacing=0 cellpadding=2 class=menu>");
	document.write("<tr>");
	drawMainTitle();
	drawMainMenu(theMenu, theLabel);
	document.write("</tr><tr>");
	document.write("<td colspan=2 class=menu>");
	document.write("<table border=0 width=100% cellspacing=0 cellpadding=2 class=menu>");
	document.write("<tr>");
	drawPageTitle();
	drawPageMenu();
	document.write("</tr>");
	document.write("</table>");
	document.write("</tr><tr>");
	drawToolBar();
	document.write("</tr>");
	document.write("</table></form>");
}

function drawFooter() {
	document.write("<table border=0 width=100% cellspacing=0 cellpadding=2 class=disclaimer>");
	document.write("<tr>");
	document.write("<td valign=top class=disclaimer nowrap>Financial Asset Services' Workflow System is privileged and confidential and is for the sole use of FAS employees and its clients.<BR>Dissemination, copying or distributing is prohibited without the prior written consent of FAS Management.</td>");
	document.write("<td valign=top align=right class=footer><a href=\"/login.asp?Logout=2\">Logout</a> </td>");
        document.write("</tr>");
        document.write("</table>");
	document.write("<layer id=lookupLayer visibility=hide></layer>");
	document.write("<iframe name='lookupFrame' border='0' frameborder='0' scrolling='no' width='0' height='0'></iframe>");
	if ((jsPagePopup != null) && (jsPagePopup > "")) alert(jsPagePopup);
}

jsDisplayList = new Array();
jsDisplayList[0] = 5;
jsDisplayList[1] = 25;
jsDisplayList[2] = 50;
jsDisplayList[3] = 100;
jsDisplayList[4] = 250;
jsDisplayList[5] = 500;
jsDisplayList[6] = 9999999;

function drawDisplay(theSize) {
	document.write("<select name=DisplaySize size=1>");
	for (i=0; i<=5; i++) {
		if (theSize == jsDisplayList[i]) isSelected = " selected";
		else isSelected = "";
		document.write("<option " + isSelected + ">" + jsDisplayList[i]);
	}
	if (theSize == 9999999) document.write("<option value=9999999 selected>All");
	else document.write("<option value=9999999>All");
	document.write("</select>");
}


jsSortByList = new Array();
jsSortByList[0] = "Date";
jsSortByList[1] = "Team";
jsSortByList[2] = "Person";
jsSortByList[3] = "Client";
jsSortByList[4] = "Vendor";
jsSortByList[5] = "Priority";
jsSortByList[6] = "City";
jsSortByList[7] = "OpenDate";

function drawSortBy(theSortBy) {
	document.write("<select name=SortBy size=1>");
	for (i=0; i<=7; i++) {
		if (theSortBy == jsSortByList[i]) isSelected = " selected";
		else isSelected = "";
		document.write("<option " + isSelected + ">" + jsSortByList[i]);
	}
	document.write("</select>");
}

/**
*** Javascript Default Routines
**/
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;
}
//time zone functionality
//date prototyping for getLoclaTimezone
 Date.prototype.getLocalTimezone = function () {
  if ( (new String(this.toString())).match(/(\w{1,}\+?\d*)\s+\d{4}$/) ) with (RegExp) {
   return $1
  }
 }
// 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 setDateOverdue(theForm) {
	jsBeginDate = new Date("1/1/1990")
	jsEndDate = new Date()
	with (theForm) {
		BeginDate.value = getDateString(jsBeginDate);
		EndDate.value = getDateString(jsEndDate);
	}
}

function setDateDay(theForm) {
	theDate = new Date();
	with (theForm) {
		BeginDate.value = getDateString(theDate);
		EndDate.value = getDateString(theDate);
	}	
}

function setDateWeek(theForm) {
	theBeginDate = new Date();	
	theBeginDate.setDate(theBeginDate.getDate() - theBeginDate.getDay());
	theEndDate = new Date(theBeginDate);
	theEndDate.setDate(theEndDate.getDate()+6);
	with (theForm) {
		BeginDate.value = getDateString(theBeginDate);
		EndDate.value = getDateString(theEndDate);
	}	
}

function setDateMonth(theForm) {
	theBeginDate = new Date();
	theBeginDate.setDate(1);
	theEndDate = new Date();
	theEndDate.setMonth(theEndDate.getMonth()+1);
	theEndDate.setDate(0);
	with (theForm) {
		BeginDate.value = getDateString(theBeginDate);
		EndDate.value = getDateString(theEndDate);
	}	
}

function setDateLastWeek(theForm) {
	theEndDate = new Date();	
	theBeginDate = new Date(theEndDate);
	theBeginDate.setDate(theBeginDate.getDate()-6);
	with (theForm) {
		BeginDate.value = getDateString(theBeginDate);
		EndDate.value = getDateString(theEndDate);
	}	
}

function setDateLastMonth(theForm) {
	theEndDate = new Date();
	theBeginDate = new Date();
	theBeginDate.setMonth(theBeginDate.getMonth()-1);
	with (theForm) {
		BeginDate.value = getDateString(theBeginDate);
		EndDate.value = getDateString(theEndDate);
	}	
}

// Window status message
function setStatus(theMessage) {
	window.status=theMessage;
	return true;
}
// Popup Email
function setEmailPopup(theEmail) {
	jsWindow = window.open("mailTo:" + theEmail, "popupWindow", "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}
}
// Popup window
function setPopup(theURL) {
	theNewDate = new Date();
	theDTStamp = String(theNewDate.getTime())
	jsWindow = window.open(theURL, "popupWindow" + theDTStamp, "toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}
}
// Popup window, specify width & height
// Center window in view
function setPopupWH(theURL,theWidth,theHeight) {
	theNewDate = new Date();
	theDTStamp = String(theNewDate.getTime())
	winl = (screen.width-theWidth)/2;
	wint = (screen.height-theHeight)/2;
	jsWindow = window.open(theURL, "popupWindow" + theDTStamp, "status=yes,toolbar=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+theWidth+",height="+theHeight+",top="+wint+",left="+winl);
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}
	jsWindow.window.focus();
}


// Picture Popup window
function setPicturePopup(theURL) {
	theNewDate = new Date();
	theDTStamp = String(theNewDate.getTime())
	jsWindow = window.open(theURL, "popupWindow" + theDTStamp, "toolbar=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480");
	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) {
	theNewDate = new Date();
	theDTStamp = String(theNewDate.getTime())
	jsWindow = window.open(escape(theURL), "setWindow" + theDTStamp, "menubar=yes,toolbar=yes,scrollbars=yes,resizable=yes");
	if (jsWindow != null) {
		if (jsWindow.opener == null) jsWindow.opener = self;
	}
}
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;
	}
}
// 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;
	}
}
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);
}

function removeValue(theField) {
	with (document.matterTaskUpdate) {
		theField.value = "";
	}
}

var nCode = 101100111000;
var jsIE4 = (document.all);
var jsNN4 = (document.layers);
var jsVersion4 = (jsNN4 || jsIE4); 

// Declare field validation strings
var jsUpperOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var jsLowerOK = "abcdefghijklmnopqrstuvwxyz";
var jsLetterOK = jsUpperOK + jsLowerOK;
var jsNumberOK =	"0123456789-.";
var jsNumbersOnlyOK =	"0123456789";
var jsIntegerOK = "0123456789-";
var jsMoneyOK = "$0123456789,.-()";
var jsDateOK = "0123456789/-";
var jsBracketsOK = "()[]{}_";
var jsWhiteSpaceOK = " \t\r\n\f";
var jsPhoneAreaCode = "949"
var jsPhoneDelimiter = "-"
var jsPhoneRE = /^([0-9]{3}\-){2}[0-9]{4}$/;
var jsSSNRE = /^[0-9]{3}\-[0-9]{2}\-[0-9]{4}$/;
var jsEmailRE = /^\w+((\.|\-)\w+)*@\w+(\-\w+)*(\.\w+)+$/;
var jsTimeRE = /^[0-9]{2}:[0-9]{2}$/;
var jsMsPerDay = 1000*60*60*24;
var jsREOPass = "change";
var jsFMRPass = "finalreview";

// Character Count Down
function charLimit(taObj) {
	var taObj=(taObj==null)?event.srcElement:taObj;
	if (taObj.value.length==taObj.maxlength*1) return false;
}

function charCount(visCnt, taObj) {
	var taObj=(taObj==null)?event.srcElement:taObj;
	if (taObj.value.length>taObj.maxlength*1) taObj.value=taObj.value.substring(0,taObj.maxlength*1);
	if (visCnt) visCnt.innerText=taObj.maxlength-taObj.value.length;
}

// WORD COUNT FUNCTIONS
function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(visCnt) {
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	if (visCnt) visCnt.innerText=taObj.maxLength-taObj.value.length;
}


// Date differences
function getDateDiff(theStart, theEnd, thePart) {
	if (thePart.toLowerCase() == 'd') return Math.round((theEnd.getTime() - theStart.getTime()) / jsMsPerDay);
	if (thePart.toLowerCase() == 'm') return (theEnd.getFullYear() - theStart.getFullYear())*12 + (theEnd.getMonth() - theStart.getMonth());
	if (thePart.toLowerCase() == 'y') return (theEnd.getFullYear() - theStart.getFullYear());
}
// Character Date
function getDateString(theDate, theFormat) {
	if (theDate.getMonth() < 9) theMonth = "0" + (theDate.getMonth() + 1);
	else theMonth = (theDate.getMonth() + 1);
	if (theDate.getDate() < 10) theDay = "0" + theDate.getDate();
	else theDay = theDate.getDate();
	theYear = theDate.getFullYear();
	theFormat = jsDateFormat;
	if (theFormat == "DD/MM/YYYY") theString = theDay + "/" + theMonth + "/" + theYear;
	else theString = theMonth + "/" + theDay + "/" + theYear;
	return theString;
}


// Character Time
function getTimeString(theTime) {
	theHours = theTime.getHours();
	theMinutes = theTime.getMinutes();
	theTime = theHours +":"+ theMinutes;
	return theTime;
}

// Date value based on DateFormat system default
function getDateValue(theDate, theFormat) {
	theResult = new String(theDate);
	if (theFormat == null) theFormat = jsDateFormat;
	if (theFormat == "DD/MM/YYYY") theDate = theResult.substring(3,5) + "/" + theResult.substring(0,2) + "/" + theResult.substring(6,10);
	else theDate = theResult;
	return(new Date(theDate));
}

// Split words 
function getSplitString(theString) {
	splitCaps = false;
	theResult = "";
	for (j=0; j<theString.length; j++) {
		if (theString.substr(j, 1) <= 'Z') {
			if (splitCaps) theResult = theResult + " " + theString.substr(j, 1);
			else theResult = theResult + theString.substr(j, 1);
			splitCaps = false;
		} else {
			theResult = theResult + theString.substr(j, 1);
			splitCaps = true;
		}
	}
	return theResult;
}
// Remove single quote
function removeQuote(theField) {
	var i;
	var theBase = new String(theField.value);
	var theResult = new String("");
	for (i=0; i<theBase.length; i++) {
		if (theBase.substring(i, i+1) == "'") theResult += "";
		else theResult += theBase.substring(i, i+1);
	}
	theField.value = theResult;
}

function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}

function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}

String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

// example of using trim, ltrim, and rtrim
///var myString = " hello my name is ";
//alert("*"+myString.trim()+"*");
//alert("*"+myString.ltrim()+"*");
//alert("*"+myString.rtrim()+"*");

// Strip String
function getStripString(theString, theContent) {
	theReplacement = "";
	for (i=0; i<theString.length; i++) {
		ch = theString.charAt(i);
		validChar = true;
		for (j=0; j<theContent.length; j++) {
			if (ch == theContent.charAt(j)) { 
				validChar = false;
				break; 
			}
		}
		if (validChar) theReplacement += ch;
	}
	return theReplacement;
}
// Strip Field
function getStripField(theField, theContent) {
	theField.value = getStripString(theField.value, theContent)
	return theField.value;
}
// Substitute String
function getSubstituteString(theString, theChar, theSubstitute) {
	theReplacement = "";
	for (i=0; i<theString.length; i++) {
		if (theString.charAt(i) == theChar) theReplacement = theReplacement += theSubstitute;
		else theReplacement = theReplacement += theString.charAt(i);
	}
	return theReplacement;
}
// Substitute Field
function getSubstituteField(theField, theChar, theSubstitute) {
	theField.value = getSubstituteString(theField.value, theChar, theSubstitute)
	return theField.value;
}
// Validate Content
function isContent(theField, tContent) {
	tFieldValue = theField.value;
	for (i=0; i < tFieldValue.length; i++) {
		ch = tFieldValue.charAt(i);
		for (j=0; j<tContent.length; j++) 
			if (ch == tContent.charAt(j)) break;		
		if (j == tContent.length) {
			theField.focus();
			return false;
		}
	}
	return true;
}
// Validate Percent
function isPercent(theField) {
	if (!isContent(theField, jsNumberOK)) {
		alert("You may only use the following characters for money: " + jsNumberOK);
		theField.value = '';
		return false;
	} else return true;
}
// Validate Only Numbers
function isNumericOnly(theField) {
	if (!isContent(theField, jsNumbersOnlyOK)) {
		alert("You may only use the following characters for numbers: " + jsNumbersOnlyOK);
		theField.value = '';
		return false;
	} else return true;
}
// Validate Number
function isNumeric(theField) {
	theNumber = Number(theField.value);
	if (!isContent(theField, jsNumberOK)) {
		alert("You may only use the following characters for numbers: " + jsNumberOK);
		theField.value = '';
		return false;
	}
	if (theNumber != theField.value) {
		alert("Please enter a valid number, excluding decimal points for whole numbers.");
		theField.value = '';
		return false;
	}
}
// Validate Money fields
function isMoney(theField) {
	if (theField.value > '') {
		if (!isContent(theField, jsMoneyOK) || (theField.value == ".")) {
			alert("You may only use the following characters for money: " + jsMoneyOK);
			theField.value = '';
			return false;
		}
		jsMoney = new Number(getStripString(theField.value, "$,"));
		jsString = '' + Math.round(jsMoney*100)/100;
		for (i=0; i<jsString.length; i++) {
			if (jsString.charAt(i) == '.') break;
		}
		if (i == jsString.length) theField.value = jsString + ".00";
		else if (i == (jsString.length-1)) theField.value = jsString + "00";
		else if (i == (jsString.length-2)) theField.value = jsString + "0";
		else theField.value = jsString;
	}
	//return (formatMoney(theField));
	return theField.value;
}
function formatMoney(theField) {
	var negPre = negSuf = ""
	var jsResult = ""
	var dec = ".00"
	var tempArray = new Array()
	var re = new RegExp(/(\d{0,3})$/)
	if (!(new String(theField.value)).match(/^[\$\d\,\.\-\(\)]+$/)) {
		alert("You may only use the following characters for money: $0123456789,.-()")
		theField.value = ''
		return false
	}
	var money = new String(theField.value).replace(/\$|\,/g, '')
	if (money.match(/^(\-|\()/)) with (RegExp) {
		negPre = $1
		negSuf = (negPre == '(')? ')' : ''
		money = money.replace(/\-|\(|\)/g, '')
	}
	if (money.match(/(\d*)(\.)(\d{0,2})/)) with (RegExp) {
		money = $1
		dec = ($3.length < 2)? ($3.length < 1)? $2 + "00" : $2 + $3 + "0" : $2 + $3 
	}
	len = money.length
	for (i=0;i<len/3;i++) {
		money.match(re)
		tempArray[i] = RegExp.$1
		money = money.replace(/\d{3}$/, '')
	}
	tempArray.reverse()
	theField.value = negPre + tempArray.join(',') + dec + negSuf
}

// Validate Pass Phrase
function validatePass(entry, thePass, theAction) {
	theAction = (theAction == null || theAction == "undefined")? "perform this action" : theAction;
	if (entry == thePass) { alert("Thank You!"); return(true); }
	else {
		alert("The Pass Phrase you have given is either incorrect or does not have permission to " + theAction + ". Please contact your manager for further information.");
		return(false);
	}
}

// Returns the Element based on elementID
function getByID(elementID) {
	return( (document.all)? document.all[elementID] : (document.getElementById)? document.getElementById(elementID) : null );
}

// "isApproved" and "msgPass" variables are required for the getPass function
var isApproved = false;
var msgPass = "";

// New Management Approval Function (mhaynes)
// Requires CSS and HTML to function correctly
function getPass(pwdEntry, msg) {
	if (msg > "") msgPass = msg;
	if (isApproved) return(true);
	if (pwdEntry == jsREOPass) {
		isApproved = true;
		alert("Password Approved! \n" + msgPass);
		getByID('npAll').style.display = getByID('npWWW').style.display = 'none';
	} else if (pwdEntry == "0") {
		getByID('npTitle').innerHTML = 'Authorization Required to Proceed';
		getByID('npPrompt').innerHTML = 'Please enter the Management Password below:';
		getByID('npAll').style.display = getByID('npWWW').style.display = '';
		getByID('npText').focus();
	} else if (pwdEntry == "1") {
		getByID('npText').value = "";
		getByID('npAll').style.display = getByID('npWWW').style.display = 'none';
	} else if (pwdEntry > "") {
		alert("You have entered an invalid password, please try again.");
		getByID('npText').focus();
		getByID('npText').select();
	} else if (pwdEntry <= "") {
		alert('You must enter a password before clicking "OK"');
		getByID('npText').focus();
	}
	return(false);
}

// Get File Field with .Net component
// theExt:(0=ANY, 1=PDF, 2=JPEG)
function getFileNet(theField, theMatterID, theMatterProcessID, theMatterTaskID, theSRC, theExt, theLabel) {
	theMatterTaskID = (theMatterTaskID == 0)? "" : theMatterTaskID;
	remote = window.open("/common/programs/fileUpload.aspx?ext=" + theExt + "&sname=" + theField.name + "&mid=" + theMatterID + "&mpid=" + theMatterProcessID + "&mtid=" + theMatterTaskID + "&label=" + theLabel, "UploadWizard", "status=yes,toolbar=no,scrollbars=no,resizable=yes,width=660,height=500");
	if (remote != null) {
		if (remote.opener == null) remote.opener = self;
		remote.opener.fileField = theField;
	}
}

// Get File Field with .Net component
// theExt:(0=ANY, 1=PDF, 2=JPEG)
function getFile(theField, theMatterID, theMatterProcessID, theMatterTaskID, theExt, theLabel) {
	theMatterTaskID = (theMatterTaskID == 0)? "" : theMatterTaskID;
	remote = window.open("/common/programs/fileUpload.aspx?ext=0&sname=" + theField.name + "&mid=" + theMatterID + "&mpid=" + theMatterProcessID + "&mtid=" + theMatterTaskID + "&label=" + theLabel, "UploadWizard", "status=yes,toolbar=no,scrollbars=no,resizable=yes,width=660,height=500");
	if (remote != null) {
		if (remote.opener == null) remote.opener = self;
		remote.opener.fileField = theField;
	}
}

// Original Get File Field
function getFileOriginal(theField, theMatterID, theMatterProcessID, theMatterTaskID) {
	remote = window.open("/matter/uploadWizardStep1.asp", "UploadWizard", "toolbar=no,scrollbars=no,resizable=yes,width=450,height=250");
	if (remote != null) {
		if (remote.opener == null) remote.opener = self;
		remote.opener.fileField = theField;
	}
}

// Get Photo will start the upload image wizard
function getPhoto(theField, theMatterID, theMatterProcessID, theMatterTaskID) {
	remote = window.open("/matter/uploadImageWizard1.asp", "UploadImageWizard", "toolbar=no,scrollbars=no,resizable=yes,width=450,height=250");
	if (remote != null) {
		if (remote.opener == null) remote.opener = self;
		remote.opener.fileField = theField;
	}
	
}

// Date Selection Window
function getDate(theField) {
	remote = window.open("/help/calendarFrame.html", "CalendarWindow", "toolbar=no,scrollbars=no,resizable=yes,width=250,height=200");
	if (remote != null) {
		if (remote.opener == null) remote.opener = self;
		if (remote.dateField == null) remote.dateField = theField;
	}
}
// Validate Date field
function isDate(theField, theFormat) {
	var theDate;
	var theCentury = new Date("1/1/1900");
	var theLimit = new Date("1/1/2050");
	theFormat = jsDateFormat;
	if (theField.value != "") {
		if (theField.value == ".") {
			theDate = new Date();
		} else if (theField.value == "?") {
			getDate(theField);
			theField.value = "";
			theField.focus();
			return false;
		} else if ((theField.value.length == 6) && (theField.value.indexOf("/") == -1) && (theField.value.indexOf("-") == -1)) {
			theString = new String(theField.value);
			if (theFormat == "DD/MM/YYYY") {
				theDay = theString.substring(2, 4);
				theMonth = theString.substring(0, 2);
				theYear = new Number(theString.substring(4, 6));
			} else {
				theDay = theString.substring(0, 2);
				theMonth = theString.substring(2, 4);
				theYear = new Number(theString.substring(4, 6));
			}
			if (theYear <= 50) theYear += 2000;
			theDate = new Date(theDay + '/' + theMonth + '/' + theYear);
		} else if ( (theField.value == "2/29/00") || (theField.value == "02/29/00") || (theField.value == "022900") ) {
			theDate = new Date("02/29/2000");
		} else if ( (theField.value == "29/2/00") || (theField.value == "29/02/00") || (theField.value == "290200") ) {
			theDate = new Date("02/29/2000");
		} else {
			theString = getSubstituteString(theField.value, "-", "/")
			if (theFormat == "DD/MM/YYYY") {
				theDay = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theMonth = theString.substring(0, theString.indexOf("/"));
			} else {
				theMonth = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theDay = theString.substring(0, theString.indexOf("/"));
			}
			theYear = new Number(theString.substring(theString.indexOf("/") + 1, theString.length));
			if (theYear <= 50) theYear += 2000;
			theDate = new Date(theMonth + "/" + theDay + "/" + theYear);
		}
		if ( isNaN(theDate.getMonth()) || (theDate.getTime() < theCentury.getTime()) || (theDate.getTime() > theLimit.getTime())) {
			alert("This is an invalid date (" + theField.value + ").");
			theField.value = "";
			theField.focus();
			return false;
		} else {
			theField.value = getDateString(theDate, theFormat);
		}
	}
	return theField;
}
// Validate time fields
function isTime(theField) {
	var theTime = theField.value;
	var theDateTime = new Date("1/1/2000 " + theTime);
	if (isNaN(theDateTime)) {
		alert("This is not a valid time.");
		theField.value = "";
		theField.focus();
		return false;
	} else return true;
}
// Validate DateTime fields
function isDateTime(theField){
	var theTime = new String("");
	var theFormat = jsDateFormat;
	var theCentury = new Date("1/1/1900");
	
	if(theField.value != ""){
		if (theField.value == "."){
			var theDate = new Date();
		}
		else if (theField.value == "?"){
			getDate(theField);
			theField.value = "";
			theField.focus();
			return false;
		}
		else if ((theField.value.length == 6) && (theField.value.indexOf("/") == -1) && (theField.value.indexOf("-") == -1)) {
			theString = new String(theField.value);
			if (theFormat == "DD/MM/YYYY") {
				theDay = theString.substring(2, 4);
				theMonth = theString.substring(0, 2);
				theYear = new Number(theString.substring(4, 6));
			} else {
				theDay = theString.substring(0, 2);
				theMonth = theString.substring(2, 4);
				theYear = new Number(theString.substring(4, 6));
			}
			if (theYear <= 50) theYear += 2000;
			theDate = new Date(theDay + '/' + theMonth + '/' + theYear);
		}
		else {
			theString = getSubstituteString(theField.value, "-", "/")
			if (theFormat == "DD/MM/YYYY") {
				theDay = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theMonth = theString.substring(0, theString.indexOf("/"));
			} else {
				theMonth = theString.substring(0, theString.indexOf("/"));
				theString = theString.substring(theString.indexOf("/") + 1, theString.length);
				theDay = theString.substring(0, theString.indexOf("/"));
			}
			if (theField.value.length > 10){
				theTime = new String(theField.value.substring(10, theField.value.length-1));
				theYear = new Number(theString.substring(theString.indexOf("/") + 1, theString.indexOf(" ")));
			}
			else{
				theYear = new Number(theString.substring(theString.indexOf("/") + 1, theString.length));
			}
			if (theYear <= 50) theYear += 2000;
			if (theField.value.length > 10) theTime = new String(theField.value.substring(10, theField.value.length));
			theDate = new Date(theMonth + "/" + theDay + "/" + theYear + theTime);
		}
		if ( isNaN(theDate.getMonth()) || (theDate.getTime() < theCentury.getTime()) ) {
			alert("This is an invalid date (" + theField.value + ").");
			theField.value = "";
			theField.focus();
			return false;
		} else {
			theField.value = getDateString(theDate, theFormat) + " " + getTimeString(theDate);
		}
	}
	return theField;
}
// Validate email fields
function isEmail(theField) {
	if ((theField.value > "") && (!jsEmailRE.test(theField.value))) {
		alert("This is not a valid email address (" + theField.value + ")");
		theField.value = "";
		theField.focus();
		return false;
	} else return theField;
}
// Validate US telephone numbers
function isPhone(theField) {
	return(true);
	theNumber = getStripString(theField.value, "()-");
	if (theNumber.length < 8) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 4);
	if (theNumber.length < 9) theNumber = jsPhoneAreaCode + jsPhoneDelimiter + theNumber;
	if (theNumber.length < 11) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 3) + jsPhoneDelimiter + theNumber.substr(6,4);
	if ((theNumber.length < 12) && (theNumber.substr(3, 1) == jsPhoneDelimiter)) theNumber = theNumber.substr(0, 7) + jsPhoneDelimiter + theNumber.substr(7, 4);
	if ((theNumber.length < 12) && (theNumber.substr(6, 1) == jsPhoneDelimiter)) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 8);
	if ((theNumber > "") && (!jsPhoneRE.test(theNumber))) {
		alert("This is not a valid US telephone number.");
		theField.focus();
		return false;
	} else return (theField.value = theNumber);
}
function isPhoneNumber(theField) {
	theNumber = getStripString(theField.value, "()-.");
	if (theNumber == "N/A" || theNumber == "n/a") return (theField.value = "N/A");
	if (theNumber.length < 8) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 4);
	if (theNumber.length < 9) theNumber = jsPhoneAreaCode + jsPhoneDelimiter + theNumber;
	if (theNumber.length < 11) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 3) + jsPhoneDelimiter + theNumber.substr(6,4);
	if ((theNumber.length < 12) && (theNumber.substr(3, 1) == jsPhoneDelimiter)) theNumber = theNumber.substr(0, 7) + jsPhoneDelimiter + theNumber.substr(7, 4);
	if ((theNumber.length < 12) && (theNumber.substr(6, 1) == jsPhoneDelimiter)) theNumber = theNumber.substr(0, 3) + jsPhoneDelimiter + theNumber.substr(3, 8);
	if ((theNumber > "") && (!jsPhoneRE.test(theNumber))) {
		alert("This is not a valid US telephone number. Please use the following format '###-###-####' or use 'N/A' where applicable.");
		theField.value = "";
		theField.focus();
		return false;
	} else return (theField.value = theNumber);
}

// Validate social security numbers
function isSSN(theField) {
	theNumber = theField.value;
	if (theNumber.length < 10) theNumber = theNumber.substr(0,3) + "-" + theNumber.substr(3,2) + "-" + theNumber.substr(5,4)
	if ((theNumber.length < 11) && (theNumber.substr(3, 1) == "-")) theNumber = theNumber.substr(0, 6) + "-" + theNumber.substr(6, 4);
	if ((theNumber.length < 11) && (theNumber.substr(5, 1) == "-")) theNumber = theNumber.substr(0, 3) + "-" + theNumber.substr(3, 7);
	if ((theNumber > "") && (!jsSSNRE.test(theNumber))) {
		alert("This is not a valid social security number.");
		theField.focus();
		return false;
	} else return (theField.value = theNumber);
}
// Security role 
function isRole(theRole) {
	var i
	for (i=0; i<jsSecurityList.length; i++)	{
		if (jsSecurityList[i] == theRole) return true;
	}
	return false;
}
// Field Visibility
function isHidden(theField) {
	if (jsIE4) {
		theName = theField.name;
		theValue = eval("FieldValue" + theName);
		if (theValue.style.visibility == "hidden") {
			return true;
		} else {
			return false;
		}
	} else return false;	
}
// Hide Field
function hideField(theField) {
	if ((jsIE4) && (!isHidden(theField))) {
		theName = theField.name;
		theLabel = eval("FieldLabel" + theName);
		theValue = eval("FieldValue" + theName);
		if (theLabel != null) {
			theLabel.style.visibility = "hidden";
			theLabel.oldHeight = theLabel.style.height;
			theLabel.style.height = 0;
		}
		if (theValue != null) {
			theValue.style.visibility = "hidden";
			theValue.oldHeight = theValue.style.height;
			theValue.style.height = 0;
		}
	}
}
// Show Field
function showField(theField) {
	if ((jsIE4) && (isHidden(theField))) {
		theName = theField.name;
		theLabel = eval("FieldLabel" + theName);
		theValue = eval("FieldValue" + theName);
		if (theLabel != null) {
			theLabel.style.height = theLabel.oldHeight;
			theLabel.style.visibility = "visible";
		}
		if (theValue != null) {
			theValue.style.height = theValue.oldHeight;
			theValue.style.visibility = "visible";
		}
	}
}
// Form cancel
function cancelForm(theForm) {
	if (confirm("Are you sure you wish to cancel?")) {
		document.location = theForm.ReferringPage.value;
	}
}

// ***
// ***	Calendar functions
// ***

maxDayIndex = new Array (31,28,31,30,31,30,31,31,30,31,30,31);
monthIndex = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");

function monthOption(theMonth, theDate) {
	if (theMonth != theDate.getMonth()) return "<option value=" + theMonth + ">" + monthIndex[theMonth] + "</option>";
	else return "<option value=" + theMonth + " selected>" + monthIndex[theMonth] + "</option>";
}
function yearOption(theYear, defaultYear) {
	if (theYear != defaultYear) return "<option value=" + theYear + ">" + theYear + "</option>";
	else return "<option value=" + theYear + " selected>" + theYear + "</option>";
}
function displayDay(theDay) {
	if (theDay == 0) return "<td style=dull> </td>";
	else return "<td align=right valign=top><a href='javascript:selectDate(" + theDay + ");'>" + theDay + "</a></td>";
}
function displayMonth(theDate) {
	theDate.setDate(1);
	theYear = theDate.getFullYear();
	if (theDate.getFullYear() < 1000) theYear += 1900;
	if ( ( ((theYear%4)==0) && ((theYear%100)!=0) ) || ((theYear%400)==0)) maxDayIndex[1] = 29;
	else maxDayIndex[1] = 28;

	document.write("<table border=1 cellspacing=1>");
	document.write("<tr><td colspan=7 align=center bgcolor=#808080 nowrap>");
	document.write("  <span class='footer'><input type=image src=/common/images/bullets/left.gif name='Back' onClick='goBack();'><select name='Month' size='1' onchange='top.goMonth(this);'>");
	for (i=0; i<=11; i++) document.write(monthOption(i, theDate));
	document.write("  </select><select name='Year' size='1' onchange='top.goYear(this);'>");
	for (i=1971; i<=2019; i++) document.write(yearOption(i, theYear));
	document.write("  </select><input type=image src=/common/images/bullets/right.gif name='Next' onClick='goNext();'></span>");
	document.write("</td></tr>");
	document.write("<tr align=center nowrap><th>S</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th></tr>");

	var theDay=theDate.getDay();
	document.write("<tr>\n");
	for (i=0; i<theDay; i++) document.write(displayDay(0));
	for (i=1; i<=maxDayIndex[theDate.getMonth()]; i++) {
		if (theDay++ == 7) {
			document.write("</tr><tr>\n");
			theDay=1;
		}	
		document.write(displayDay(i));
	}
	for (i=theDay; i<7; i++) document.write(displayDay(0));
	document.write("</tr></table>");
}

function goBack() {
	currentDate.setMonth(currentDate.getMonth() - 1);
	displayMonth(currentDate);
}

function goNext() {
	currentDate.setMonth(currentDate.getMonth() + 1);
	displayMonth(currentDate);
}

function goMonth(theMonth) {
	currentDate.setMonth(theMonth.options[theMonth.options.selectedIndex].value);
	displayMonth(currentDate);
}

function goYear(theYear) {
	currentDate.setYear(theYear.options[theYear.options.selectedIndex].value);
	displayMonth(currentDate);
}

currentDate = new Date();

function setWeek(theForm, theDifference) {
	with (theForm) {
		theBeginDate = new Date(BeginDate.value);
		theEndDate = new Date(EndDate.value);	
		theBeginDate.setDate(theBeginDate.getDate() + (7*theDifference));
		theEndDate.setDate(theEndDate.getDate() + (7*theDifference));
		BeginDate.value = getDateString(theBeginDate);
		EndDate.value = getDateString(theEndDate);
	}	
}

/**Javascript Data Retrieval Routines**/

var jsIE4 = (document.all);
var jsNN4 = (document.layers);
var jsVersion4 = (jsNN4 || jsIE4); 
var jsDataBusy;

// Javascript error trapping
function trapError(theMessage) {
	alert(theMessage);
}
//Retrieve Value of a single column
function getValue(theSQL, theColumn) {
	theResult = "";
	var theRoot = getXMLSQL(theSQL);
	if (theRoot.childNodes.length > 0) {
		theNode = theRoot.childNodes.item(0);
		theResult = theNode.selectSingleNode(theColumn).text;
	}
	return(theResult);
}

// Dynamic data rewrites
function sqlFormObject(tForm) {
	this.theForm = tForm;
	this.theSQL = new Object;
}
// Retrieve a single row from a database
function getObject(theSQL, theObject, theForm) {
	eval(theObject + " = new sqlFormObject(theForm);");
	if (jsDataBusy) {
		setTimeout('getObject(' + '"' + theSQL + '", "' + theObject + '", "' + theForm + '")', 1000);
		return false;
	} 
	jsDataBusy = true;
	if (document.layers) {
		document.layers["lookupLayer"].src="/common/programs/getObject.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
	} else {
		lookupFrame.location = "/common/programs/getObject.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
	}
	return true;
}
// Set the form fields matching the field names for a retrieved record
function setObject(theObject) {
	var i;
	jsDataBusy = false;
	with (eval(theObject + ".theForm")) {
		for (i=0; i<elements.length; i++) {
			if (elements[i].name > '') {
				if ((eval(theObject + ".theSQL." + elements[i].name) >= "") && (eval(theObject + ".theSQL." + elements[i].name) != "undefined")) {
					if (elements[i].type == "select-one") {
						defaultOption(elements[i], eval(theObject + ".theSQL." + elements[i].name));
					} else if (elements[i].type == "checkbox") {
						defaultCheck(elements[i], eval(theObject + ".theSQL." + elements[i].name));
					} else elements[i].value = eval(theObject + ".theSQL." + elements[i].name);
				} 
			}
		}
	}
	eval(theObject + " = null;");
}

// Dynamic data rewrites
function sqlListObject(tList) {
	this.theList = tList;
	this.theSQL = null;
}
// Retrieve 1 or more rows from a database
function getList(theSQL, theObject, theList) {
	if (eval("top." + theObject) == null) eval("top." + theObject + " = new sqlListObject(theList);");
	if (jsDataBusy) {
		setTimeout('getList(' + '"' + theSQL + '", "' + theObject + '", "' + theList + '")', 1000);
		return false;
	} 
	jsDataBusy = true;
	if (jsNN4) {
		// top.menu.document.layers["lookupLayer"].src="/common/programs/getList.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
		document.layers["lookupLayer"].src="/common/programs/getList.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
	} else {
		// menu.lookupFrame.location = "/common/programs/getList.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
		lookupFrame.location = "/common/programs/getList.asp?SQL=" + escape(theSQL) + "&Object=" + theObject;
	}
	return true;
}
// Set the form fields matching the field names for a retrieved record
function setList(theObject) {
	var i;
	jsDataBusy = false;
	tObject = eval("top." + theObject);
	try {
		with (tObject.theList) {
			options.length = 1;
			for (i=0; i<tObject.theSQL.length-1; i++) {
				theIndex = Math.round((i/2)+0.5);
				if (theIndex >= options.length) options.length = theIndex + 1;
				options[theIndex].value = tObject.theSQL[i++];
				options[theIndex].text = tObject.theSQL[i];
			}
			defaultOption(tObject.theList, tObject.theList.defaultValue);
		}
	} catch(e) {
		alert(theObject + " is not a top-level object.\n\n" + e.description + "\n\n" + lookupFrame.location);
	}
	eval("top." + theObject + " = null;");
}

function getXMLSQL(theSQL) {
	try {
		var theFieldList = (arguments.length > 1) ? "&Restrict=1" : "";
		for (var i=1; i<arguments.length; i++) theFieldList += "&" + arguments[i] + "=1";
		var theXMLDoc = new ActiveXObject("Microsoft.XMLDOM");
		theXMLDoc.async = false;
		//prompt("","/common/programs/xmlSP.asp?SQL=" + escape(theSQL) + theFieldList);
		theXMLDoc.load("/common/programs/xmlSP.asp?SQL=" + escape(theSQL) + theFieldList);
		if (theXMLDoc.documentElement) return(theXMLDoc.documentElement);
		else throw(Error(1, "No data retrieved in XML document.\n\nSQL: " + theSQL + "\n\nURL:\n\n/common/programs/xmlSP.asp?SQL=" + escape(theSQL) + theFieldList));
	} catch(e) {
		if (e.number == 1) throw(e);
		else throw(Error(2, "Error retrieving XML document:\n" + e.description + "\n\nSQL: " + theSQL));
	}
}

function getListXML(theElement, theSQL, theValue, theText) {
	with (theElement) {
		options.length = 1;
		options[0].text = "<Loading new list>";
		try {
			var theRoot = getXMLSQL(theSQL, theValue, theText);
			if (theRoot.childNodes.length > 0) {
				for (var i=0; i<theRoot.childNodes.length; i++) {
					theNode = theRoot.childNodes.item(i);
					if (i+1 >= options.length) options.length = i + 2;
					if (i==0) {
						options[0].value = "";
						options[0].text = "None";
					}
					options[i+1].value = theNode.selectSingleNode(theValue).text;
					options[i+1].text = theNode.selectSingleNode(theText).text;
				}
			} else {
				options[0].value = "";
				options[0].text = "None";
			}
		} catch(e) {
			alert("An Error Has Occurred in Your Browser. Please send this error to workflow.fasinc.com with a brief description of how the error was received. \n\nError:" + e.description + " \n\nThank you.");
		}
	}
}

function setStop(theForm) {
	with (theForm) {
		if (StopTrigger.selectedIndex == 7) {
			getList("EXECUTE pTaskList @SortBy='Label'", "jsTaskID", StopTriggerID);
			StopTriggerID.options[0].text = "Select a task >>";
		} else if (StopTrigger.selectedIndex == 8) {
			getList("EXECUTE pFieldListDate", "jsTaskID", StopTriggerID);
			StopTriggerID.options[0].text = "Select a field >>";
		} else {
			StopTriggerID.options.length = 1;
			StopTriggerID.options[0].text = "Not used";
			StopTriggerID.options[0].value = "";
		}
	}
}

function setStart(theForm) {
	with (theForm) {
		if (StartTrigger.selectedIndex == 7) {
			getList("EXECUTE pTaskList @SortBy='Label'", "jsTaskID", StartTriggerID);
			StartTriggerID.options[0].text = "Select a task >>";
		} else if (StartTrigger.selectedIndex == 8) {
			getList("EXECUTE pFieldListDate", "jsTaskID", StartTriggerID);
			StartTriggerID.options[0].text = "Select a field >>";
		} else {
			StartTriggerID.options.length = 1;
			StartTriggerID.options[0].text = "Not used";
			StartTriggerID.options[0].value = "";
		}
	}
}
function setSearchString(theElement) {
	if (theElement.value == "") theElement.value = '%';
}
function autoNoteInsert(thePrompt) {
	if (thePrompt <= "") thePrompt = "Please document your reason for making this change:";
	theNote = ""
	do 
		theNote = prompt(thePrompt);
	while (theNote <= "")
	with (document.matterTaskUpdate) {
		theMatterID = MatterID.value;
		theMatterProcessID = MatterProcessID.value;
		theMatterTaskID = MatterTaskID.value;
		theURL = "/common/programs/setNote.asp?MatterID=" + MatterID.value + "&MatterProcessID=" + MatterProcessID.value + "&MatterTaskID=" + MatterTaskID.value + "&Person=" + getCookie("Person") +  "&NoteType=Private" +  "&Priority=4" +  "&Note=" + escape(theNote);
		//alert(theURL);
	}
	if (document.layers) {
		document.layers["lookupLayer"].src=theURL;
	} else {
		lookupFrame.location = theURL;
	}
	return true;
}
// Log an event
function autoLogEvent(theTable, theIdentity, theEvent, thePrompt) {
	if (thePrompt > "") theEvent += " " + prompt(thePrompt);
	theURL = "/common/programs/setLog.asp?TableName=" + theTable + "&IdentityID=" + theIdentity +  "&LogRecord=" + escape(theEvent);
	if (document.layers) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
	return true;
}
// Cookie functions
cookieExpiration = new Date("12/31/2013");

function getCookie(name) {
	var cname = name + "=";
	if (document.cookie.length > 0) {              
		begin = document.cookie.indexOf(cname);       
		if (begin != -1) {
			begin += cname.length;       
			end = document.cookie.indexOf(";", begin);
			if (end == -1) end = document.cookie.length;
			return unescape(document.cookie.substring(begin, end));
		} 
	}
	return null;
}

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) + 
		((expires == null) ? "" : "; expires=" + expires.toGMTString()) +
		((path == null) ? "" : "; path=" + path) +
		((domain == null) ? "" : "; domain=" + domain) +
		((secure == null) ? "" : "; secure");
}

function deleteCookie (name,path,domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path == null) ? "" : "; path=" + path) +
			((domain == null) ? "" : "; domain=" + domain) +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
if (document.all) {
	var theTables = document.all.tags("TABLE");
	var theRows = document.all.tags("TR");
}

if (document.images) { 
	expand = new Image(); 
	expand.src = "/common/images/bullets/expand.gif"; 
	collapse = new Image(); 
	collapse.src = "/common/images/bullets/collapse.gif";
}

// Hide any element by ID
function hideElement(elementId) {
	var element;
	if (document.all)
	element = document.all[elementId];
	else if (document.getElementById)
	element = document.getElementById(elementId);
	if (element && element.style) 
	element.style.display = 'none';
}

// Show any element by ID
function showElement(elementId) {
	var element;
	if (document.all)
	element = document.all[elementId];
	else if (document.getElementById)
	element = document.getElementById(elementId);
	if (element && element.style)
	element.style.display = '';
}

function setDisplay(theTable) {
	for (i=0; i<theTables.length; i++) {
		if (theTables[i].id.indexOf("Tab") >= 0) {
			if (theTables[i].id == "Tab" + theTable) theTables[i].style.display = "inline";
			else theTables[i].style.display = "none";
		}
	}
}
// This toggles all table rows with an id tag named theObject
function toggleDisplay(theObject, theImage) {
	for (i=0; i<theRows.length; i++) {
		if (theRows[i].id == theObject) {
			if (theRows[i].style.display == "inline") {
				theRows[i].style.display = "none";
				if (theImage != null) document[theImage].src = expand.src;
				deleteCookie(theObject);
			} else {
				theRows[i].style.display = "inline";
				if (theImage != null) document[theImage].src = collapse.src;
				setCookie(theObject, "ON");
			}
		}
	}
}
function showRow(theName) {
	for (i=0; i<theRows.length; i++) {
		if (theRows[i].id.indexOf(theName) == 0) {
			theRows[i].style.display = "inline";
		}
	}
}

function hideRow(theName) {
	for (i=0; i<theRows.length; i++) {
		if (theRows[i].id.indexOf(theName) == 0) {
			theRows[i].style.display = "none";
		}
	}
}
function setRow(theName, theState) {
	for (i=0; i<theRows.length; i++) {
		if (theRows[i].id.indexOf(theName) == 0) {
			theRows[i].style.display = (theState) ? "inline" : "none";
		}
	}
}
// This pops up a help screen with lookup field information based on a field's 'l' stored procedure
function lookupMatterField(theFieldID, theField, theMatterID, theMatterProcessID, theMatterTaskID) {
	with (document.matterTaskUpdate) {
		if (theField.options.selectedIndex == 0) {
			alert("You cannot look up the value of 'None'.  Please select an option before clicking on the lookup link.");
		} else {
			theURL = "/help/matterFieldSelect.asp?FieldID=" + theFieldID + "&Value=" + escape(theField.value ? theField.value : theField.defaultValue) 
			//theURL = "/help/matterFieldSelect.asp?FieldID=" + theFieldID + "&Value=" + escape(theField.value) 
			theURL += "&MatterID=" + theMatterID + "&MatterProcessID=" + theMatterProcessID + "&MatterTaskID=" + theMatterTaskID;
			setPopup(theURL);
		}
	}
}

function toggleField(theField) {
	if (document.all) {
		theFields = document.all.tags("TD");
		for (i=0; i<theFields.length; i++) {
			if (theFields[i].id.indexOf("TabField" + theField) >= 0) {
				if (theFields[i].style.display == "inline") theFields[i].style.display = "none";
				else theFields[i].style.display = "inline";
			} 
		}

	}
}
function checkDocument() {
	return(true);
}

function executeInsertTask(theTask, theBeforeTask, theTeam, thePerson, theStartDate, theStopDate) {
	theURL = "/common/programs/execute.asp?Method=MatterTaskInsert";
	theURL += "&MatterID=" + document.matterTaskUpdate.MatterID.value;
	theURL += "&MatterProcessID=" + document.matterTaskUpdate.MatterProcessID.value;
	theURL += "&Task=" + escape(theTask);
	theURL += "&BeforeTask=" + escape(theBeforeTask);
	if (theTeam != undefined) theURL += "&Team=" + theTeam;
	if (thePerson != undefined) theURL += "&Person=" + thePerson;
	if (theStartDate != undefined) theURL += "&StartProjected=" + theStartDate;
	if (theStopDate != undefined) theURL += "&StopProjected=" + theStopDate;
//	alert(theURL);
	if (jsNN4) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
}

function executeProcessOnhold(theOnholdDate) {
	theURL = "/common/programs/execute.asp?Method=MatterProcessOnhold";
	theURL += "&MatterProcessID=" + document.matterTaskUpdate.MatterProcessID.value;
	if (theOnholdDate != null) theURL += "&OnholdDate=" + escape(theOnholdDate);
	if (jsNN4) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
}

function executeProcessResume(theResumeDate) {
	theURL = "/common/programs/execute.asp?Method=MatterProcessResume";
	theURL += "&MatterProcessID=" + document.matterTaskUpdate.MatterProcessID.value;
	if (theResumeDate != null) theURL += "&ResumeDate=" + escape(theResumeDate);
	if (jsNN4) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
}

function executeProcessClosed(theClosedDate) {
	theURL = "/common/programs/execute.asp?Method=MatterProcessClosed";
	theURL += "&MatterProcessID=" + document.matterTaskUpdate.MatterProcessID.value;
	if (theClosedDate != null) theURL += "&ResumeDate=" + escape(theClosedDate);
	if (jsNN4) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
}

function executeProcessStatus(theStatus) {
	theURL = "/common/programs/execute.asp?Method=MatterProcessStatus";
	theURL += "&MatterProcessID=" + document.matterTaskUpdate.MatterProcessID.value;
	if (theStatus != null) theURL += "&ResumeDate=" + escape(theStatus);
	if (jsNN4) {
		document.layers["lookupLayer"].src = theURL;
	} else {
		lookupFrame.location = theURL;
	}
}

function validateAction(theForm, theName) {
	with (theForm) {
  		if (Action.selectedIndex == 0) {
	   		alert("You must select an action before clicking Go!");
	   		return(false);
		} else theAction = Action.options[Action.selectedIndex].value;
		isSelected = false;
		for (i=0; i<elements.length; i++) {
			if (elements[i].name == theName) {
				if (isSelected = elements[i].checked) break;
			}
		}
		if (!isSelected) {
			alert("You must check at least one checkbox before clicking Go!");
			return(false);
		}
	}
	return(confirm("Are you sure you want to " + theAction + " these items?"));
}

// dropdown keypress matching routines
var jsListboxBuffer = "";
var jsListboxTimeout = "";
var jsListboxCounter = 0;
var jsListboxCounterLimit = 3;

function listboxKeypress(theField){
	window.clearInterval(jsListboxTimeout)
	var keycode = window.event.keyCode;
	if (keycode >= 32) {
		jsListboxBuffer += String.fromCharCode(keycode).toUpperCase(); 
		listboxFind(theField);
		jsListboxTimeout = window.setInterval("listboxIdle()", 325);  
	}
}

function listboxBlur(theField) {
	window.clearInterval(jsListboxTimeout);
	jsListboxBuffer = "";
	if (theField.onchange) theField.onchange();
}

function listboxIdle(){
	jsListboxCounter += 1
	if(jsListboxCounter > jsListboxCounterLimit) {
		jsListboxBuffer = "";
		jsListboxCounter = 0;
		window.clearInterval(jsListboxTimeout);
	}
}

function listboxFind(theField) {
	var allOptions = theField.options;	
	for (i=0; i < allOptions.length; i++){
		nextOptionText = allOptions(i).text.toUpperCase();
		if(!isNaN(nextOptionText) && !isNaN(jsListboxBuffer) ){
			nextOptionText *= 1;
			jsListboxBuffer *= 1;
		}
		if(jsListboxBuffer == nextOptionText){
			theField.selectedIndex = i;
			window.event.returnValue = false;
			break;
		}
		if(i < allOptions.length-1) {
			lookAheadOptionText = allOptions(i+1).text.toUpperCase() ;
			if ( (jsListboxBuffer > nextOptionText) && (jsListboxBuffer < lookAheadOptionText) ) {
				theField.selectedIndex = i+1;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			}
		} else {
			if (jsListboxBuffer > nextOptionText) {
				theField.selectedIndex = allOptions.length-1;
				window.event.cancelBubble = true;
				window.event.returnValue = false;
				break;
			}
		}
	}
}

function setRowOrder(theForm, theIdentifier) {
	with (theForm) {
		for (i=0; i<elements.length; i++) {
			if (elements[i].name == theIdentifier) {
				elements[i].checked = true;
				eval(theIdentifier + "Order" + elements[i].value + ".value=" + (elements[i].parentElement.parentElement.rowIndex-1));
			}
		}
	}
}

function twin_onLoad(){
	if (document.forms.length > 0){
		for (frm = 0; frm < document.forms.length; frm++){
			var frmObj = document.forms[frm];
			if(frmObj.elements.length > 0){
				for (itm = 0; itm < frmObj.elements.length; itm++){
					var itmObj = frmObj.elements[itm];
					if(itmObj.twinObject != null){
						var twinObj = frmObj.elements[itmObj.twinObject];
						switch (itmObj.type){
							case "text": 
								itmObj.value = twinObj.value; 
							break;
							case "checkbox": 
								if (itmObj.value == twinObj.value) itmObj.checked = true;
							break;
							case "radio":
								if (itmObj.value == twinObj.value) itmObj.checked = true;
							break;
							case "select-one":
								for (i = 0; i < itmObj.length; i++){
									if (itmObj[i].value == twinObj.value) itmObj.selectedIndex = i;
								}
							break;
							case "textarea":
								itmObj.value = twinObj.value;
							break;
						}
					}
				}
			}
		}
	}
}

function twin_onSave(){
	if (document.forms.length > 0){
		for (frm = 0; frm < document.forms.length; frm++){
			var frmObj = document.forms[frm];
			if(frmObj.elements.length > 0){
				for (itm = 0; itm < frmObj.elements.length; itm++){
					var itmObj = frmObj.elements[itm];
					if(itmObj.twinObject != null){
						var twinObj = frmObj.elements[itmObj.twinObject];
						switch (itmObj.type){
							case "text": 
								twinObj.value = itmObj.value; 
							break;
							case "checkbox": 
								if (itmObj.checked) twinObj.value = itmObj.value
								else twinObj.value = null;
							break;
							case "radio":
								if (itmObj.checked) twinObj.value = itmObj.value;
							break;
							case "select-one":
								twinObj.value = itmObj.value;
							break;
							case "textarea":
								twinObj.value = itmObj.value;
							break;
						}
					}
				}
			}
		}
	}
}

function tabCapture (obj) {
	if (!window.self.workingObj) window.self.workingObj  = new Object();
	if (!window.self.workingId) window.self.workingId  = new Object();
	if (!window.self.tabMode) window.self.tabMode = new Object();

	if (new String(tabMode[event.srcElement.id]) == 'undefined') tabMode[event.srcElement.id] = false;
	status = 'TabMode = ' + tabMode[event.srcElement.id]
	window.self.theRange = document.selection.createRange();
	window.self.workingObj[obj.id] = obj;
	window.self.workingId[obj.id] = obj.id;
	
	if (event.keyCode == 9 && tabMode[event.srcElement.id]) {
		workingObj[event.srcElement.id].onblur = function anonymous () {
			this.focus();
			theRange.select();
		}
		theRange.text = "\t";
	}
	if (! tabMode[event.srcElement.id]) {
		if (workingObj[event.srcElement.id]) workingObj[event.srcElement.id].onblur = null;
	}
	if (event.keyCode == 84 && event.ctrlKey) {
		tabMode[event.srcElement.id] = !tabMode[event.srcElement.id];
		status = 'TabMode = ' + tabMode[event.srcElement.id];
	}
}


//convert Value into Money
function convertMoney(theValue){

	jsMoney = new Number(theValue);
	jsString = '' + Math.round(jsMoney*100)/100;

	for (i=0; i<jsString.length; i++) {
		if (jsString.charAt(i) == '.') break;
	}
	if (i == jsString.length) return(jsString + ".00");
	else if (i == (jsString.length-1)) return(jsString + "00");
	else if (i == (jsString.length-2)) return(jsString + "0");
	else return(jsString);
}

function validateRevision(theForm) {
	with (theForm) {
		if (RevisionCode.value <= "") {
			alert("You must enter a revision code."); 
			RevisionCode.focus();
			return(false);
		}
		if (RevisionReason.value <= "") {
			alert("You must enter a revision reason."); 
			RevisionReason.focus();
			return(false);
		}
	}
	return(true);
}

function showHideField(theField, theLevel, theDisplay, theElement) {
	switch (theLevel.toUpperCase()) {
		case 'ELEMENT' :
			theNode = theField
			break
		case 'LABEL' :
			theNode = theField.parentNode.parentNode.childNodes[0]
			theNode = (theNode.nodeName.toUpperCase() != "SPAN")? theNode : theNode.parentNode.parentNode.childNodes[0]
			theNode.innerHTML = (theNode.childNodes[0].nodeName == "#text")? "<span>" + theNode.innerHTML + "</span>" : theNode.innerHTML
			theNode = theNode.childNodes[0]
			break
		case 'LABELCELL' :
			theNode = theField.parentNode.parentNode.childNodes[0]
			theNode = (theNode.nodeName.toUpperCase() != "SPAN")? theNode : theNode.parentNode.parentNode.childNodes[0]			
			break
		case 'ELEMENTLABEL' :
			theNode = theField.parentNode
			if (theNode.nodeName.toUpperCase() != "SPAN") {
				theNode.innerHTML = (theNode.childNodes[1].nodeName == "#text")? "<span>" + theNode.innerHTML + "</span>" : theNode.innerHTML
				theNode = theNode.childNodes[0]
			}
			break
		default :
			theNode = theField.parentNode
			while (theNode.nodeName.toUpperCase() != theLevel.toUpperCase()) theNode = theNode.parentNode
	}
	theNode.style.display = (theDisplay == null)? (theNode.style.display == 'none') ? '' : 'none' : (theDisplay) ? '' : 'none'
}

function tabClear() {
	if (window.self.tabFocus) {
		window.self.tabFocus.onblur = null;
		window.self.tabFocus = null;
	}
}

function tabCapture (obj) {
	if (!window.self.workingObj) window.self.workingObj  = new Object();
	if (!window.self.workingId) window.self.workingId  = new Object();
	if (!window.self.tabMode) window.self.tabMode = new Object();

	if (new String(tabMode[event.srcElement.id]) == 'undefined') tabMode[event.srcElement.id] = false;
	status = 'TabMode = ' + tabMode[event.srcElement.id]
	window.self.theRange = document.selection.createRange();
	window.self.workingObj[obj.id] = obj;
	window.self.workingId[obj.id] = obj.id;
	
	if (event.keyCode == 9 && tabMode[event.srcElement.id]) {
		workingObj[event.srcElement.id].onblur = function anonymous () {
			this.focus();
			theRange.select();
		}
		theRange.text = "\t";
	}
	if (! tabMode[event.srcElement.id]) {
		if (workingObj[event.srcElement.id]) workingObj[event.srcElement.id].onblur = null;
	}
	if (event.keyCode == 84 && event.ctrlKey) {
		tabMode[event.srcElement.id] = !tabMode[event.srcElement.id];
		status = 'TabMode = ' + tabMode[event.srcElement.id];
	}
}

function bHover(b) {
	b.className = "orangebutton";
}

function bOut(b) {
	b.className = "graybutton";
}
function formatDate(theString, theFormat) {
	if (theString > "") {
		theDate = new Date(theString);
		return getDateString(theDate, theFormat);
	} else return "";
}
function dateAdd(numberOfDays, theDate) {
	if (theDate == null) theDate = new Date();
	else theDate = new Date(theDate);
	returnDate = new Date(theDate);
	return formatDate(returnDate.setDate(theDate.getDate() + numberOfDays));
}

