$(window).load(function(){
  
   $('.extraContent p a').each(function() {
   		var href = $(this).attr('href').toLowerCase(); 
		var ismovie = href.indexOf(".flv");
		if(ismovie != -1){
			$(this).attr('rel','shadowbox;height=288;width=384');
		}
   });
   $('img').not('.gallery_image, .advertentie, .edit_article img').each(function(){
      
	  var caption = $(this).attr('alt');
	  $(this).unwrap();
	  if(caption === undefined){
		if($page != ""){
      		$(this).wrap('<div class="image"><a href="'+$(this).attr('src')+'" rel="shadowbox"><\/a><\/div>');
		}
		else
		{
			if($(this).height() > $(this).width()){
				$(this).wrap('<div class="image highImage"><\/div>');
				$(this).width(288);
			}
			else
			{
				$(this).wrap('<div class="image"><\/div>');
			}
		}
	  }
	  else{
		if($page != ""){
	
      		$(this).wrap('<div class="image"><a href="'+$(this).attr('src')+'" title="'+caption+'" rel="shadowbox"><\/a><\/div>');
			$(this).parent().after('<p class="onderschrift">'+caption+'<\/p>');
		}
		else
		{
	   		if($(this).height() > $(this).width()){
				$(this).wrap('<div class="image highImage"><\/div>');
				$(this).width(288);
			}
			else
			{
				$(this).wrap('<div class="image"><\/div>');
			}
			$(this).after('<p class="onderschrift">'+caption+'<\/p>');
		}
		
	 }
	
	  
   });	
   if($page != ""){
    	$('.current h1').next('.image').each(function(){

			var image = $(this).find('img').not('.highImage');	
			if(image.length > 0){
				$(this).width(638);
				image.width(638);
				if (image.parent('a').length > 0){
				  image.unwrap();
				}
			}
		});
   }
	
  initialize(json);

  $container.masonry({
    itemSelector : '.item',
    columnWidth : 350,
	isAnimated : true,
	isFitWidth : true
  });  
  $('.item').has('.more').hover(
    function () {
      $(this).find('.more').addClass("hover");
	  //$(this).stop().animate({ backgroundColor: "#a7bf51"}, 800);
	  $(this).stop().animate({ backgroundColor: "#f5f0e4" }, "slow");
    },
    function () {
      $(this).find('.more').removeClass("hover");
	  //$(this).stop().animate({ backgroundColor: "#FFFFFF"}, 800);
	  $(this).stop().animate({ backgroundColor: "#EFE8DA" }, "slow");
    }
  );
  Shadowbox.init();
  $(document).ready(function(){

	/* Adding a colortip to any tag with a title attribute: */

	$('.gallery_image').colorTip({color:'yellow'});

});
});
$("img.gallery_image").show().lazyload({ 
    effect : "fadeIn"
});

