
scheduler.templates.day_date = function(date){
	var format = scheduler.date.date_to_str("%D, %j %M %Y");
    return format(date);
};
scheduler.templates.week_date = function(start, end){
	var format = scheduler.date.date_to_str("%j %M %Y");
	var endDate = new Date(end.getFullYear(),end.getMonth(),(end.getDate()-1));
	return format(start)+' &ndash; '+format(endDate);
};
scheduler.config.xml_date="%Y-%m-%d %H:%i";
scheduler.config.readonly = true;
scheduler.config.prevent_cache = true;
scheduler.config.select = false;
// 	scheduler.config.multi_day = true;
scheduler.templates.week_agenda_event_text = function(start_date, end_date, event, date, position) {
	switch(position){
		case "middle": return "-- " + event.text;
		case "end": return "[Selesai] "+scheduler.templates.event_date(end_date) + " " + event.text;
		case "start": return "[Mulai] "+scheduler.templates.event_date(start_date) + " " + event.text;
		default: return scheduler.templates.event_date(start_date) + " " + event.text;
	}
};

// Limit scheduler in date range, disable button next
function schDateLimit(startDate,endDate){
	var startArr = startDate.split('-');
	var startDay = parseInt(startArr[2]);
	var startMon = parseInt(startArr[1]);
	var startYear = parseInt(startArr[0]);
	var endArr = endDate.split('-');
	var endDay = parseInt(endArr[2]);
	var endMon = parseInt(endArr[1]);
	var endYear = parseInt(endArr[0]);
	
	scheduler.config.limit_start = new Date(startYear, (startMon-1), startDay);
	scheduler.config.limit_end = new Date(endYear, (endMon-1), endDay);
	scheduler.config.limit_view = true;
}

// Highlight Out Range Date
function schHlOutRangeDate(startDate,endDate){
	var startArr = startDate.split('-');
	var startDay = parseInt(startArr[2]);
	var startMon = parseInt(startArr[1]);
	var startYear = parseInt(startArr[0]);
	var endArr = endDate.split('-');
	var endDay = parseInt(endArr[2]);
	var endMon = parseInt(endArr[1]);
	var endYear = parseInt(endArr[0]);
	
	scheduler.deleteMarkedTimespan();
	
	scheduler.addMarkedTimespan({
		start_date: new Date((startYear-1),00,01),
		end_date: new Date(startYear, (startMon-1), startDay),
		css: "grey_section"
	}); 
	
	scheduler.addMarkedTimespan({
		start_date: new Date(endYear, (endMon-1), (endDay+1)),
		end_date: new Date((endYear+1),11,31),
		css: "grey_section"
	});
	
	scheduler.templates.month_date_class=function(date,today){
		var start = new Date(startYear,(startMon-1),startDay);
		var end = new Date(endYear,(endMon-1),endDay);
		var cssClass = '';
		if(date < start || date > end) cssClass = 'grey_section';
		return cssClass;
	}; 
}
