
/*
<!-- Original:  Ben McFarlin (mcfarlin@netscape.net) -->
<!-- Web Site:  http://sites.netscape.net/mcfarlin -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
*/
function populate(objForm,selectIndex,formName) {
timeA = new Date(objForm.year.options[objForm.year.selectedIndex].text, objForm.month.options[objForm.month.selectedIndex].value,1);
timeDifference = timeA - 86400000;
timeB = new Date(timeDifference);
var daysInMonth = timeB.getDate();
for (var i = 0; i < objForm.day.length; i++) {
objForm.day.options[0] = null;
}
for (var i = 0; i < daysInMonth; i++) {
objForm.day.options[i] = new Option(i+1);
}
document.forms[formName].day.options[0].selected = true;
}
function getYears(formName) {

// You can easily customize what years can be used
var years = new Array(2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019)

for (var i = 0; i < document.forms[formName].year.length; i++) {
document.forms[formName].year.options[0] = null;
}
timeC = new Date();
currYear = timeC.getFullYear();
for (var i = 0; i < years.length; i++) {
document.forms[formName].year.options[i] = new Option(years[i]);
}
document.forms[formName].year.options[2].selected=true;
}
//window.onLoad = getYears;

function set_today(formName){
	thisDate = new Date();
	day = thisDate.getUTCDate()-1; 
	month = thisDate.getMonth(); // numbered from 0 
	year = thisDate.getYear()-104;//  This sets the year based on it index position.  
	// When the year changes, change the index or remove a previous year from the option drop down.
	//alert (day+'/'+month+'/'+year);  
	
	set_day(formName,day,month,year);
}

function set_day(formName,day,month,year){
	document.forms[formName].month.selectedIndex = month; 
	populate(document.forms[formName],document.forms[formName].month.selectedIndex,formName);
	document.forms[formName].day.selectedIndex = day; 
	document.forms[formName].year.selectedIndex = year; 
}