   var currentDate = new Date();
   var maxSeasonDate;
   var noOfMonths = 0;
   var monthDays = [31,0,31,30,31,30,31,31,30,31,30,31];
   var totalDays=0;
   var isleap;
   // The number of milliseconds in one day
   var ONE_DAY = 1000 * 60 * 60 * 24;


   currentCheckInDate = new Date((currentDate.getTime())+ONE_DAY);
   with (currentCheckInDate) 
   {
      var checkInMonth  = getMonth();
      var checkInDay  = getDate();
      var checkInYear = getFullYear();
   }


   with (currentDate)
   {
      currentMonthValue = getMonth();
      currentDayValue = getDate();
      currentYearValue = getFullYear();
   }

   var currentDateValue = currentDayValue + "/" + (currentMonthValue + 1) + "/" + currentYearValue;
   

   var cinDate = (checkInDay-1) + "/" + (checkInMonth + 1) + "/" + checkInYear;

   var isleap = (checkInYear % 4 == 0 && (checkInYear % 100 != 0 || checkInYear % 400 == 0));

   if(isleap)
   {
      monthDays[1] = 29;
   }
   else
   {
      monthDays[1] = 28;
   }

   totalDays = monthDays[checkInMonth] - checkInDay + 1;
   var monthStart = checkInMonth;
   var monthEnd = 12;
   var yearIncr;
   var monthIncr = 6;
   var flag=1;
   var yearIncrement;

   if(checkInMonth >= 7)
   {
      yearIncrement = 2;
   }
   else
   {
      yearIncrement = 1;
   }

   for(var year=checkInYear;year<=(checkInYear+yearIncrement);year++)
   {
      isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
      if(isleap)
      {
         monthDays[1] = 29;
      }
      else
      {
         monthDays[1] = 28;
      }

      for(var i=monthStart+1;i<monthEnd;i++)
      {
         totalDays = totalDays + monthDays[i];
      }

      monthStart = -1;
      monthEnd = monthIncr;

      if(flag==1)
      {
         monthEnd = checkInMonth+monthIncr;
         flag=0;
      }
       
      if(monthEnd >= 13)
      {
         monthIncr = monthEnd - 12;
         monthEnd=12;
      }
   }

   var maxDay=(ONE_DAY * totalDays) - ONE_DAY;

   // Convert both dates to milliseconds
   var usFormat = (checkInMonth + 1) + "/" + checkInDay + "/" + checkInYear; 
   var usFormatdate=new Date(usFormat);
   var dateInMilliSeconds = usFormatdate.getTime();

   // Calculate the CheckoutDate in milliseconds
   var maxCheckoutDateMs = dateInMilliSeconds + maxDay;
   var checkoutDateMs = dateInMilliSeconds + (ONE_DAY*7);

   var maxCheckoutDate = new Date(maxCheckoutDateMs);
   var defaultCheckoutDate = new Date(checkoutDateMs);
   var maxCheckoutDay  = maxCheckoutDate.getDate();
   var maxCheckoutMon  = maxCheckoutDate.getMonth();
   var maxCheckoutYear = maxCheckoutDate.getFullYear();

   //maxSeasonDate = currentDayValue + "/" + (currentMonthValue + 1) + "/" + currentYearValue; 
    

   //maxSeasonDate initialised in loadSeasons method.
   var maxDate =new Date(maxSeasonDate);

   with(maxDate)
   {
       maxCheckoutDay =getDate();
       maxCheckoutMon =getMonth();
       maxCheckoutYear =getFullYear();    
   }
   
   var maxCoDate =  maxCheckoutDay + "/" + (maxCheckoutMon + 1) + "/" + maxCheckoutYear;

   var checkOutDay  = defaultCheckoutDate.getDate();
   var checkOutMonth  = defaultCheckoutDate.getMonth();
   var checkOutYear = defaultCheckoutDate.getFullYear();
   calculateNoOfMonths(); 


   function calculateNoOfMonths()
   {     
      var startMonth = checkInMonth;
      var monEnd=0;
        
      if(checkInYear == maxCheckoutYear)
      {
         monEnd=maxCheckoutMon+1;
      }
      else
      {
         monEnd = 12;
      } 

      for(year=checkInYear;year<=maxCheckoutYear;year++)
      {
         for(i=startMonth;i<monEnd;i++)
         {
            noOfMonths = noOfMonths + 1;
         }
         startMonth = 0;

         if((year+1)==maxCheckoutYear)
         {
            monEnd = maxCheckoutMon+1;
         }
      }
   }

   var months = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
   var maxMonth=0;
