
jQuery(document).ready(function($){
//************ Begin no conflict

//***********************************************************
function mycallback(){};






$(function()
{
	$('.date-pick')
		.datePicker(
			{
				createButton:false,
				inline:true,
				selectMultiple:true,
				renderCallback:function($td, thisDate, month, year)
				{
					if (thisDate.getDay() == 0 || thisDate.getDay() == 1) {
						$td.addClass('disabled');
					}
				}

				
			}
		)
		
		.bind(
			'dateSelected',
			function(e, selectedDate, $td, state)
			{
			var d = new Date();
					d.setTime(selectedDate);
					dag=d.getDate();
					maand=d.getMonth();
					jaar=d.getYear();					
					dagnaam=Date.dayNames[d.getDay()];
					dagn=Date.abbrDayNames[d.getDay()];
					maandnaam=Date.monthNames[maand];
					datum=dagnaam+" "+dag+" "+maandnaam+" "+jaar;
					idd=dagnaam+"_"+dag+"_"+maandnaam+"_"+jaar;
					//idd=Date.UTC(jaar,maand,dag);;

			if (state) {// ************** status true ****************
				
				reshtml='<span id ="'+idd+'">';
				
				reshtml+='<div class="myroundDiv"><span class="restekstheading">';
				reshtml+=datum+'</span>';
				
				reshtml+='<span class="restekstkader">';
				reshtml+=' kan ik mij vrij maken tussen  <input name="van'+idd+'" id="van'+idd+'" type="text" size="6" class="initsmall">';
				reshtml+=' en  <input name="tot'+idd+'" id="tot'+idd+'" type="text" size="6" class="initsmall"> ';
				reshtml+='<br>';
	
				reshtml+='</span>';
				
				reshtml+='</div><br></span>';
				
				
				if (countres==0){$("#reservaties").text("");}
				
				$("#reservaties").append(reshtml);	
			
			var sh=10,eh=19;
			if (dagn == 'Din'){sh=9;eh=21;};
			if (dagn == 'Woe'){sh=9;eh=18;};
			if (dagn == 'Don'){sh=9;eh=21;};
			if (dagn == 'Vry'){sh=9;eh=18;};
			if (dagn == 'Zat'){sh=10;eh=13;};
			
			$("#van"+idd).clockpick({starthour : sh,endhour : eh,showminutes : true,military:true,minutedivisions:2,hoursopacity:1,minutesopacity:1}, mycallback);

			
			$("#tot"+idd).clockpick({starthour : sh,endhour : eh,showminutes : true,military:true,minutedivisions:2,hoursopacity:1,minutesopacity:1}, mycallback);

			
			$("#van"+idd).val(sh+'u00');
			$("#tot"+idd).val(eh+'u00');
			
			countres++;//$("#oxo").text(countres);
			
			
			}else{//************** status false *********************
				
				$("#"+idd).remove();
				countres--;//$("#oxo").text(countres);
				
				};
			}
		)
		
});
 });//**************************** End no conflict ***********************

