//*************************************************
//File Name			:	Check_date.js
//Purpose			:	function to set the day in accordance with the year
//						To use this function, the programmer have to pass
//						year combo object
//						month combo object
//						days combo object
//Author			:	Vishal
//Date Created		:	08 Oct 2003
//************************************************


function setDays(objYear, objMonth, objDay) {
	
  var y = objYear.options[objYear.selectedIndex].value;
  var m = objMonth.selectedIndex;
  var d;

  // find number of days in current month
  if ( (m == 3) || (m == 5) || (m == 8) || (m == 10) ) {
    days = 30;
  }
  else if (m == 1) {
    // check for leapyear - Any year divisible by 4, except those divisible by 100 (but NOT 400)
    if ( (Math.floor(y/4) == (y/4)) && ((Math.floor(y/100) != (y/100)) || (Math.floor(y/400) == (y/400))) )
      days = 29
    else
      days = 28
  }
  else {
    days = 31;
  }


  // if (days in new month > current days) then we must add the extra days
  if (days > objDay.length) {
    for (i = objDay.length; i < days; i++) {
      objDay.length = days;
      objDay.options[i].text = i + 1;
      objDay.options[i].value = i + 1;
    }
  }

  
  // if (days in new month < current days) then we must delete the extra days
  if (days < objDay.length) {
    objDay.length = days;
    if (objDay.selectedIndex == -1) 
      objDay.selectedIndex = days - 1;
  }

}