$(document).ready(function(){
	$("#matchdate").change(
		function(){
			$.post("/data/getsectionsbymatchdate.ajax",	{ date: $("#matchdate").val() },
				function(data){
					$("#matchsection").html(data);				
			});
		setTimeout("$('#matchsection').change()", 500);
	});


	$("#matchsection").change(
		function() {
			$.post(
				"/data/getmatchteamsbysection.ajax",
				{ date: $("#matchdate").val(), section: $("#matchsection").val() },
				function(data) {
					$("#matchteam").html(data);
					draw_teamprogramma();
				}
			)
		}
	);

	$("#matchteam").change(
		function() {
			draw_teamprogramma();
		}
	);

	function draw_teamprogramma() {
		$("#matchprogramma").html('<p>&nbsp;</p><p align="center"><img src="/images/layout/loader.gif" class="noline" /></p>');
		var cb = document.getElementById('afgelast').checked;
		$.post(
			"/data/getmatchprogrambyfilter.ajax",
			{ date: $("#matchdate").val(), section: $("#matchsection").val(), team: $("#matchteam").val(), afgelast: cb  },
				function(data) {
					$("#matchprogramma").html(data);
			}
		)
	}

$("#matchdate").change();

//	$("#element").show();
//	$("#element").hide('slow');
});

function showhide(what) {
	var divs = what.parentNode.getElementsByTagName('div');
	
	if( divs[0].style.display == 'none' || divs[0].style.display == '' ) {
		divs[0].style.display = 'block';
	} else {
		divs[0].style.display = 'none';
	}
}
