
function selectInput1(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
//	$("#ac1").flushCache();
} 
function selectInput2(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
//	$("#ac2").flushCache();
}
function selectInput3(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
//	$("#ac2").flushCache();
}
function selectInput4(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
}
function selectInput5(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
}
function selectInput6(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
}
function selectInput7(d, p) {
	var nodes = p.split(",<");
	return nodes[0];
}
function customRange(input) { 
	var d  = new Date();

	var d1 = new Date($("#startDate").datepicker("getDate"));

	var d2 = d1;
	if ( d.getTime() > d1.getTime() ) {
		d2 = d;
	}

	if (input.id == "startDate") {
    	return {minDate: (input.id == "startDate" ? d2 : null), 
        	maxDate: "2y"}; 
	} else {
    	return {minDate: (input.id == "endDate" ? d1 : null), 
        	maxDate: "2y"}; 
	}
} 


  $(document).ready(function(){
 
  $("#startDate,#endDate").datepicker({ 
    beforeShow: customRange,
    showOn : "both",
    buttonImage: "images/calendar.gif", 
    buttonImageOnly: true 
});

$("#ac1").autocomplete("/eneeds/hcs", 
{ 
	minChars:1, 
	width:350, 
	scroll:true, 
	scrollHeight:200
	});

$("#ac2").autocomplete("/eneeds/hcs", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput2  
	});
  

$("#ac3").autocomplete("/eneeds/hcs\?i=1", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput3,
	max:600
	});
$("#ac4").autocomplete("/eneeds/hcs\?i=2", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput4,
	max:600
	});
$("#ac5").autocomplete("/eneeds/hcs\?i=3", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput5,
	max:600
	});
$("#ac6").autocomplete("/eneeds/hcs\?i=4", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput6,
	max:600
	});
$("#ac7").autocomplete("/eneeds/hcs\?i=5", 
{ 
	minChars:1, 
	width:300, 
	scroll:true, 
	scrollHeight:200, 
	formatResult:selectInput7,
	max:600
	});
  });
