function DaysArray(month,year) {//returns the number of days in a month given that month and year.
	var i = month;
	var days = 31;
	if (i==4 || i==6 || i==9 || i==11) {days = 30;}
	if (i==2) {
		// February has 29 days in any year evenly divisible by four,
		// EXCEPT for centurial years which are not also divisible by 400.
		return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
return days;
}

function GoodDate(year, month, day, CurYear, CurMonth, CurDay){//checks if Date is valid, (NOT if the field is blank) if valid, returns true.
	errmsg1 = "webmaint";
	errmsg2 = "leadertech";
	if (year=='' || month=='' || day==''){
		if (year=='' && month=='' && day==''){ return true}else {return false;}
	}
	if (CurYear=='' || CurMonth=='' || CurDay==''){
		alert("Server date innaccurate.  Please contact " + errmsg1 + "@" + errmsg2 + "." + "com with this page URL.");
		return false;
	}
	year = parseInt(year,10);
	month = parseInt(month,10);
	day = parseInt(day,10);
	CurYear = parseInt(CurYear,10);
	CurMonth = parseInt(CurMonth,10);
	CurDay = parseInt(CurDay,10);
	var daysInMonth = DaysArray(month,year);
	if (month>CurMonth&&year==CurYear){return false;}
	if ((day>CurDay&&month==CurMonth&&year==CurYear)||day>daysInMonth){return false;}
	if (year>CurYear){return false;}
return true;
}

function badDate(year, month, day, CurYear, CurMonth, CurDay){//checks if Date is bad, (NOT if the field is blank)
/************************************************************************
 Example call to capture error and allow for pass through if not an error
error = badDate(document.demographics.YEAR.options[document.demographics.YEAR.selectedIndex].value, document.demographics.MNTH.options[document.demographics.MNTH.selectedIndex].value, document.demographics.DAYS.options[document.demographics.DAYS.selectedIndex].value, <TMPL_VAR NAME="SSYR">, "<TMPL_VAR NAME="SSMN">", "<TMPL_VAR NAME="SSDY">")
if (error){
  ff=1;
  window.scroll(0,0);
  if (error=="day"){
    document.demographics.DAYS.focus();
    alert(req_valid_day);
  }else if(error=="month"){
    document.demographics.MNTH.focus();
    alert(req_valid_month);
  }else if(error=="year"){
    document.demographics.YEAR.focus();
    alert(req_valid_year);
  }
}
************************************************************************/
	errmsg1 = "webmaint";
	errmsg2 = "leadertech";

	if (year=='' && month=='' && day==''){
	  return false
	}else {
	    if (month==''){return "month";}
	    else if (day==''){return "day";}
	    else if (year==''){return "year";}
	    else if (CurYear=='' || CurMonth=='' || CurDay==''){
	      alert("Server date innaccurate.  Please contact " + errmsg1 + "@" + errmsg2 + "." + "com with this page URL.");
	      return false;
	    }else{
	  }
	}

	year = parseInt(year,10);
	month = parseInt(month,10);
	day = parseInt(day,10);
	CurYear = parseInt(CurYear,10);
	CurMonth = parseInt(CurMonth,10);
	CurDay = parseInt(CurDay,10);
	var daysInMonth = DaysArray(month,year);
	if (month>CurMonth && year==CurYear){return "month";}
	if ((day>CurDay && month==CurMonth && year==CurYear) || day>daysInMonth){return "day";}
	if (year>CurYear){return "year";}
return false;
}