//This function checks if a date is valid. eg Feb 31 st is invalid
function isDate(month, day, year)
   {
   //Get the date object for the month day and year
   var checkDate = new Date(year,month,day);
   
   //Check if the date is valid
   if ((checkDate.getFullYear() == year) && 
      (month == checkDate.getMonth()) && 
      (day == checkDate.getDate()))
      return true;
   else
      return false;
   }
 
 
function compareDates(startMonth, startDay , startYear, endMonth, endDay, endYear)
   {
   var errStr = ""   //to hold the error string
   //check the validity of the start date and the end date 
   var todayDate = new Date();   //Get the today's date 
      
   var todayDateVal = Date.UTC(todayDate.getFullYear(),todayDate.getMonth(),todayDate.getDate());
   var startDateVal = Date.UTC(startYear, startMonth,startDay);
   var endDateVal = Date.UTC(endYear, endMonth, endDay);
      
   //Compare dates 
   if(startDateVal < todayDateVal || endDateVal < todayDateVal)
      {
      if (startDateVal < todayDateVal)
         errStr = errStr + "Start date cannot be a past date\n";
      if (endDateVal < todayDateVal)
         errStr = errStr + "End date cannot be a past date\n";
      }
   else if (endDateVal < startDateVal) 
      errStr = errStr + "Start date cannot be greater than End date\n";
      
   return errStr;
   }