$(document).ready(init);

function init(){

	
//--------------------------------------------------------// TARGET BLANK
	
	$(".external").attr("target","_blank");
	

//--------------------------------------------------------// LIGHTBOX

	$('.photos>a,.lightbox').lightBox();

//--------------------------------------------------------// HEADER

	$('#headerimg IMG').css({opacity: 0.0});
	$('#headerimg IMG:last').css({opacity:1});
	setInterval("headerSwitch()", 10000); 
	
//--------------------------------------------------------// SCROLL FUNCTIONALITY.	

	$('a[href*=#]').click(function() {
		if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') 
			&& location.hostname == this.hostname) {
			var $target = $(this.hash);
			
			$target = $target.length && $target || $('[name=' + this.hash.slice(1) +']');
			
			if ($target.length) {
			
				var targetOffset = $target.offset().top;
				
				$('html,body').animate({scrollTop: targetOffset}, 500);
				
				return false;
				
				// hier nog value in link aanpassen (swfadress?)
				
			}	
		}
    });
    
    
    $('.eventscont').masonry({
      itemSelector: '.event'
    });
    
    $("#closeie6warning").bind({
    click: function (){
    $("#ie6_banner").hide();
    $("#topBar").css('top','0px');
    }
    }); 
	
}

function headerSwitch(){
	var $active = $('#headerimg IMG.active');
	if($active.length == 0){
		$active = $('#headerimg IMG:last');
	}
	var $next = $active.next().length ? $active.next() : $('#headerimg IMG:first');
	
	$active.animate({opacity: 0}, 2000, 'easeInOutExpo', function(){$active.addClass('last-active');});
	
	$next.css({'opacity': '0.0', 'margin-top':'-100px'}).addClass('active').animate({opacity: 1, marginTop:0}, 2000, 'easeInOutExpo', function() {
		$active.removeClass('active last-active');
	}); 

	
}




