//ALERTS
function melding(act,mes){
	$("body").append('<div id="melding"><div id="melding_text">'+mes+'</div><img id="melding_img" src="img/'+act+'.png" /></div>');
	$("#melding").fadeIn(500).delay(4000).fadeOut(1000, function() { $(this).remove(); });
}

//FOOTER MENU
function change(wich) {
	if (wich == 'coaching') {
		$('#pretwerkt').fadeOut(50, function() {
			$('#onlinecoaching').fadeIn(50);
		});
		$('#coaching').addClass('button_active').removeClass('button');
		$('#pret').addClass('button').removeClass('button_active');

	} else {
		$('#onlinecoaching').fadeOut(50, function() {
			$('#pretwerkt').fadeIn(50);
		});
		$('#pret').removeClass('button').addClass('button_active');
		$('#coaching').removeClass('button_active').addClass('button');

	}
}


//GOOGLE MAPS ZIPCODE
function doSomething(to) {
	saddr = document.getElementById('saddr').value;
		$.fancybox([
			{ 'href'    : 'http://maps.google.nl/?f=d&source=s_d&saddr=' + saddr + '&daddr=' + to }
		],{
			'width'             : '90%',
			'height'            : '90%',
			'transitionIn'      : 'none',
			'transitionOut'     : 'none',
			'type'              : 'iframe'
		});

		return false;
}

//CYCLE SHOW/HIDE BUTTON
function onAfter(curr, next, opts) {
	var index = opts.currSlide;
	$('.prev')[index == 0 ? 'hide' : 'show']();
	$('.next')[index == opts.slideCount - 1 ? 'hide' : 'show']();
}

$(function(){

	//NAVIGATION DROPDOWN
//	$('#lavaLampBasicImage li').hover(
//		function () { $('ul', this).fadeIn(500);	},
//		function () { $('ul', this).fadeOut(200); }
//	);

	//FOTOGALLERY
	$('#fotogallery').masonry({
		singleMode: true,
		columnWidth: 180,
		itemSelector: '.box'
	});

	//FANCYBOX PROJECTEN
	$("a.single_image").fancybox({
		titlePosition : 'inside',
		titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft">'+title+'</span></span>';
		}
	});

	//FANCYBOX CV
	$(".cvAnnemieke").click(function() {
		$.fancybox([
			{ 'href'    : 'img/Annemieke-Meerstra-1.jpg' },
			{ 'href'    : 'img/Annemieke-Meerstra-2.jpg' },
			{ 'href'    : 'img/Annemieke-Meerstra-3.jpg' }
		], {
			titlePosition : 'inside',
			'autoScale'   : true,
			titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft" style="margin-left:10px;"><a style="font-size:11px;" href="/uploadfiles/Levensloop Annemieke Meerstra.pdf"><b>Download de levensloop van Drs. Annemieke Meerstra- Van Putten</b></a></span></span>';
			}
		});
	});

	//FANCYBOX CV
	$(".cvInga").click(function() {
		$.fancybox([
			{ 'href'    : 'img/Inga-Freudenberg-1.jpg' },
			{ 'href'    : 'img/Inga-Freudenberg-2.jpg' },
			{ 'href'    : 'img/Inga-Freudenberg-3.jpg' }
		], {
			titlePosition : 'inside',
			'autoScale'   : true,
			titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft" style="margin-left:10px;"><a style="font-size:11px;" href="/uploadfiles/Levensloop Inga Freudenberg.pdf"><b>Download de levensloop van Drs. Inga Freudenberg- Van Gastel</b></a></span></span>';
			}
		});
	});

	//FANCYBOX CV
	$(".cvAnnelie").click(function() {
		$.fancybox([
			{ 'href'    : 'img/Levensloop-Annalie-van-Schaijck-1.jpg' },
			{ 'href'    : 'img/Levensloop-Annalie-van-Schaijck-2.jpg' },
			{ 'href'    : 'img/Levensloop-Annalie-van-Schaijck-3.jpg' },
			{ 'href'    : 'img/Levensloop-Annalie-van-Schaijck-4.jpg' }
		], {
			titlePosition : 'inside',
			'autoScale'   : true,
			titleFormat   : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-inside"><span class="floatRight" style="font-size: 10px; color: #333333;">' +  (currentIndex + 1) + ' / ' + currentArray.length + '</span><span class="flaotLeft" style="margin-left:10px;"><a style="font-size:11px;" href="/uploadfiles/Levensloop Annalie van Schaijck.pdf"><b>Download de levensloop van Annelie M.A. van Schaijck</b></a></span></span>';
			}
		});
	});

	$("#login").submit(function(e) {
		$.fancybox({
			href: 'ajaxloading.php',
			width: '80%',
			height: '80%',
			transitionIn: 'none',
			transitionOut: 'none',
			type: 'iframe',
			onComplete: function() {
				e.preventDefault();
				var name = $('#fancybox-frame').attr('name');
				$('#login').attr('target', name).submit();
			}
		});
	});

	//CUFON
	Cufon.replace('h1')('h2')('h3')('h4')('.button')('.button_active');
	Cufon.replace('#nav a', { hover : true })
	//Cufon.replace('#subnav a', { hover : true })


	//CYCLE ARTIKEL HOME
	$('#header_cycle').cycle({
		fx: 'fade',
		timeout: 4500,
		random: 1
	});

	// ITEMS MODULE CYCLE
	$('#itemCycle').cycle({
		fx: "scrollHorz",
		timeout: 0,
		startingSlide:   0,
		next:  '.next',
		prev:  '.prev',
		after:   onAfter,
		before: function(slide,next){
				$("#newsCycle").animate({
				'height' :  $(next).height()
				});
		}
	});

	//CYCLE NEWS ITEMS
	$('#newsCycle').cycle({
		fx: "scrollHorz",
		timeout: 0,
		startingSlide:   0,
		speed : 300,
		next:  '.next',
		prev:  '.prev',
		after:   onAfter,
		before: function(slide,next){
				$("#newsCycle").animate({
				'height' :  $(next).height()
				}, 300);
		}
	});


	$("#floorplanner").click(function(){return false;});

	//FANCYBOX GOOGLEMAPS
	$("a.readmore").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'     	: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

});

//$(window).load(function(){
	//NAVIGATION LAVALAMP
//	$('#lavaLampBasicImage').lavaLamp({
//		fx: "backout",
//		autoResize:true,
//		speed: 700
//	});
//});

