$(function(){

	/*****  Links in nieuw venster *****/

    $('a.new-window').click(function(){
        window.open(this.href);
        return false;
    });
    
    /***** Accordion menu (http://www.i-marco.nl/weblog/archive/2010/02/27/yup_yet_another_jquery_accordi) *****/
    
    $('#menu').initMenu();

	/***** Fancybox *****/

	$('.fotoalbum a').fancybox({
		'opacity'			: 'true',
		'overlayOpacity'	: '0.7',
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'speedIn'			: '5000',
		'overlayColor'		: '#fff',
		'cyclic'			: 'true',
		'titleShow'			: false,
		'titlePosition' 	: 'over'
	});
	
	/*****  Labels in input velden *****/
	
	$('form#contactform label.inside').inFieldLabels({fadeOpacity: 0});
	$('form#contactform input').attr('autocomplete','on');

	/* Formulier validatie */
	
	$('#contactform').validate({
    	//Geen error tonen
		errorPlacement:		function(error,element) {
                       			return true;
                    		},
    	rules:		{	naam:		{required: true},
    					email:		{required: true, email: true},
    					bericht:	{required: true, minlength: 0}
    				}
    });
    
    /*****  Verstuur contactformulier *****/
	
	$('#contactform').submit(function(){ // controleer of het contactformulier verstuurd werd
		
		if($('#contactform').valid()){
			$('#confirm').load('/nl/contact/a/submit', $(this).serializeArray()); // laadt tekst in <p id="confirm"> met bevesting van verzending
			$('#contactform input:text').val(''); // leeg de input fields
			$('#contactform textarea').val(''); // leeg de tekstvelden
			$('#contactform label').css('opacity','1');
			location.href='#verstuurd'; // ga naar top van de pagina om de melding beter te zien
			return false;
		}
	});
	
	/*****  Bewegende banner *****/

	$('#characteristics ul').innerfade({
		animationtype: 'fade',
    	speed: 1500,
    	timeout: 5000,
    	type: 'random_start'
	});

	$('#banner ul').innerfade({
		animationtype: 'fade',
    	speed: 1500,
    	timeout: 5000,
    	type: 'random_start'
	});
	
	// http://www.i-marco.nl/weblog/jquery-accordion-3/
	// http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm
	
});
