$(document).ready(function(){

	initHomeAnimation();			   
	initSearchFocus();
	initCalendar();
});

// Animation homepage
function initHomeAnimation(){
	if ($('#animationHome').length) {
		$('#animationHome').flash(
		{ 
			src: '../swf/home.swf',
			width: 934,
			height: 288,
			wmode: 'opaque',
			flashvars: { pathToXml: '../php/AjaxController.php' }
		},
		{ version: 8 }
		);
	}
}

// Hide input field content
function initSearchFocus(){
    if ($('#q').length) {
		$('#q').focus(function() {
			if ($(this).val()=="zoek cursussen..."||$(this).val()=="Vul hier uw trefwoord in") $(this).val("");
		});
	}
}

// Initialise the calendar
function initCalendar(){
	if($('#calendar').length){
		$('#calendar .next, #calendar .prev').click(function(){
			var getMonth = $(this).attr('rel');
			$.ajax({
				type: "POST",
				dataType: "html",
				url: "/php/AjaxController.php",
				data: "action=rGetCalendar&month="+getMonth,
				success: function(msg){
					if(msg.length){
						$('#calendar').replaceWith(msg);
						initCalendar();
					}
				}
			});
		});
	}
}