// JavaScript Document

$(function() {
	$('#navigation li.act ul, #navigation li.bread ul').appendTo('#headerbottom');
	
	$('.article h4 + p')
		.addClass('showmeinfo');
		//.hide()
		//.css({'background-color': '#cc0066', 'color': '#FFFFFF', 'padding': '5px'})
	
	//$('.article h4').css({'text-decoration': 'underline', 'cursor': 'pointer', 'padding': '20px 0'});
	
	//$('.article h4').after(' <button class="showme">Tonen</button>');
	/*$('.article h4').after(' <div class="showme">Tonen &dArr;</div>');
	$('.showme').click(function() {
		$(this).next().slideDown();
		$(this).slideUp();
	});*/
	
	$('<div class="showme">Tonen &dArr;</div>')
		.insertAfter('.article h4')
		.click(function() {
			var myPar = $(this).next();
			
			myPar.slideDown();
			
			/*if (myPar.has('.button')) {
				// Paragraph already has a button. Don't show another one
			} else {
			
				$('<br/><button class="button rosy impact">Meer Informatie &raquo;</button>')
					.appendTo(myPar)
					.hide()
					.click(function() {
						if (typeof _gaq != 'undefined') {
							_gaq.push(['_trackEvent', 'Articles h4', 'moreinfo', $(this).prevUntil('h3').andSelf().prev('h3').text()]);
						}
						document.location.href='/index.cfm/page:contact';
					})
					.delay(3000)
					.slideDown();
			}*/
			
			$('<br/><button class="button gray impact">Meer Informatie &raquo;</button>')
					.appendTo(myPar)
					.hide()
					.click(function() {
						if (typeof _gaq != 'undefined') {
							_gaq.push(['_trackEvent', 'Articles h4', 'moreinfo', $(this).prevUntil('h3').andSelf().prev('h3').text()]);
						}
						document.location.href='/index.cfm/page:contact';
					})
					.delay(3000)
					.slideDown();
				
			$(this).slideUp();
			
			
			//setTimeout(function() { myPar.append('Hello'); }, 2000);
			
			//alert($(this).prevUntil('h3').andSelf().prev('h3').text()); // http://stackoverflow.com/questions/2770588/jquery-prevuntil-include-start-selector-and-end-selecter
			
			if (typeof _gaq != 'undefined') {
				_gaq.push(['_trackEvent', 'Articles h4', 'showme', $(this).prevUntil('h3').andSelf().prev('h3').text()]);
			}
			
		});
	
	/*$('.article h4').hover(function() {
		$(this).next().slideToggle();
	});
	
	$('.article h4').click(function() {
		$(this)
			.unbind('mouseenter mouseleave')
			.css({'text-decoration': 'none', 'cursor': 'normal'});;	
		$(this).next().slideDown();
	});*/
});



/*********************
	PRELOAD IMAGES
\*/
	/* NAVIGATIE upside down */
	$('<img src="/sitescene/custom/images/nav_ud.png" />');
	$('<img src="/sitescene/custom/images/nav_act_ud.png" />');
/*\
	PRELOAD IMAGES
\********************/



/*********************
	STICKY NAVIGATION
\*/
function sticky_relocate() {
  var window_top = $(window).scrollTop();
  var div_top = $('#navtop').offset().top;
  if (window_top > div_top) {
	  if (!$('#navmiddle').hasClass('stick')) {
			//$('#navmiddle').animate({paddingTop: '+=20px'}, 500);
			//$('#navmiddle #navigation').animate({borderTopWidth: '+=20px'}, 500);
			$('#navmiddle').addClass('stick');
	  }
  }
  else {
	  if ($('#navmiddle').hasClass('stick')) {
    	$('#navmiddle').removeClass('stick');
		//$('#navmiddle').animate({paddingTop: '-=20px'}, 200);
	  }
  }
}



$(function() {
	var badBrowser = (/MSIE ((5\.5)|6|7)/.test(navigator.userAgent));
	if (!badBrowser) {
		$(window).scroll(sticky_relocate);
		sticky_relocate();
	}
});
/*\
	STICKY NAVIGATION
\********************/





