function set_from_ddls()
{
	var d=0, m=0, y=0, today, tomorrow, t;
	today = new Date();

	// don't do anything if dropdown has been changed,
	// ie it is different from the default.
	var d = document.forms[0].startDay.selectedIndex
	+ document.forms[0].startMon.selectedIndex
	+ document.forms[0].startYear.selectedIndex;
	if ( d != 0 ) { return; }

	// get tomorrow
	//t = today.getTime() + 1000 * 60 * 60 * 24;
	//tomorrow = new Date(t);

	//UPDATED 08/1/2003 - Use today instead of tomorrow
	
	d = today.getDate();
	m = today.getMonth()+1;
	y = today.getFullYear();

	document.forms[0].startDay.selectedIndex = d-1;
	document.forms[0].startMon.selectedIndex = m-1;
	document.forms[0].startYear.selectedIndex = y-2008;

}


function set_both_ddls()
{
	set_from_ddls();

	var d=0, m=0, y=0, today, nextweek, t;
	today = new Date();

	// don't do anything if dropdown has been changed,
	// ie it is different from the default.
	var d = document.forms[0].endDay.selectedIndex
	+ document.forms[0].endMon.selectedIndex
	+ document.forms[0].endYear.selectedIndex;
	if ( d != 0 ) { return; }

	// get tomorrow
	//UPDATED 08/1/2003 - Use 7 days instead of 8 days in advance
	t = today.getTime() + 1000 * 60 * 60 * 24 * 7;
	tomorrow = new Date(t);

	d = tomorrow.getDate();
	m = tomorrow.getMonth()+1;
	y = tomorrow.getFullYear();

	document.forms[0].endDay.selectedIndex = d-1;
	document.forms[0].endMon.selectedIndex = m-1;
	document.forms[0].endYear.selectedIndex = y-2008;
}


function check_dates(){

	var from_month, from_day, from_year, to_day, to_month, to_year;
	var cd = document.forms[0];
	
	from_day = cd.startDay.selectedIndex;
	from_month = cd.startMon.selectedIndex;
	from_year = cd.startYear.value;
	to_day = cd.endDay.selectedIndex;
	to_month = cd.endMon.selectedIndex;
	to_year = cd.endYear.value;
	
	//get the from Date from the page
	var fromDate = new Date(from_year, from_month, from_day+2);
	var toDate = new Date(to_year, to_month, to_day+2);
	
	var today = new Date();
	var this_day   = getDayOfMonth( today );
	var this_month = today.getMonth();
	var this_year  = today.getFullYear();
	
	today.setHours(0);
	today.setMinutes(0);
	today.setSeconds(0);
	
	//return true;
	if ((fromDate < today) || (toDate < fromDate))
	{
		alert("There is a problem with the dates you have selected.\nThis could be because:\n\n-The from date is prior to today's date\n-The to date is before the from date\n\nPlease check the dates and try again.");
		return false;
	}
	
	return true;
}

function getDayOfMonth( date )
{
    var dateString = date.toUTCString();
    var day = dateString.substring( 5, 7 );

    return parseInt( day );
}
window.onload=set_both_ddls;