function cutMonth(value) {
	return parseInt(value) < 10 ? value.substr(1,1) : value;
}
function dateFields(el) {
	var id = el.id.substr(0,1);
	var dtArray = el.value.split('.');
	if (dtArray.length == 3) {
		document.getElementById(id + "dd").value	= dtArray[0];
		document.getElementById(id + "mm").value	= cutMonth(dtArray[1]);
		document.getElementById(id + "yy").value	= dtArray[2];
	}
}
Calendar.setup({
	inputField		:	"vdd",
	ifFormat		:	"%d.%m.%Y", 
	button			:	"dt_fm_btn",
	singleClick		:	true,
    weekNumbers		:	false
});
Calendar.setup({
	inputField		:	"bdd",
	ifFormat		:	"%d.%m.%Y", 
	button			:	"dt_to_btn",
	singleClick		:	true,
    weekNumbers		:	false
});

// fill datefields
var dtnow = new Date();
var today = new Date(dtnow.getFullYear(), dtnow.getMonth(), dtnow.getDate() + 1, 0, 0, 0);
var tomorrow = new Date(dtnow.getFullYear(), dtnow.getMonth(), dtnow.getDate() + 8, 0, 0, 0);
document.getElementById("vdd").value = today.print('%d');
document.getElementById("vmm").value = cutMonth(today.print('%m'));
document.getElementById("vyy").value = today.print('%Y');
document.getElementById("bdd").value = tomorrow.print('%d');
document.getElementById("bmm").value = cutMonth(tomorrow.print('%m'));
document.getElementById("byy").value = tomorrow.print('%Y');
