
function CalenderWidget(container, restrictionManager, minDate, maxDate) {
	this.container = container;
	this.restrictionManager = restrictionManager;
	this.minDate = minDate;
	this.maxDate = maxDate;
}

CalenderWidget.prototype = {

	render: function() {
		widget = new YAHOO.widget.Calendar("cal", this.container.attr("id"), { 
			MULTI_SELECT: false, 
			START_WEEKDAY: 1,
			DATE_DELIMITER: ';',
			DATE_FIELD_DELIMITER: "-",
			DATE_RANGE_DELIMITER: "_",
			MDY_YEAR_POSITION: 1,
			MDY_MONTH_POSITION: 2,
			MDY_DAY_POSITION: 3
		});
		
		widget.cfg.setProperty("MONTHS_LONG",    ["Januar", "Februar", "M\u00E4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"]); 
		widget.cfg.setProperty("WEEKDAYS_SHORT", ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"]); 

		if (this.minDate) widget.cfg.setProperty("mindate", this.minDate);
		if (this.maxDate) widget.cfg.setProperty("maxdate", this.maxDate);

		var dates = new Array();
		var dateRestrictions = this.restrictionManager.getRestrictions("datum");
		for (var n = 0; n < dateRestrictions.length; n++) {
			dates.push(dateRestrictions[n].value);
		}
		
		if (dates.length) {
			widget.cfg.setProperty("selected", dates.join(";"));
			var dateParts = dates[0].split("-");
			widget.setMonth(dateParts[1]-1);
			widget.setYear(dateParts[0]);
		}
		
		widget.restrictionManager = this.restrictionManager;   
		widget.renderCellDefault = function(d, cell) {
			year = d.getFullYear();
			month = d.getMonth()+1;
			if (month<10) month = '0' + month;
			day = d.getDate();
			if (day<10) day = '0' + day;

			var url = this.restrictionManager.createDatumUrl(year + '-' + month + '-' + day);
			cell.innerHTML = '<a href="' + url + '" onclick="event.cancelBubble = true; return true;" class="' + this.Style.CSS_CELL_SELECTOR + '">' + this.buildDayLabel(d) + "</a>"; 
			return YAHOO.widget.Calendar.STOP_RENDER; 
		};
		
		this.restrictionManager.attachToCalenderWidget(this.widget);

		widget.render();
	}
	
}
 
