function setSel(thelist,theval) {
	// a generic set selection function for any select list in a form 
  for ( var i = 0; i < thelist.options.length; ++i ) { 
    if (thelist.options[i].value == theval) { 
      thelist.options[i].selected = true; 
      break; 
    } 
  } 
} 
   
function setDays(yrobj,monobj,dayobj) {

	// first a bit of pure laziness - shorter names to type and more readable code
	selDay = dayobj.options[dayobj.selectedIndex].value;
	selMth = monobj.options[monobj.selectedIndex].value;
	selYr  = yrobj.options[yrobj.selectedIndex].value;

	LeapYear = (selYr/4 == Math.floor(selYr/4));
	// OK I know about 100 and 400 but what's the chances we'll still be using WebDB in yr 2100 ???

  if ((selMth == 2) && (selDay > 28)) {selDay=!(LeapYear)?28:29;}
	//  clear the select list    
  for (var i=dayobj.options.length-1; i>=0; i--) { 
    dayobj.options[i] = null; 
  } 
  dayobj.selectedIndex = -1; 
	
	// and re-populate it in case of a month/year change
  var largestDay = 31;    
  if (selMth == 2) largestDay = (LeapYear?29:28);     
  if (selMth == 4 || selMth == 6 || selMth == 9 || selMth == 11) largestDay = 30; 
  for (i=0;i<largestDay;i++) { dayobj.options[i] = new Option(i+1,i+1,true,false); } dayobj.length = (i); 

	// finally reset the day pointer
  setSel(dayobj,selDay);     
} 

