   TRUE = 1;
   FALSE = 0;
   
   var monthOffset = new Array(0, 31, 59, 90, 120, 151, 181, 212,
                               243, 273, 304, 334);
	
function initiate() {
  //document.myform.monthb.focus();
}

function daysOld(month, date, year) {
     // convert day-of-month to 0 based range,
     // except following February in a leap year,
     // in which case we skip the conversion to
     // account for the extra day in February 

    var day = (parseInt(date) + monthOffset[parseInt(month)]);

    if ((parseInt(year) & 3) != 0 || parseInt(year) % 100 == 0 && (parseInt(year) + 300) 
         % 400 != 0 || parseInt(month) < 2) {
       day -= 1;
    }
 
    day += (parseInt(year) - 70) * 365;    	 	// days per year
    day += Math.floor((parseInt(year) - 69) / 4);	 	// plus leap days
    day -= Math.floor((parseInt(year) - 1) / 100);		// no leap on century years
    day += Math.floor((parseInt(year) + 299) / 400);		// except %400 years

    return day;
}

function isnum(str) {
  len = str.length

  if (len == 0)
     return(FALSE)
 
  for (i=0; i<len; i++)
    if (!((str.charAt(i) >= '0') && (str.charAt(i) <= '9')))
      return(FALSE)
  return(TRUE)
}

function calculate(days, lod, planet) {

   monthb = document.myform.monthb.value;
   dayb = document.myform.dayb.value;
   yearb = document.myform.yearb.value;

   if (isnum(monthb) && isnum(dayb) && isnum(yearb)) {
     
     var today = new Date ();

     // Year 2000 compliance
     if (yearb < 20) yearb = parseInt(yearb) + 100;
     
     if (yearb > 1900) yearb = parseInt(yearb) - 1900;
     
     //alert(yearb);
     
     var bday = daysOld (monthb-1, dayb, yearb);

     var obday = new Date(yearb, monthb-1, dayb);

     //confirm(bday + " = " + (obday.getTime() / 86400000));
   
     age = (today.getTime() / 86400000 - bday);
   
     document.myform.planet.value = planet ;
    

      newage = age / days;
      if (newage < 1)
        document.myform.newage.value = "less than 1";
      else 
        document.myform.newage.value = parseInt(newage);
        
      document.myform.newday.value = parseInt(age *23.934 / lod)
      document.myform.days.value = parseInt(age);  
   } else {
      warnMe(1);
   }
}


function clear()  {
  document.myform.data.value = ""
  document.myform.data.focus()
}

function warnMe(n)  {
   if(n == 1) 
     alert("First, enter your birthday!\nNumbers only!") 
   else  
     alert("Sorry, I don't know what is wrong.") 
}

function DoSubmit() {
   alert("Don't Press return.  Enter your birthday\nAnd, click on a planet.");
   return false
}
