icuro.worker = icuro.worker || {};

icuro.worker.calendar = (function () {

	function datePickerSetup () {
		//todays date
		var dateToday = new Date();
		var todayDate = dateToday.toLocaleDateString("en-GB"); //returns 05/12/2014
		$('#datepicker-date-full').text(todayDate);

		var todayDateNumber = dateToday.getDate(); //returns 5 if 05/12/2014
		$('#datepicker-date-selected').text(todayDateNumber);

		var options = {
		    weekday: "long", year: "numeric", month: "short",
		    day: "numeric", hour: "2-digit", minute: "2-digit"
		};

		var weekday = new Array(7);
		weekday[0]=  "Sunday";
		weekday[1] = "Monday";
		weekday[2] = "Tuesday";
		weekday[3] = "Wednesday";
		weekday[4] = "Thursday";
		weekday[5] = "Friday";
		weekday[6] = "Saturday";

		var todaysDay = weekday[dateToday.getDay()]; // returns Tuesday
		$('#datepicker-day-of-week').text(todaysDay);

		$("#datepicker").datepicker({
			inline: true,
			minDate: new Date(),
			firstDay: 1,
			dateFormat: "dd-mm-yy",
			onSelect: function(date) {
				// work out selected date 
				var dateSelect = $(this).datepicker('getDate'); //used below

				var todayDateOnChange = $.datepicker.formatDate('d/m/yy', dateSelect); //shows 10/03/1994
				$('#datepicker-date-full').text(todayDateOnChange);
		        
    			var dayOfWeek = $.datepicker.formatDate('DD', dateSelect); //shows Monday
    			$('#datepicker-day-of-week').text(dayOfWeek);

    			var dateOfSelected = $.datepicker.formatDate('d', dateSelect); //shows 10 if 10/03/1994
    			$('#datepicker-date-selected').text(dateOfSelected);
		    }
		});

		//TODO: 
		// - get current month, last month and next month
		// - get date in 24 August 2014 format
	}

	datePickerSetup();
});