$(document).ready(function(){




// global menu

	$(".menu ul li:first").addClass('home-button');


	$(".menu ul li").hover(function()
		{
		$(this).children("ul").show();
		},function()
		{
		$(this).children("ul").fadeOut('fast');
		}
	);
	


	// higlight parent of submenu
	$(".menu ul ul").hover(function()
		{
		$(this).parent("li").addClass('current_rollover_parent');
		},function()
		{
		$(this).parent("li").removeClass('current_rollover_parent');
		}
	);
	


	// disable the top menu items and get the href of the first child element
	$('.menu ul li.page-item-3 a').not('.menu ul li.page-item-3 ul a').click(function(event)
		{
		event.preventDefault();
		window.location = $(this).next('ul').find('a').attr('href');
		}
	);
	$('.menu ul li.page-item-16 a').not('.menu ul li.page-item-16 ul a').click(function(event)
		{
		event.preventDefault();
		window.location = $(this).next('ul').find('a').attr('href');
		}
	);
	$('.menu ul li.page-item-17 a').not('.menu ul li.page-item-17 ul a').click(function(event)
		{
		event.preventDefault();
		window.location = $(this).next('ul').find('a').attr('href');
		}
	);
	$('.menu ul li.page-item-746 a').not('.menu ul li.page-item-746 ul a').click(function(event)
		{
		event.preventDefault();
		window.location = $(this).next('ul').find('a').attr('href');
		}
	);	


	
// telefoonnummer
	
	$('#footer a.telefoonnummerBttn').click(function(event)
		{
		event.preventDefault();
		$('#telefoonnummer').animate({opacity: 'toggle'}, 'fast');
		}
	);
	$('#telefoonnummerCloseBttn a').click(function(event)
		{
		event.preventDefault();
		$('#telefoonnummer').animate({opacity: 'toggle'}, 'fast');
		}
	);


	// center the div
	$("#telefoonnummer").css({left: $(window).width()/2-425});
	// center the content while the user resizes the window
	$(window).resize(function()
		{
		$('#telefoonnummer').css({left: $(window).width()/2-425});
		}
	);


	$('#telefoonnummerCloseBttn a').css({ opacity: '0.3' });
	$('#telefoonnummerCloseBttn a').hover(function()
		{
		$(this).css({ opacity: '1'});
		}, function()
		{
		$(this).css({ opacity: '0.3'});
		}
	);





// homepage news
	
	
	$("#homeImages").before('<div id="homeImagesPager"></div>').cycle(
		{ 
    	fx:			"fade", 
    	speed:		1000, 
    	timeout:	5500,
		pager:		'#homeImagesPager',
		random:		1
		}
	);
	$('.description').hover(function()
		{
		$('#homeImages').cycle('pause');
		},function()
		{
		$('#homeImages').cycle('resume');
		}
	);

	
	
	
	
//google map contact page
	$('a#map-open-button').click(function(event)
		{
		event.preventDefault();
		if ($(this).data('currentState'))
			{
			$('#map').animate({opacity: 'toggle'}, 'fast');
			$(this).data('currentState', false); 
			} else {
			$('#map').css({ display: 'none' });
			$('#map').css({ top: '0' });
			$('#map').animate({opacity: 'toggle'}, 'fast');
			$(this).data('currentState', true);
			}
		}
	);
	$('#map-close-button a').click(function(event)
		{
		event.preventDefault();
		$('#map').animate({opacity: 'toggle'}, 'fast');
		}
	);
	
	



//luikjes op homepage

	function luikje1(var1,var2)
		{


		var interval = var2;
	
	
		function openLuikje()
			{
			openTimer1 = setTimeout(function()
				{
				$(var1).find('.luikje-deksel').animate(
					{
					marginTop: "-80px"
					}, 500, function()
					{
					sluitLuikje();
					interval = interval + 500;
					}
				);
				}, interval);
			}


		function sluitLuikje()
			{
			sluitTimer1 = setTimeout(function()
				{
				$(var1).find('.luikje-deksel').animate(
					{
					marginTop: "0"
					}, 500, function()
					{
					openLuikje();
					}
				);
				}, 2000);
			}


	
		setTimeout(function()
			{
			$(var1).fadeIn( 'slow', openLuikje() );
			}, 250);



		$(var1).hover(function()
			{
			clearTimeout(sluitTimer1);
			clearTimeout(openTimer1);
			$(this).find('.luikje-deksel').animate({ marginTop: "-80px" }, 250);
			window.status = $(this).find('a').attr('href');
			}, function()
			{
			$(this).find('.luikje-deksel').animate({ marginTop: "0" }, 250);
			window.status = '';
			openLuikje();
			}
		).click(function()
			{
			if ( $(this).find('a').attr('target') == '')
				{
				window.location = $(this).find('a').attr('href');
				} else {
				window.open($(this).find('a').attr('href'));
				}
			}
		);


		}

luikje1('#luikje1', 4000);





	function luikje2(var1,var2)
		{


		var interval = var2;
	
	
		function openLuikje()
			{
			openTimer2 = setTimeout(function()
				{
				$(var1).find('.luikje-deksel').animate(
					{
					marginTop: "-80px"
					}, 500, function()
					{
					sluitLuikje();
					interval = interval + 500;
					}
				);
				}, interval);
			}


		function sluitLuikje()
			{
			sluitTimer2 = setTimeout(function()
				{
				$(var1).find('.luikje-deksel').animate(
					{
					marginTop: "0"
					}, 500, function()
					{
					openLuikje();
					}
				);
				}, 2000);
			}


	
		setTimeout(function()
			{
			$(var1).fadeIn( 'slow', openLuikje() );
			}, 250);



		$(var1).hover(function()
			{
			clearTimeout(sluitTimer2);
			clearTimeout(openTimer2);
			$(this).find('.luikje-deksel').animate({ marginTop: "-80px" }, 250);
			window.status = $(this).find('a').attr('href');
			}, function()
			{
			$(this).find('.luikje-deksel').animate({ marginTop: "0" }, 250);
			window.status = '';
			openLuikje();
			}
		).click(function()
			{
			if ( $(this).find('a').attr('target') == '')
				{
				window.location = $(this).find('a').attr('href');
				} else {
				window.open($(this).find('a').attr('href'));
				}
			}
		);


		}

luikje2('#luikje2', 2500);


	
});