function slideshow(){
	$('#slides').cycle({ 
		fx:     'fade', 
		timeout: 0,
		next:   '#slideshow_next', 
		prev:   '#slideshow_prev'
	});
}
function fadeInput() {
	$('input.fade').each(function(){
		if ( $(this).val() != '' ) {
			$(this).css('background-repeat', 'repeat');
			$(this).prev().fadeTo(150, 0.33);
		}
	});
	$('input.fade').focus(function() {
		$(this).select();
		$(this).prev().fadeTo(150, 0.33);
		$(this).keydown(function() {
			$(this).css('background-repeat', 'repeat');			 
		});
	});
	$('input.fade').blur(function() {
		if ( $(this).val() == '' ) {
			$(this).css('background-repeat', 'no-repeat');
			$(this).prev().fadeTo(150, 1);
		}
	});
}
function initCalendar() {
	$('.month a').click(function() {
		var sMaand = $(this).attr('title');
		var aMaand = sMaand.split('-');
		var sData = 'month='+aMaand[0]+'&year='+aMaand[1];
		$.ajax({
			type: 'POST',
			url: 'agenda/index',
			data: sData,
			success: function(result){
				$('#ajax-kalender').html(result);
				initCalendar();
				initCalendarHover();
			}
		});
	});
}
function initCalendarHover() {
	$('.kalender .day.event').hover(function() {
		$(this).addClass('hover');
		$(this).children('.tooltip').show();
	}, function() {
		$(this).removeClass('hover');
		$('.tooltip').hide();
	});
}
function initSelectboxes(){
	$('div.select select').selectbox();
	var zIndex = 9999;
	$('div.form div.entry').each(function(){
		$(this).css('z-index',zIndex);
		zIndex--;
	});
}

function validateForm(p_sForm) {
	
	switch(p_sForm) {
		
		case 'newsletterform':
		
			var rules = {};
			rules['sName'] = {
				required: true,
				notags: true,
				minlength: 2
			};
			rules['sEmail'] = {
				required: true,
				email: true,
				notags: true
			};
			
			var messages = {};
			messages['sName'] = {
				required: 'Vul uw naam in',
				notags: 'U mag geen tags invullen',
				minlength: 'Vul minimaal 2 tekens in'
			};
			messages['sEmail'] = {
				required: 'Vul uw e-mailadres in',
				email: 'Vul een geldig e-mailadres in',
				notags: 'U mag geen tags invullen'
			};
		
		break;
		
		case 'contactform':
		
			var rules = {};
			rules['sName'] = {
				required: true,
				notags: true,
				minlength: 2
			};
			rules['sEmail'] = {
				required: true,
				email: true,
				notags: true
			};
			rules['sMessage'] = {
				required: true,
				notags: true
			};
			
			var messages = {};
			messages['sName'] = {
				required: 'Vul uw naam in',
				notags: 'U mag geen tags invullen',
				minlength: 'Vul minimaal 2 tekens in'
			};
			messages['sEmail'] = {
				required: 'Vul uw e-mailadres in',
				email: 'Vul een geldig e-mailadres in',
				notags: 'U mag geen tags invullen'
			};
			messages['sMessage'] = {
				required: 'Vul uw bericht in',
				notags: 'U mag geen tags invullen'
			};
			
		break;
		
		case 'activityform':
		
			var rules = {};
			rules['sNaam'] = {
				required: true,
				notags: true,
				minlength: 2
			};
			rules['sEmail'] = {
				required: true,
				email: true,
				notags: true
			};
			rules['sTelefoon'] = {
				required: true,
				telephone: true,
				notags: true
			};
			
			var messages = {};
			messages['sNaam'] = {
				required: 'Vul uw naam in',
				notags: 'U mag geen tags invullen',
				minlength: 'Vul minimaal 2 tekens in'
			};
			messages['sEmail'] = {
				required: 'Vul uw e-mailadres in',
				email: 'Vul een geldig e-mailadres in',
				notags: 'U mag geen tags invullen'
			};
			messages['sTelefoon'] = {
				required: 'Vul uw telefoonnummer in',
				telephone: 'Vul een geldig telefoonnummer in.',
				notags: 'U mag geen tags invullen'
			};
			
		break;
		
	}
	
	$('#'+p_sForm).validate({
		rules: rules,
		messages: messages,
		errorPlacement: function(error, element) {
			error.insertAfter(element.parents('.input, .textarea'));
		},
		success: function(label) {
			label.remove();
		},
		submitHandler: function(form) {
			form.submit();
		}
	});	
}

