Calendar.setup({
	ifFormat       :    "%Y/%d/%m",      // format of the input field
	button         :    "btn_d_checkin",  // trigger for the calendar (button ID)
	align          :    "Tl",           // alignment (defaults to "Bl")
	singleClick    :    true,
	onUpdate 	   :	catcalcIN
});

function insertDates () {
	chkin_day 	= document.getElementById('chkin_day').value;
	chkin_month = document.getElementById('chkin_month').value;
	chkin_year 	= document.getElementById('chkin_year').value;
	arrivaldate 	= 	chkin_month + "/" +  chkin_day + "/" + chkin_year;
	document.getElementById('DateIn').value 		= arrivaldate;
}

function setDateToForm(date) {
	var d	=	date.getDate();
	var m	=	date.getMonth()+1;
	if(d<10) d='0'+d;
	if(m<10) m='0'+m;
	document.getElementById('chkin_day').value=d;
	document.getElementById('chkin_month').value=m;
	document.getElementById('chkin_year').value=date.getFullYear();	
}

function catcalcIN(cal) {
	setDateToForm(cal.date);
}

var BuchungsFenster = null;

function go() {
	insertDates ();
	if ( BuchungsFenster == null ) {
		BuchungsFenster = window.open("", "Buchungsanfrage", "toolbar=no,width=1030,height=700,top=50,left=100,directories=no,status=yes,scrollbars=yes,resize=yes,menubar=no" );
	} else {
		if ( BuchungsFenster.closed )
			BuchungsFenster = window.open("", "Buchungsanfrage", "toolbar=no,width=1030,height=700,top=50,left=100,directories=no,status=yes,scrollbars=yes,resize=yes,menubar=no" );
		else
			BuchungsFenster.focus();
	}
	
	document.bkrequest.target="Buchungsanfrage";
	document.bkrequest.action="http://www.hotelzoo.de/isproxy.php";
	document.bkrequest.submit();
	document.bkrequest.action="go()";
	document.bkrequest.target="_self";
}

function init_date() {
	var jetzt = new Date();
	setDateToForm(jetzt);
}
init_date();
