   function addzero( value )
   {
      while( value.length<2 ) value = String("0") + value;
      return value;
   }
    
function checkDateOrder(frm, ci_day, ci_month_year, co_day, co_month_year) {
   if (document.getElementById) {
      var frm = document.getElementById(frm);
      // create date object from checkin values
      // set date to 12:00 to avoid problems with one
      // date being wintertime and the other summertime
      var my = frm[ci_month_year].value.split("-");
       var ci = new Date (my[0], my[1]-1, frm[ci_day].value, 12, 0, 0, 0);

        // create date object from checkout values
       my = frm[co_month_year].value.split("-");
       var co = new Date (my[0], my[1]-1, frm[co_day].value, 12, 0, 0, 0);

      // if checkin date is at or after checkout date,
      // add a day full of milliseconds, and set the
      // selectbox values for checkout date to new value
       if (ci >= co){
          co.setTime(ci.getTime() + 1000 * 60 * 60 * 24);
           frm[co_day].value =  co.getDate();
          var com = co.getMonth()+1;
           frm[co_month_year].value = co.getFullYear() + "-" + com;
      }
   }
}

