
function openwindow (currPage, currWidth, currHeight) {
	if (currPage != "" && currWidth != "" && currHeight != "") {
		wPopupWindow = window.open(currPage, "wPopupWindow", "resizable=no,location=no,menubar=no,scrollbars=yes,status=no,width=" + currWidth + ",height=" + currHeight + "");
		wPopupWindow.focus();
	}
}

function isNumeric(fieldObject) {
	var fldValue;

	fldValue = fieldObject.value.replace(/ /g, "");
	fldValue = fldValue.replace(/\$/g, "");
	fldValue = fldValue.replace(/,/g, "");

	if (fldValue != "" && isNaN(parseFloat(fldValue))) {
		alert("Please enter a number.");
		fieldObject.value = "";
		fieldObject.select();
		fieldObject.focus();
	} else if (fldValue != "") {
		fieldObject.value = Math.round(parseFloat(fldValue) * 100) / 100;
	}
}


function isDate(fieldObject) {
	var fldValue;
	var strLen;
	var fldTest;

	fldValue = fieldObject.value.replace(/ /g, "");
	fldValue = fldValue.replace(/\//g, "");
	fldValue = fldValue.replace(/\-/g, "");
	strLen = fldValue.length;

	fldTest = isNaN(fldValue);

	if (fldValue == "") {
		fieldObject.value = "";

	} else if (fldValue != "" && (strLen != 8 || fldTest == true)) {
		alert("Please enter in mm/dd/yyyy format.");
		//fieldObject.value = "";
		fieldObject.select();
		fieldObject.focus();
	} else if (!(isValidDate(fldValue))) {
		alert("Please re-enter a valid date.");
		//fieldObject.value = "";
		fieldObject.select();
		fieldObject.focus();

	} else if (fldValue != "") {
		fieldObject.value = fldValue.substring(0,2) + "/" + fldValue.substring(2,4) + "/" + fldValue.substring(4);

	}
}

function isValidDate(currDateString) {
	var retValue = true;

	if (currDateString.substring(0,2) == "08") {
		currMonth = parseInt("8");
	} else if (currDateString.substring(0,2) == "09") {
		currMonth = parseInt("9");
	} else if (currDateString.substring(0,2) == "02") {
		currMonth = parseInt("2");
	} else {
		currMonth = parseInt(currDateString.substring(0,2));
	}
	if (currDateString.substring(2,4) == "08") {
		currDay = parseInt("8");
	} else if (currDateString.substring(2,4) == "09") {
		currDay = parseInt("9");
	} else {
		currDay = parseInt(currDateString.substring(2,4));
	}
	if (currDateString.substring(4,8) == "08") {
		currYear = parseInt("8");
	} else if (currDateString.substring(4,8) == "09") {
		currYear = parseInt("9");
	} else {
		currYear = parseInt(currDateString.substring(4,8));
	}

	if (currMonth < 0 || currMonth > 12) {
		retValue = false;

	} else if (currMonth == 4 || currMonth == 6 || currMonth == 9 || currMonth == 11) {
		if (currDay > 30 || currDay < 1) {
			retValue = false;
		}
	} else if (currMonth != 2) {
		if (currDay > 31  || currDay < 1) {
			retValue = false;
		}
	} else {
//alert("check isLeap");
		if (isLeap(currYear)) {
//alert("check isLeap then clause");
			if (currDay > 29  || currDay < 1) {
				retValue = false;
			}
		} else {
			if (currDay > 28  || currDay < 1) {
				retValue = false;
			}
		}
	}

	return retValue;

}

function isLeap(currYear) {
	var retValue = false;

	// any year divisible by 4 except those divisible by 100 but
	// not by 400 are leap years.
	if (currYear % 400 == 0) {
		retValue = true;
	} else if (currYear % 4 == 0) {
		retValue = true;
	}

	return retValue;
}

