$(document).ready(function() {
	hoverSubmenu();
});

function hoverSubmenu() {
	$('.menu_item').hover(function() {
		$(this).children('.submenu, .submenu_top').show();
	}, function() {
		$(this).children('.submenu, .submenu_top').hide();
	});
}

function initSlideshow() {
	$('#slideshow')
	.cycle({
		fx:     'fade',
		timeout: 5000,
		speed:	 900
	});
}

function vacatures() {
	$('.lees_meer_info a').click(function() {
		$(this).parent().hide();									  
		$(this).parent().next().slideDown(500);	
	});
	$('a.sluiten').click(function() {
		$(this).parents('.meer_info').slideUp(500, function() {
			$(this).prev().slideDown(250);									  
		});	
	});
}

function validateForm() {	
	var iconOK = {
		'background-position' : '0px -32px'
	}
	var iconError = {
		'background-position' : '0px 0px'
	}
	$('#contactformulier').validate({
		rules: {
			sContactpersoon: 'required',
			sBericht: 'required',
			sEmail: {
				required: true,
				email: true
			}
		},
		messages: {
			sContactpersoon: 'Vul uw naam in.',
			sBericht: 'Vul een bericht in.',
			sEmail: {
				required: 'Vul uw e-mailadres in.',
				email: 'Vul een geldig e-mailadres in.'
			}
		},
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().next());
			element.parent().next('div.controle').css(iconError);
		},
		success: function(label) {
			label.prev('div.controle').css(iconOK);
			label.remove();
		},
		submitHandler: function(form) {
			form.submit();
		}
	});	
	$('#aanmeldformulier').validate({
		rules: {
			sContactpersoon: 'required',
			sBedrijf: 'required',
			sAantal: 'required'
		},
		messages: {
			sContactpersoon: 'Vul uw naam in.',
			sBedrijf: 'Vul een bedrijfsnaam in.',
			sAantal: 'Vul het aantal personen in'
		},
		errorPlacement: function(error, element) {
			error.insertAfter(element.parent().next());
			element.parent().next('div.controle').css(iconError);
		},
		success: function(label) {
			label.prev('div.controle').css(iconOK);
			label.remove();
		},
		submitHandler: function(form) {
			form.submit();
		}
	});	
}

function radioButtons() {
	$('.radio span').click(function() {
		$('.radio span').removeClass('checked');	
		$('.radio span input').attr("checked","");
		$(this).addClass('checked');
		$(this).children('input').attr("checked","checked");
	});
}

function filterActueel() {
	$('.selectbox-wrapper ul li').click(function(){
		sFilter = $(this).attr('id');
		$.ajax({
			type: 'POST',
			url: sDomain+'/inc/request.actueel.php',
			data: 'sFilter='+sFilter,
			success: function(result){
				$('#right').html(result);
				
				$('#sFilter').selectbox();
				filterActueel();
				
				sIFR.replace(sifr, {
				selector: 'h3'
				,css: [
				  '.sIFR-root { padding: 0px; font-weight: bold; font-size: 26px; color: #001f59; line-height: 34px; height: 34px; width: auto;}'
				],
				wmode: 'transparent'
				});
			}
		});
	});	
}


