$(document).ready(function(){ 
	
	$('#toggle-bgheader').click(function() {
		if($(this).hasClass('active')) {
			$(this).removeClass('active');
			$('#bgheader').stop().animate({
				height: '370px'
			  }, 1000, 'easeOutSine', function() {
				// Animation complete.
			  });
		}
		else {
			$(this).addClass('active');
			$('#bgheader').stop().animate({
				height: '100%'
			  }, 500, 'easeInSine', function() {
				// Animation complete.
			  });
		}
		
	})
	
	//Slideshow homepage
	$('#slideshow').nivoSlider({
		effect:'fade'
	});

	//Fancybox (lightbox)
	$("a.fancybox").fancybox();
	
	//Navigatie
	$('#nav li').hover(
        function () {
            //Submenu tonen
            $('ul', this).slideDown(100);
			$('a', this).addClass('selected');
 
        },
        function () {
            //Submenu verbergen
            $('ul', this).slideUp(100);
			$('a', this).removeClass('selected');        
        }
    )
	
	//Gallery image overlay
	$('a.fancybox').hover(
        function () {
            //overlay verbergen
            $(this).find('.overlay').fadeOut(300,'easeInQuad');
        },
        function () {
            //overlay tonen
            $(this).find('.overlay').fadeIn(500,'easeOutQuad');   
        }
    )
	$('a.fancybox').click(
        function () {
            //overlay verbergen
            $(this).find('.overlay').fadeIn(500,'easeOutQuad');
        }
	)	
	
	//Menukaart pijltjes fixed vanaf bepaalde hoogte
	var fixed = false;

	$(document).scroll(function() {
		if( $(this).scrollTop() >= 100 ) {
			if( !fixed ) {
				fixed = true;
				$('.arrow').css({position:'fixed',top:200});
			}
		} else {
			if( fixed ) {
				fixed = false;
				$('.arrow').css({position:'absolute',top:300});
			}
		}
	});
	
	/*$.featureList(
		$("#tabs li"),
		$("#output li"), {
			start_item : 1
		}
	);*/
	
	$('td.special-vraag').click(function() {
		if ($('input#terugbellen').attr('checked')) {
			$('input#terugbellen').attr('checked', false);
			$('input#telefoonnummer').attr('value', ' ');
			$('td.terugbellen').slideUp(400,'easeInOutExpo');
			$(this).removeClass('active');
		}
		else {
			$('input#terugbellen').attr('checked', true);
			$('td.terugbellen').slideDown(400,'easeInOutExpo');
			$(this).addClass('active');
		}
	})
	$('input#terugbellen').click(function() {
		if ($('input#terugbellen').attr('checked')) {
			$('input#terugbellen').attr('checked', false);
			$('input#telefoonnummer').attr('value', ' ');
			$('td.terugbellen').slideUp(400,'easeInOutExpo');
			$(this).removeClass('active');
		}
		else {
			$('input#terugbellen').attr('checked', true);
			$('td.terugbellen').slideDown(400,'easeInOutExpo');
			$(this).addClass('active');
		}
	})
	
	$('td.special-reserveer').click(function() {
		$('td.special-reserveer').removeClass('active');
		$(this).find('input.radio').attr('checked', true);
		$(this).addClass('active');
		var titleName = $(this).find('input.radio').attr('title');
		if (titleName != 'besloten') {
			$('td.extra').slideUp(400,'easeInOutExpo');
			$('input.checkbox-extra').attr('checked', false);
		}
		if (titleName == 'besloten') {
			$('td.extra').slideDown(400,'easeInOutExpo');
		}	
		
	})
	
	//GOOGLE MAPS ROUTE PLANNER
	$('#gmaps-action').click(function() {
		var postcode = $('#gmaps-input').attr('value');
		if(postcode.match(/[1-9][0-9]{3} ?[a-zA-Z]{2}/) && postcode != '1234AB') {
			$('#gmaps-input').removeClass('error');
			var maps = "http://maps.google.com/maps?q=from:+" + postcode + "+to:+3012KM"
			window.open(maps);
		}
		else {
			$('#gmaps-input').addClass('error');
		}
		
		
	})
			 
	
	$("input").focusin(function () {
		 $(this).removeClass('filled');
         $(this).addClass('active');
    });
	
	$("input").focusout(function () {
         $(this).removeClass('active');
		 
		 if ($(this).attr('value') != '') {
			 $(this).addClass('filled');
		 }
    });
	
	$("textarea").focusin(function () {
		 $(this).removeClass('filled');
         $(this).addClass('active');
    });
	
	$("textarea").focusout(function () {
         $(this).removeClass('active');
		 if ($(this).attr('value') != '') {
			 $(this).addClass('filled');
		 }
    });
	
	$('#gmaps-input').focusin(function() {
		if($(this).attr('value', '1234AB')) {
		   $(this).attr('value', '');	
		}
	})
	
	$('#gmaps-input').focusout(function() {
		$(this).removeClass('active'); 
		if ($(this).attr('value') == '') {
			$(this).attr('value', '1234AB');
		}
	})
	
	
	$(function() {
		var $mybook 		= $('#mybook');
		var $bttn_next		= $('#next_page_button');
		var $bttn_prev		= $('#prev_page_button');

		$bttn_next.show();
		$bttn_prev.show();
		$mybook.show().booklet({
			name:               null,                            // name of the booklet to display in the document title bar
			width:              867,                             // container width
			height:             510,                             // container height
			speed:              600,                             // speed of the transition between pages
			direction:          'LTR',                           // direction of the overall content organization, default LTR, left to right, can be RTL for languages which read right to left
			startingPage:       0,                               // index of the first page to be displayed
			easing:             'easeInOutQuad',                 // easing method for complete transition
			easeIn:             'easeInQuad',                    // easing method for first half of transition
			easeOut:            'easeOutQuad',                   // easing method for second half of transition

			closed:             false,                           // start with the book "closed", will add empty pages to beginning and end of book
			closedFrontTitle:   null,                            // used with "closed", "menu" and "pageSelector", determines title of blank starting page
			closedFrontChapter: null,                            // used with "closed", "menu" and "chapterSelector", determines chapter name of blank starting page
			closedBackTitle:    null,                            // used with "closed", "menu" and "pageSelector", determines chapter name of blank ending page
			closedBackChapter:  null,                            // used with "closed", "menu" and "chapterSelector", determines chapter name of blank ending page
			covers:             false,                           // used with  "closed", makes first and last pages into covers, without page numbers (if enabled)

			pagePadding:        10,                              // padding for each page wrapper
			pageNumbers:        true,                            // display page numbers on each page

			hovers:             false,                            // enables preview pageturn hover animation, shows a small preview of previous or next page on hover
			overlays:           false,                            // enables navigation using a page sized overlay, when enabled links inside the content will not be clickable
			tabs:               false,                           // adds tabs along the top of the pages
			tabWidth:           60,                              // set the width of the tabs
			tabHeight:          20,                              // set the height of the tabs
			arrows:             false,                           // adds arrows overlayed over the book edges
			cursor:             'pointer',                       // cursor css setting for side bar areas

			hash:               false,                           // enables navigation using a hash string, ex: #/page/1 for page 1, will affect all booklets with 'hash' enabled
			keyboard:           true,                            // enables navigation with arrow keys (left: previous, right: next)
			next:               $bttn_next,          			// selector for element to use as click trigger for next page
			prev:               $bttn_prev,          			// selector for element to use as click trigger for previous page

			menu:               null,                            // selector for element to use as the menu area, required for 'pageSelector'
			pageSelector:       false,                           // enables navigation with a dropdown menu of pages, requires 'menu'
			chapterSelector:    false,                           // enables navigation with a dropdown menu of chapters, determined by the "rel" attribute, requires 'menu'

			shadows:            true,                            // display shadows on page animations
			shadowTopFwdWidth:  166,                             // shadow width for top forward anim
			shadowTopBackWidth: 166,                             // shadow width for top back anim
			shadowBtmWidth:     50,                              // shadow width for bottom shadow

			before:             function(){},                    // callback invoked before each page turn animation
			after:              function(){}                     // callback invoked after each page turn animation
		});	
	});
})
