// Functions for calendar:

var today = new Date();
var day   = today.getDate();
var month = today.getMonth();
var year  = y2k(today.getYear());
var dateFieldsBeingChanged;

function y2k(number)    { return (number < 1000) ? number + 1900 : number; }

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart() 
{
	if ( dateFieldsBeingChanged == 'from' )
	{
		document.SelForm.ddd.value = padout(day);
		document.SelForm.ddm.selectedIndex = month;
		document.SelForm.ddy.selectedIndex = year-2004;
	}
	else
	{
		document.SelForm.rdd.value = padout(day);
		document.SelForm.rdm.selectedIndex = month;
		document.SelForm.rdy.selectedIndex = year-2004;	
	}
	mywindow.close();
}

function newWindow(a_dateField) 
{
		
	dateFieldsBeingChanged = a_dateField;
	if ( dateFieldsBeingChanged == 'from' )
	{
		month = document.SelForm.ddm.selectedIndex;
	}
	else
	{
		month = document.SelForm.rdm.selectedIndex;
	}
	
	mywindow=open('/calendar.html','Calendar','resizable=no,width=350,height=270');
	mywindow.location.href = '/calendar.html';
	if (mywindow.opener == null) 
	{
		mywindow.opener = self;
	}
}
