// ajax to call the script which finds the teas which match the picker settings

function doPicker(year,month) {
$.post("inc/cal.php", { year: year, month: month },
   		function(data){
			$("#cal_results").html(data);
		});
}

function doDeliveryPicker(year,month,target,group) {
$.post("inc/deliverycal.php", { year: year, month: month, target: target, group: group },
   		function(data){
			$(target).html(data);
		});
}


function doAdminPicker(year,month) {
$.post("inc/cal.php", { year: year, month: month },
   		function(data){
			$("#cal_results").html(data);
		});
}


function bookit(day, month, year, action) {
	$("#status").text("Saving...");

if (action == "book") {
var url = 'inc/bookit.php';
} else {
var url = 'inc/unbookit.php';
}
$.post(url, { year: year, month: month, day: day },
   		function(){
			doAdminPicker(year, month);
		});

$("#status").text("");
}

function bookdelivery(day, month, year, target, group) {
	
$('#date_'+target).val(day+"/"+month+"/"+year);
setBasketInfoSessions();
var myDate=new Date();
month = month - 1;
myDate.setFullYear(year,month,day);
var today = new Date();

if (myDate>today)
  {
	  month = month + 1;
$.post("inc/setpostage.php", { type: '1', group: group, day: day, month: month, year: year });
calcCart(1);
}
else
  {
	  month = month + 1;
$.post("inc/setpostage.php", { type: '2', group: group, day: day, month: month, year: year });
  calcCart(1);
  }
}
