// JavaScript Document

 ///////////// search start date	////////////////

function searchstartdate()
{
var start_date =document.getElementById("txtesdate").value ;
start_date = start_date.split("/")

year = start_date[2];
month = start_date[1];
day = start_date[0];

if( isNaN(month) || isNaN(day) || isNaN(year)) {
alert("Invalid number. Please ensure the day, month and year are valid numbers.");
return false;
}

if(month < 1 || month > 12) {
alert("Invalid Month. Please ensure that the month is between 1 and 12 inclusive.");
return false;
}

if
(day < 1 || day > 31) {
alert("Invalid Day. Please ensure that the day is between 1 and 31 inclusive.");
return false;
}

if
((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Invalid Day/Month combination. Please ensure that you have a valid day/month combination.");
return false;

}

if
(month == 2) {
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day>29 || (day==29 && !isleap))
{
alert("Invalid Day. This year is not a leap year. Please enter a value less than 29 for the day.");
return false
}
}

var sDate = new Date(year,month-1,day);
var today = new Date();
diff = sDate-today;
diff = Math.ceil(diff/1000/60/60/24);
//alert(diff);
//if(diff < 0) {
//alert("Invalid Start Date. Please specify a date that is in the future and not the past.");
//document.getElementById("txtesdate").value='';
// txtesdate.focus();
//    return false;
//
//}
 }
 ///////////// search end date	////////////////

function enddate()
{

var t1= document.getElementById("txtesdate").value ; 
var t2= document.getElementById("txtefdate").value ; 
var one_day=1000*60*60*24;

var x=t1.split("/");
year = x[2];
month = x[1];
day = x[0];
var y=t2.split("/");
year = y[2];
month = y[1];
day = y[0];
var date1=new Date((x[1])+ "/" + x[0] + "/" + x[2]);

var date2=new Date((y[1])+ "/" + y[0]+ "/" + y[2]); 

if(date1 !="NaN" && date2 !="NaN")
diff=(Math.ceil((date2.getTime()-date1.getTime())/(one_day))-1);

if(date2 < date1){
alert("Please select a To date after the starting date !!!");
document.getElementById("txtefdate").value='';
txtefdate.focus();
    return false;
	}
	}
	
