define(function(require){
	var $ = require('jquery');
	require('uriTemplate')($);
	require('dialog')($);
	require('datepicker')($);
	require('grid')($);
	var IFA = require('util');
	require('../../../styles/cim/jquery-ui-1.8.14.custom.css');
	require('../../../styles/cim/cim-grid.css');
	$(function(){
		initializehDate();
	});
	
	$("#exportBtn").click(function(){
		if($("#startDate").val()==""||$("#endDate").val()==""){
			$.msg.alert(i18ns("Entity.report.selectStatisticalTime"));
		}else{			
			var url = $('#exportUrl').val().trim();
			$('#searchForm').attr("action",url);
			$('#searchForm').submit();
		}
	});
	
	$("#resetBtn").click(function(){
		$("#searchForm :input").val("");
		$("#startDate").datepicker("destroy");
		$("#endDate").datepicker("destroy");
		initializehDate();
	});
    
	function initializehDate(){	
		$("#startDate").datepicker({
			
		});
		$("#endDate").datepicker({
			beforeShow:function(date){
				var startDate = $("#startDate").val();
				if(startDate!=""){
					var date=$("#startDate").datepicker("getDate");
					 $("#endDate").datepicker("option","minDate",new Date(date.getTime()));
				}
				}
		});
	}
});