var firstselect=0;
var firstselect2=0;

YAHOO.namespace("example.calendar"); 
		function showcal1() {
			// document.getElementById("cal2Container").style.display="none";
			if (document.getElementById("cal1Container").style.display=="none") document.getElementById("cal1Container").style.display=""; else document.getElementById("cal1Container").style.display="none";
			}

		function showcal2() {
			// document.getElementById("cal1Container").style.display="none";
			if (document.getElementById("cal2Container").style.display=="none") document.getElementById("cal2Container").style.display=""; else document.getElementById("cal2Container").style.display="none";
			}

	    function init_veranst() { 
	        YAHOO.example.calendar.cal1 = new YAHOO.widget.Calendar("cal1","cal1Container"); 
	        YAHOO.example.calendar.cal1.render(); 
			YAHOO.example.calendar.cal1.selectEvent.subscribe(handleSelect); 
			updateCal1();
	        YAHOO.example.calendar.cal2 = new YAHOO.widget.Calendar("cal2","cal2Container"); 
	        YAHOO.example.calendar.cal2.render(); 
			YAHOO.example.calendar.cal2.selectEvent.subscribe(handleSelect22); 
			updateCal22();
	    	} 

	    function init_heuriger() { 
	        YAHOO.example.calendar.cal2 = new YAHOO.widget.Calendar("cal2","cal2Container"); 
	        YAHOO.example.calendar.cal2.render(); 
			YAHOO.example.calendar.cal2.selectEvent.subscribe(handleSelect2); 
			updateCal2();
	    	} 




function handleSelect(type,args,obj) { 
	    var dates = args[0]; 
	    var date = dates[0]; 
	    var year = date[0], month = date[1], day = date[2]; 
	 	if (day<10) day="0"+day;
		if (month<10) month="0"+month;
	    document.freedatform.datum.value = day + "." + month + "." + year; 
	    document.getElementById('datumfield').innerHTML = day + "." + month + "." + year; 
		document.getElementById("cal1Container").style.display="none";
		document.getElementById("cal2Container").style.display="none";
		if (firstselect==0) firstselect=1; else document.freedatform.submit();
		// alert("jetzt");
	} 



function handleSelect2(type,args,obj) { 
	    var dates = args[0]; 
	    var date = dates[0]; 
	    var year = date[0], month = date[1], day = date[2]; 
	 	if (day<10) day="0"+day;
		if (month<10) month="0"+month;
	    document.freedatform2.datum.value = day + "." + month + "." + year; 
		document.getElementById("cal2Container").style.display="none";
		if (firstselect==0) firstselect=1; else document.freedatform.submit();
		// alert("jetzt");
	} 



function handleSelect22(type,args,obj) { /* für veranstaltungen der zweite kalender */
	    var dates = args[0]; 
	    var date = dates[0]; 
	    var year = date[0], month = date[1], day = date[2]; 
	 	if (day<10) day="0"+day;
		if (month<10) month="0"+month;
	    document.freedatform.bisdatum.value = day + "." + month + "." + year; 
	    document.getElementById('bisdatumfield').innerHTML = day + "." + month + "." + year; 
		document.getElementById("cal1Container").style.display="none";
		document.getElementById("cal2Container").style.display="none";
		if (firstselect2==0) firstselect2=1; else document.freedatform.submit();
		// alert("jetzt");
	} 


function handleSelect3(type,args,obj) { /* für veranstaltungen der zweite kalender */
	    var dates = args[0]; 
	    var date = dates[0]; 
	    var year = date[0], month = date[1], day = date[2]; 
	 	if (day<10) day="0"+day;
		if (month<10) month="0"+month;
	    document.freedatform2.bisdatum.value = day + "." + month + "." + year; 
	    document.getElementById('bisdatumfield').innerHTML = day + "." + month + "." + year; 
		document.getElementById("cal1Container").style.display="none";
		document.getElementById("cal2Container").style.display="none";
		if (firstselect2==0) firstselect2=1; else document.freedatform2.submit();
		// alert("jetzt");
	} 



function updateCal1() { 
	    // Select the date typed in the field 
		var dats=document.getElementById("datumfield").innerHTML.split(".");
		var val=Number(dats[1])+"/"+Number(dats[0])+"/"+Number(dats[2]);
	    YAHOO.example.calendar.cal1.select(val); 
	    var firstDate = YAHOO.example.calendar.cal1.getSelectedDates()[0]; 
	    // Set the Calendar's page to the earliest selected date 
	    YAHOO.example.calendar.cal1.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear()); 
	    YAHOO.example.calendar.cal1.cfg.setProperty("selected", val); 
	    YAHOO.example.calendar.cal1.cfg.setProperty("close", true); 
		YAHOO.example.calendar.cal1.cfg.setProperty("MONTHS_SHORT",   ["Jan", "Feb", "M\u00E4r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("MONTHS_LONG",    ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_1CHAR", ["S", "M", "D", "M", "D", "F", "S"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_MEDIUM",["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("WEEKDAYS_LONG",  ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]); 
		YAHOO.example.calendar.cal1.cfg.setProperty("START_WEEKDAY",  1); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("mindate",  "<? echo date("n/j/Y",strtotime("-1 day"));?>"); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("maxdat", "<? echo date("n/j/Y",strtotime("+1 year"));?>"); 
	    YAHOO.example.calendar.cal1.render(); 
	    // Select the date typed in the field 
	}  



function updateCal2() { 
	    // Select the date typed in the field 
		var dats=document.freedatform2.datum.value.split(".");
		var val=Number(dats[1])+"/"+Number(dats[0])+"/"+Number(dats[2]);
	    YAHOO.example.calendar.cal2.select(val); 
	    var firstDate = YAHOO.example.calendar.cal2.getSelectedDates()[0]; 
	    // Set the Calendar's page to the earliest selected date 
	    YAHOO.example.calendar.cal2.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear()); 
	    YAHOO.example.calendar.cal2.cfg.setProperty("selected", val); 
	    YAHOO.example.calendar.cal2.cfg.setProperty("close", true); 
		YAHOO.example.calendar.cal2.cfg.setProperty("MONTHS_SHORT",   ["Jan", "Feb", "M\u00E4r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("MONTHS_LONG",    ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_1CHAR", ["S", "M", "D", "M", "D", "F", "S"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_MEDIUM",["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_LONG",  ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("START_WEEKDAY",  1); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("mindate",  "<? echo date("n/j/Y",strtotime("-1 day"));?>"); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("maxdat", "<? echo date("n/j/Y",strtotime("+1 year"));?>"); 
	    YAHOO.example.calendar.cal2.render(); 
	    // Select the date typed in the field 
	}  



function updateCal22() { 
	    // Select the date typed in the field 
		var dats=document.getElementById("bisdatumfield").innerHTML.split(".");
		var val=Number(dats[1])+"/"+Number(dats[0])+"/"+Number(dats[2]);
	    YAHOO.example.calendar.cal2.select(val); 
	    var firstDate = YAHOO.example.calendar.cal2.getSelectedDates()[0]; 
	    // Set the Calendar's page to the earliest selected date 
	    YAHOO.example.calendar.cal2.cfg.setProperty("pagedate", (firstDate.getMonth()+1) + "/" + firstDate.getFullYear()); 
	    YAHOO.example.calendar.cal2.cfg.setProperty("selected", val); 
	    YAHOO.example.calendar.cal2.cfg.setProperty("close", true); 
		YAHOO.example.calendar.cal2.cfg.setProperty("MONTHS_SHORT",   ["Jan", "Feb", "M\u00E4r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("MONTHS_LONG",    ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_1CHAR", ["S", "M", "D", "M", "D", "F", "S"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_MEDIUM",["Son", "Mon", "Die", "Mit", "Don", "Fre", "Sam"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("WEEKDAYS_LONG",  ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]); 
		YAHOO.example.calendar.cal2.cfg.setProperty("START_WEEKDAY",  1); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("mindate",  "<? echo date("n/j/Y",strtotime("-1 day"));?>"); 
		// YAHOO.example.calendar.cal1.cfg.setProperty("maxdat", "<? echo date("n/j/Y",strtotime("+1 year"));?>"); 
	    YAHOO.example.calendar.cal2.render(); 
	    // Select the date typed in the field 
	}  


