function OpenNewWindow(URL, width, height){
	window.open (URL,"anyName","toolbar=yes,location=yes, scrollbars=yes,width=" + width + ",height=" + height + ",personalbar=yes,directories=no,menubar=yes,titlebar=yes,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	return false;	 
}

function OpenNoBarWindow(URL, width, height){
	 window.open (URL,"anyName","toolbar=no,location=no, scrollbars=yes,width=" + width + ",height=" + height + ",personalbar=no,directories=no,menubar=no,titlebar=no,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	 return false;
}

function OpenWindow(URL, width, height){
	window.open (URL,"anyName","toolbar=yes,location=yes,scrollbars=yes,width=" + width + ",height=" + height + ",personalbar=yes,directories=yes,menubar=yes,titlebar=yes,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	return false;
}
 
function OpenWindowWithScrollbar(URL, width, height){
	window.open (URL,"anyName","toolbar=no,location=no,scrollbars=yes,width=" + width + ",height=" + height + ",personalbar=no,directories=no,menubar=no,titlebar=no,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	return false;
}

function OpenImageWindow(URL, width, height){
	window.open (URL,"anyName","toolbar=no,location=no,scrollbars=no,width=" + width + ",height=" + height + ",personalbar=no,directories=no,menubar=no,titlebar=no,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	return false;
}

function OpenWindowSelfResize(URL){
	width = 400;
	height = 400;
	window.open (URL,"anyName","toolbar=no,location=no,scrollbars=yes,width=400,height=400,personalbar=no,directories=no,menubar=no,titlebar=no,resizable=yes,left="+parseInt((screen.availWidth-width)/2)+",top="+parseInt((screen.availHeight-height)/2)+"");
	return false;
}
 
function ShowCalendar(formName, controlName) {
	window.open ("./Calendar.asp?Control=" + formName + "." + controlName,"calWin","scrollbars=no,status=no,width=220,height=155,resizable=yes,left="+parseInt((screen.availWidth-220)/2)+",top="+parseInt((screen.availHeight-155)/2)+"");
}

function ShowCalendarStartOn(formName, controlName, dateStart) {
	window.open ("./Calendar.asp?theDate=" + dateStart + "&Control=" + formName + "." + controlName,"calWin","scrollbars=no,status=no,width=220,height=155,resizable=yes,left="+parseInt((screen.availWidth-220)/2)+",top="+parseInt((screen.availHeight-155)/2)+"");
}

function resetSearchFields() {
	allElements = document.searchform.elements;
								
	for (var i=0; i<allElements.length; i++) {
		if (allElements[i].type == "checkbox") {
			allElements[i].checked = false;
		}
		else if (allElements[i].type == "text") {
			allElements[i].value = "";
		}
		else if (allElements[i].type == "select-one") {
			allElements[i].selectedIndex = 0;
		}
	}
}


// Takes in an unlimited number of arguments, each corresponding to an elementID to disable
function enableDates() {
	for (var i=0; i<enableDates.arguments.length; i++) {
		currElement = document.getElementById(enableDates.arguments[i]);
		if (currElement != null)
			currElement.disabled = false;
	}
}

function clearField(elementNameOrID) {
	if (document.getElementById(elementNameOrID)) {
		document.getElementById(elementNameOrID).value = "";
	}
	else if (document.getElementsByName(elementNameOrID)) {
		var theElement = document.getElementsByName(elementNameOrID);
		for (var i=0; theElement.length; i++)
			theElement[i].value = "";
	}
	return false;
}

function showRemainingCharsWithDelay (textElementID, counterID, maxChars) {
	setTimeout("showRemainingChars(" + textElementID + ", " + counterID + ", " +  maxChars + ");");
}
function showRemainingChars (textElementID, counterID, maxChars) {
	var formElement = document.getElementById(textElementID);
			
	if (formElement) {
		var numChars = formElement.value.length;
				
		if (numChars > maxChars) {
			formElement.value = formElement.value.substring(0, maxChars);
			numChars = formElement.value.length;
		}
		numCharsRemaining = maxChars - numChars;
		document.getElementById(counterID).innerHTML = numCharsRemaining;
	}
}


function isNumberKey(evt) {
	var charCode = (evt.which) ? evt.which : evt.keyCode
				       
	if (isArrowOrDeleteKey(evt))
		return true;
						
	if (charCode > 31 && (charCode < 48 || charCode > 57))
		return false;

	return true;
}
		
function isArrowOrDeleteKey(evt) {
	var charCode = (evt.which) ? evt.which : evt.keyCode
					
	if ((charCode >= 37 && charCode <= 39) || (charCode == 46) || (charCode == 8))
		return true;
	else
		return false;
}

function isNumber(testValue) {
	var myRegExp = /[0-9]+/;
	if (myRegExp.test(testValue))
		return true;
	else
		return false;
}



function showHideDiv(theDivIDToToggle) {
	var theElement = document.getElementById(theDivIDToToggle);
	
	if (theElement) {
		if (theElement.style.display.toLowerCase() == "none")
			theElement.style.display = "";
		else
			theElement.style.display = "none";
	}
	
	return false;
}



var refreshTimer = null;
function refreshPopup(nameOfIFrame) {
	refreshTimer = window.setTimeout("refreshFrame('" + nameOfIFrame + "')", 350);
}
function refreshFrame(nameOfIFrame) {
	try {
		frames[nameOfIFrame].location.reload(false);
	}
	catch(e){}
}


function roundUp(inValue, numPlaces) {

	var numToMultiplyBy = Math.pow(10, numPlaces+1);
	var shiftedValue = Math.floor(inValue * numToMultiplyBy);
	shiftedValue += 5;
	shiftedValue /= numToMultiplyBy;
	
	
	shiftedValue = shiftedValue.toFixed(2);

	return shiftedValue;
}
