﻿$(document).ready(function() {

	$('#cycleImages').before('<ul id="jQul">').cycle({
		fx:						'fade',
		speed:					800,
		timeout:				6000,
		pager:					'#jQul',
		pagerEvent:				'mouseover',
		pauseOnPagerHover:		true,
		allowPagerClickBubble:	true,
					
		pagerAnchorBuilder: function(idx, slide) {
			return '<li><a href="'+slide.alt+'" onFocus="this.blur()">'+slide.title +'</a></li>';
		}
	});



	$('#mainVisual').cycle({fx:'fade', speed:1200,timeout:6000 });


	if ($('#header').length) {
		$("#menu").css("background-image","url(/media/bgmenu.gif)");
	} else { 
		$("#menu").css("background-image","url(/media/bgmenutop.jpg)");
	}
  

	$('a.lightbox').colorbox();



	// CSS
	
	$("ul#mainnav ul li:has(ul)").find("a:first").append("&nbsp;&raquo;");
	
	$("div.row:last").css("border","solid 1px #d3cce1").css("margin-bottom","10px")



	//	aanbod rechterkolom
	$(".accordion").accordion( { autoHeight: false, clearStyle: false, active: 0 });
	jScroll( 'aanbodScroller' );
	jScroll( 'openhuisScroller', Array("ohp_up", "ohp_down") );



	//	CLICKABLE DIV
	$("div.clickable").click( function(event) {
		event.preventDefault();
		var url = $(this).attr("url");
		
		if ( url.substr(0,4) == "http" )
		{
			window.open( $(this).attr('target','_blank').attr("url") );
		} else {
			window.location = $(this).attr("url");
		}
	});

	
	


/* COOKIE HEADER ON-OFF */
/*
	if ($.cookie('mvmheader')) {
		$('#header').css('display','none');
		$('#menu').css('background-image','url(/media/bgmenutop.jpg)');
		$('#menu .btnHeader').css('display','block');
	} else 	{
		$('#header').css('display','block');
		$('#menu').css('background-image','url(/media/bgmenu.gif)');
		$('#menu .btnHeader').css('display','none');
	};
*/
/* CLICK HEADER ON-OFF */
/*
	$('#menu .btnHeader').click(function() { 
		$('#header').css('display','block');
		$('#menu').css('background-image','url(/media/bgmenu.gif)');
		$('#menu .btnHeader').css('display','none');
		$.cookie("mvmheader", null); 
	});
	$('#header .btnHeader').click(function() {
			$('#header').css('display','none');
			$('#menu').css('background-image','url(/media/bgmenutop.jpg)');
			$('#menu .btnHeader').css('display','block');
			$.cookie("mvmheader", "show", { expires: 1 });
	});
*/	
	
	
/* CLEAR INPUT ON FOCUS */

	var clearMePrevious = "";
	
	// clear input on focus
	$('.clearMeFocus').focus(function()	{
		if($(this).val() == $(this).attr('title')) {
			clearMePrevious = $(this).val();
			$(this).val("");
		}
	});	
	
	// if field is empty afterward, add text again
	$('.clearMeFocus').blur(function() {
		if($(this).val() == "") {
			$(this).val(clearMePrevious);
		}
	});




/* MOUSEOVER BOX */

	$(".box").hover(function() {
		$(this).stop().animate({ backgroundColor: "#eaf3d8" }, 100);
		$(".verdertxt",this).animate({ color:'#00774c' }, 100);
	},function() {
		$(this).animate({ backgroundColor: "white" }, 300);
		$(".verdertxt",this).animate({ color:'#462682' }, 300);
	});

/* MOUSEOVER AANBODPANEL HP_HUIS */

	$(".hp_huis").hover(function() {
		$(this).stop().animate({ backgroundColor: "#ece9f2" }, 200);
	},function() {
		$(this).animate({ backgroundColor: "white" }, 400);
	});


/* GALLERY ROW */

	$(".row").hover(function() {
		$(this).stop().animate({ backgroundColor: "#eaf3d8" }, 100);
	},function() {
		$(this).animate({ backgroundColor: "white" }, 300);
	});


/* GALLERY GALBOX */

	$(".galbox").hover(function() {
		$(this).stop().animate({ backgroundColor: "#eaf3d8" }, 100);
	},function() {
		$(this).animate({ backgroundColor: "white" }, 300);
	});
	
	$('div.galbox:nth-child(3n+1)').css("margin-right","0");
	$('div.galbox:nth-child(3n+1)').after("<br clear='all' />");
	
	if ($('.div.galbox img').length > 1) {
		$(".adres").css("margin-top","20px");
	}



  

});
