//<!--
// duesjsNoGlobal.js
function noNull(s) {
	if (s === null || s === '' ) {
		return ' ';
	} else {
		return s;
	}
}

function appendDecimal(thisNumber) {
	var pos,numberAsString,stringWithDecimal;
	// convert value to a string
  	numberAsString = thisNumber.toString();
  	pos = numberAsString.search(/\./);
  	if(pos == -1) {
		// there is no decimal. Assume this is a whole dollar amount
  	 	stringWithDecimal = numberAsString + ".00";
  	} else {
  		if (pos == numberAsString.length - 2) {
  			stringWithDecimal = numberAsString + "0";
  		} else {
   			stringWithDecimal = numberAsString;
   		}
   	}
  	return stringWithDecimal;
}

function makeDollar(f) {
	// rounds to the nearest penny
	document.getElementById(f).value = appendDecimal(parseFloat(Math.round(document.getElementById(f).value * 100)/100));

}

function makeDollarJS(v) {
	// rounds to the nearest penny
	return appendDecimal(parseFloat(Math.round(v * 100)/100));

}

function makeDollarFromVar(f, v) {
	// round the value to the nearest PENNY

	document.getElementById(f).value = appendDecimal(parseFloat(Math.round(v * 100)/100));
}

function daysBetween(thisDate, thatDate) {
	var DSTadjust = 0;
	// constants for calculations:
	var oneMinute = 1000 * 60;
	var oneDay = oneMinute * 60 * 24;

	// equalize times (assume midnight of each day):
	thisDate.setHours(0);
	thisDate.setMinutes(0);
	thisDate.setSeconds(0);
	thatDate.setHours(0);
	thatDate.setMinutes(0);
	thatDate.setSeconds(0);

	// deal with Daylight Saving Time:
	if (thatDate > thisDate) {
		DSTadjust = (thatDate.getTimezoneOffset() - thisDate.getTimezoneOffset()) * oneMinute;
	}
	else {
		DSTadjust = (thisDate.getTimezoneOffset() - thatDate.getTimezoneOffset()) * oneMinute;
	}
	var diff = Math.abs(thatDate.getTime() - thisDate.getTime()) - DSTadjust;

	return Math.ceil(diff/oneDay);
}


function isLaterDate(thisDate, thatDate) {
	// is thatDate later than thisDate?
	var DSTadjust = 0;
	// constants for calculations:
	var oneMinute = 1000 * 60;
	var oneDay = oneMinute * 60 * 24;

	// equalize times (assume midnight of each day):
	thisDate.setHours(0);
	thisDate.setMinutes(0);
	thisDate.setSeconds(0);
	thatDate.setHours(0);
	thatDate.setMinutes(0);
	thatDate.setSeconds(0);

	// deal with Daylight Saving Time:
	if (thatDate > thisDate) {
		DSTadjust = (thatDate.getTimezoneOffset() - thisDate.getTimezoneOffset()) * oneMinute;
	}
	else {
		DSTadjust = (thisDate.getTimezoneOffset() - thatDate.getTimezoneOffset()) * oneMinute;
	}
	var diff = (thatDate.getTime() - thisDate.getTime() - DSTadjust)/oneDay;

	return (diff > 0);
}


function isFutureDate(then) {
// is given date later than today?
	var today = new Date();
	var tomorrow = new Date(then);
	return isLaterDate(today, tomorrow);
}

function closeChild(xwindow) {
	if (xwindow !== undefined && xwindow !== null && !xwindow.closed) {
		xwindow.close();
	}
}

function viewWindowElements(displayWindow) {
	var i, j;

	for (i = 0; i < document.forms.length; i++) {
		for (j = 0; j < document.forms[i].elements.length; j++) {
	  		displayWindow.document.write('document.forms['+i+'].elements['+j+']: '
	   					+ document.forms[i].elements[j].name + ' : '
						+ document.forms[i].elements[j].value);
	  		if (document.forms[i].elements[j].checked) {
	  			displayWindow.document.write(' : checked');
	  		}
	  		displayWindow.document.write('<br>');
	  	}
	}
}

function viewElements() {
	if (displayWindow === null || displayWindow === undefined || displayWindow.closed) {
		displayWindow = window.open('','WDWindow');
	}
	displayWindow.document.write('<html>');
	displayWindow.document.write('<body>');
	viewWindowElements(displayWindow);
}


function viewChildElements() {
	viewWindowElements(window);
}



// -->
