// $Id: calendar-brem.js,v 1.2 2008/11/25 12:48:47 marko Exp $

function disallowDate(date) {
	if (date.getTime() < today.getTime()) {
		// disallow dates in the past
		return true;
	}
	if (date.getTime() > today.getTime() + (1000*60*60*24*365)) {
		// disallow dates more than a year from now
		return true;
	}
	// allow all other dates
	return false;
};


function fillDateFields(datum, dagId, maandId, jaarId) {
	var datum_array = datum.split("-");
	$(dagId).value = datum_array[0];
	$(maandId).value = datum_array[1];
	if (jaarId != undefined) {
		$(jaarId).value = datum_array[2];
	}
}

function giveDateToCalendar(sourceDagId, sourceMaandId, sourceJaarId) {
	var datum = $(sourceDagId).value + "-" + $(sourceMaandId).value;
	var today = new Date();
	if (isDayMonthBeforeToday($(sourceDagId).value,$(sourceMaandId).value)) {
		$(sourceJaarId).value = today.getFullYear()+1;
	} else {
		$(sourceJaarId).value = today.getFullYear();
	}
	datum += "-" + $(sourceJaarId).value;
	calendar.parseDate(datum, "%d-%m-%Y");
}

function isDayMonthBeforeToday(myDay,myMonth) {
	var today = new Date();
	var aaa = ((parseInt(myMonth*1)*100) + parseInt(myDay*1));
	var bbb = (((today.getMonth()+1)*100) + today.getDate());
	if (aaa <= bbb) {
		return true;
	} else {
		return false;
	}
}

function giveBirthDateToCalendar(sourceDagId, sourceMaandId, sourceJaarId) {
	var datum = $(sourceDagId).value + "-" + $(sourceMaandId).value + "-" + $(sourceJaarId).value;
	calendar.parseDate(datum, "%d-%m-%Y");
}