<script>
function applyDateRange() {
	var dateBegin = dojo.byId('date-begin').value;
	var dateEnd = dojo.byId('date-end').value;
	var oDateBegin = dojo.date.stamp.fromISOString(dateBegin);
	var oDateEnd = dojo.date.stamp.fromISOString(dateEnd);
	var comparison = dojo.date.compare(oDateBegin,oDateEnd);
	if (comparison > 0) {
		alert('<?=__('Invalid date range.')?>');
		return;
	}
	TabState.setParam({'dateBegin':dateBegin,'dateEnd':dateEnd});
	TabState.redrawTab();
	closeDateRangeWindow();
}
</script>

<style>table.obj td {border-bottom: none;border-right:none;}</style>
<div style="float:left;">
	<div class="formRow">
		<dt><label for="date-begin"><?=__("Begin Date")?></label></dt>
		<input type="text" name="dateBegin" id="date-begin" />
		<script>
			var dateBegin = dijit.byId('date-begin');
			if (dateBegin != undefined) {
				dateBegin.destroyRecursive();
				dateBegin = null;
			}

			dateBegin = new dijit.form.DateTextBox({name:'dateBegin',constraints: {datePattern:'yyyy-MM-dd'}},dojo.byId('date-begin'));
			var beginDate = new Date();
			var x = TabState.getParam('dateBegin').split('-');
			beginDate.setFullYear(parseInt(x[0]),parseInt((x[1]-1)),parseInt(x[2]));
			dateBegin.setValue(beginDate);
		</script>
	</div>
	<br />
	<div class="formRow">
		<dt><label for="date-end"><?=__("End Date")?></label></dt>
		<input type="text" name="dateEnd" id="date-end" />
		<script>
			var dateEnd = dijit.byId('date-end');
			if (dateEnd != undefined) {
				dateEnd.destroyRecursive();
				dateEnd = null;
			}

			dateEnd = new dijit.form.DateTextBox({name:'dateEnd',constraints: {datePattern:'yyyy-MM-dd'}},dojo.byId('date-end'));
			var endDate = new Date();
			var de = TabState.getParam('dateEnd');
			if (TabState.getParam('dateEnd') == '*') {
				de = TabState.getParam('dateBegin');
			}
			var x = de.split('-');
			endDate.setFullYear(parseInt(x[0]),parseInt((x[1]-1)),parseInt(x[2]));
			dateEnd.setValue(endDate);
		</script>
	</div>
	<br />
	<br style="clear:left"/>
	<div style="text-align:right;margin-top:10px;">
		<input type="button" value="<?=__("Cancel")?>" onClick="closeDateRangeWindow()" />
		<input type="button" value="<?=__("OK")?>" onClick="applyDateRange()" />
	</div>
</div>
