function filterAct(val,type,fromDatePicker) {
	/*
	if (val!='All') {
		$.ajax({
			type: "POST",
			url: "/services/getActivities.php",
			data: "type="+type+"&val="+val,
			success: function(msg){
				$('.rightContent').html(msg);
				$('.leftContent').height($('.rightContent').height());
			}
		});
	} else {
		$.ajax({
			type: "POST",
			url: "/services/getActivities.php",
			success: function(msg){
				$('.rightContent').html(msg);
				$('.leftContent').height($('.rightContent').height());
			}
		});
	}
	*/
	if (!fromDatePicker) {
		var found = false;
		$('.filters select').each(function() {
			if ($(this).val() != '-1') found = true;
		});
		
		if (!found) type = 'all';
	}
	
	$.ajax({
		type: "POST",
		url: "/services/getActivities.php",
		data: "type="+type+"&val="+val,
		success: function(msg){
			$('.rightContent').html(msg);
			$('.leftContent').height($('.rightContent').height());
			
			if (type=='dates' && $('.rightContent .act').length==0) {
				
			}
		}
	});
}

function getParticipants(val) {
	val = val.split(';;');
	var actid = val[0];
	var date  = val[1];
	var time  = val[2];
	$.ajax({
		type: "POST",
		url: "/services/getParticipants.php",
		data: "actid="+actid+"&date="+date+"&time="+time,
		success: function(msg){
			if (msg!='') $('select[name=participants]').html(msg).attr('disabled',false);
			else $('select[name=participants]').attr('disabled',true);
		}
	});
}

function add2Cart(actinfo,amount) {
	actinfo = actinfo.split(';;');
	var actid = actinfo[0];
	var date  = actinfo[1];
	var time  = actinfo[2];
	$.ajax({
		type: "POST",
		url: "/services/add2cart.php",
		data: "actid="+actid+"&date="+date+"&time="+time+"&amount="+amount,
		success: function(msg){
			if (msg=='done') {
				$('select[name=date]').val(0);
				$('select[name=participants]').val(0);
				$('select[name=participants]').attr('disabled',true);
				if (confirm('De activiteit is aan uw inschrijflijst toegevoegd.')) window.location.href='/docent/inschrijven';
				/*
				$("#dialog").dialog("destroy");
				$("#dialog-confirm").dialog({
					resizable: false,
					height:160,
					buttons: {
						'Naar inschijfformulier': function() {
							window.location.href='/docent/inschrijven';
						},
						'Verder': function() {
							window.location.href='/docent/activiteiten';
						}
					}
				});
				*/
			} else if (msg=='wrong') alert('Er is iets fout gegaan bij het toevoegen aan uw inschrijflijst. Probeer het nogmaals of neem contact met ons op.');
		}
	});
}

function del2Cart(id) {
	var answer = confirm('Weet u zeker dat u deze activiteit uit uw inschrijflijst wilt verwijderen?');
	if (answer) {
		$.ajax({
			type: "POST",
			url: "/services/del2cart.php",
			data: "id="+id,
			success: function(msg){
				if (msg=='done') window.location.reload();
				else if (msg=='wrong') alert('Er is iets fout gegaan bij het verwijderen van uw inschrijflijst. Probeer het nogmaals of neem contact met ons op.');
			}
		});
	}
}

function del2Signups(id) {
	var answer = confirm('Weet u zeker dat u zich van deze activiteit wilt uitschrijven? De organisatie zal uw uitschrijving eerst beoordelen voordat u echt van deze activiteit wordt uitgeschreven. Wij nemen zo snel mogelijk contact met u op.');
	if (answer) {
		$.ajax({
			type: "POST",
			url: "/services/del2signup.php",
			data: "id="+id,
			success: function(msg){
				if (msg=='done') window.location.reload();
				else if (msg=='wrong') alert('Er is iets fout gegaan bij het verwijderen van uw inschrijflijst. Probeer het nogmaals of neem contact met ons op.');
			}
		});
	}
}

function doLogOut() {
	var answer = confirm('Weet u zeker dat u wilt uitloggen?');
	if (answer) {
		$.ajax({
			type: "POST",
			url: "/services/logout.php",
			success: function(msg){
				if (msg=='done') window.location.reload();
				else if (msg=='wrong') alert('Er is iets fout gegaan bij het uitloggen. Probeer het nogmaals of neem contact met ons op.');
			}
		});
	}
}

function loadBlogItems(amount) {
	$.ajax({ 
		type	: "GET", 
		url		: "/services/getTwitter.php", 
		data	: "amount="+amount,
		success	: function(html){
			$('#twitter').html(html);
			$('.leftContent').height($('.rightContent').height());
			$('.homeLeft, .homeRight').height($('.leftContent').height());
		}
	});
}
