$(document).ready(function() {
				var nuwelMainbuttons = function(){
					function nuwellinks() {
					  $("ul#buttons li a").each(function(i) {
						  var a = $(this);
						  var title = a.html();
						  var w = a.outerHeight();
						  a.append("<span class='mask' style='height: 0; display: none;'><em>"+title+"</em></span>");
						  var span = a.find("span");
						  a.hover(function(){
							  span.stop(true,true);
							  span.show().animate({
								height: w+'px'
							  }, 200);
						  }, function() {
							  span.animate({
								height: '0px'
							  }, 400, function(){ 
								  span.hide();          
							  });
						  });
					  });    	
					}
						nuwellinks();
					return {
					   nuwellinks:nuwellinks
					}
				}();
				var nuwelNieuwslinks = function(){
					function nieuwslinks() {
					  $(".nieuwskorttitel a").each(function(i) {
						  var a = $(this);
						  var title = a.html();
						  var w = a.outerWidth();
						  a.append("<span class='mask' style='width: 0; display: none;'>"+title+"</span>");
						  var span = a.find("span");
						  a.hover(function(){
							  span.stop(true,true);
							  span.show().animate({
								width: w+'px'
							  }, 200);
						  }, function() {
							  span.animate({
								width: '0px'
							  }, 400, function(){ 
								  span.hide();          
							  });
						  });
					  });    	
					}
						nieuwslinks();
					return {
					   nieuwslinks:nieuwslinks
					}
				}();
				$('ul#buttons li:last').addClass('nobreak');				
				$('#facebook a').fadeTo(50, 0);
				$('#facebook').hover(function(){
					$('#facebook a').fadeTo(650, 1.0); 
					},function(){
						$('#facebook a').fadeTo(500, 0);
				});
				 $.fn.fadeSliderToggle = function(settings) {
					 settings = $.extend({
						speed:500,
						easing : "swing"
					}, settings)
					
					caller = this
					if($(caller).css("display") == "none"){
						$(caller).animate({
							opacity: 1,
							height: 'toggle'
						}, settings.speed, settings.easing);
					}else{
						$(caller).animate({
							opacity: 0,
							height: 'toggle'
						}, settings.speed, settings.easing);
					}
				}; 				
				$('.brandimage').click(function(){
					$(this).next().fadeSliderToggle(300)
						return false;
				});
				$('#toongmap').click(function(){
					$(this).toggleClass('up'),
					$('#middenbalk').toggleClass('').fadeSliderToggle(300)
						return false;
				});
				$('.showform').click(function(){
					$('#formwrapper').fadeSliderToggle(300)
						return false;
				});
				
				$('.brandon').fadeTo(50, 0);
				$('ul#brandlist > li').hover(function(){
					$(this).find('.brandon').fadeTo(300, 1.0); 
					},function(){
						$(this).find('.brandon').fadeTo(300, 0);
				});
				$('#brandlist').nuwelBrands();
				$('#nieuwslist').nuwelBrands();
				$.fn.screenshotPreview = function(){	
						xOffset = -20;
						yOffset = 10;
				
					$("a.meerinfo").hover(function(e){
						this.t = this.title;
						this.title = "";	
						var c = (this.t != "") ? "<br/>" + this.t : "";
						$("body").append("<p id='meerinfo'><img src='"+ this.rel +"' alt='meer info' />"+ c +"</p>");								 
						$("#meerinfo")
							.css("top",(e.pageY - xOffset) + "px")
							.css("left",(e.pageX + yOffset) + "px")
							.fadeIn("fast");						
					},
					function(){
						this.title = this.t;	
						$("#meerinfo").remove();
					});	
					$("a.meerinfo").mousemove(function(e){
						$("#meerinfo")
							.css("top",(e.pageY - xOffset) + "px")
							.css("left",(e.pageX + yOffset) + "px");
					});			
				};
				$.fn.screenshotPreview();
				$('ul#nieuwslist li').hover(function(){
					$(this).find('.nieuwszoom').fadeTo(200, 1.0); 
					},function(){
						$('.nieuwszoom').fadeTo(100, 0);
				});
				$('#nieuwsbriefspot').hover(function(){
					$('#nieuwsbriefspot').fadeTo(300, 0.5); 
					},function(){
						$('#nieuwsbriefspot').fadeTo(300, 1.0);
				});
				$('ul#filerlijst li:last').addClass('noborder')
				$("a[rel='nieuwsimg']").nuwelPopup({
					opacity: 0.6,
					maxWidth: "80%",
					maxHeight: "80%"
					});
				$('.privacy').nuwelPopup({width:"500px", inline:true, href:"#privacy-statement", opacity: 0.6});
				$('.disclaim').nuwelPopup({width:"500px", inline:true, href:"#disclaimer", opacity: 0.6});	
				$('.nbrief').nuwelPopup({width:"500px", height:"310px", iframe:true, opacity: 0.6});	
				$(function()
				{
					$('#detailomschrijving').nuScroll();
					$('#reinit-link').bind(
						'click',
						function()
						{
							$('#detailomschrijving').nuScroll();
							return false;
						}
					);
				});
				$(function()
				{
					$('#detailthumbs').nuScroll();
					$('#reinit-link').bind(
						'click',
						function()
						{
							$('#detailthumbs').nuScroll();
							return false;
						}
					);
				});
				
				$('img.nieuwsfoto').hide();			
				$('img.nieuwsfoto').delay(300).fadeIn(200);		
				function fadeItem() {
					$('.nieuwskortafbeelding img:hidden:first').delay(50).fadeIn(200, fadeItem);
				}
				
				$(fadeItem);
				$('.nieuwskortafbeelding img').hide();	
				$('#share li a').delay(200).fadeTo(300, 0);
				$('#share li').hover(function(){
					$(this).find('a').fadeTo(350, 1.0); 
					},function(){
						$(this).find('a').fadeTo(300, 0);
				});
//				$(".fotothumb").click(function(){
//					var main_href = $(this).attr('href');
//					change_image(main_href );
//				});
//				
//				function change_image(main_href)
//				{
//					$(".nieuwsfoto2").attr("src", main_href).hide().fadeIn(200, function()
//				{
//					  $(".nieuwsfoto").attr("src", $(".nieuwsfoto2").attr("src"));
//					  $(".nieuwsfoto2").hide();
//				});
//					$(".nieuwsfoto").show().fadeOut(300, function(){$(this).show();});
//				}
				$(function() {
				  $('.detailafb img').load(function() {
					$(this).fadeIn(); 
				  });
				  $("#detailthumbs a").click(function() {
					var image = $(this).attr("href");
					$('.detailafb img').stop().hide().attr('src', image);
					return false;
				  });
				});
				$(function(){
					$('.tekst').columnize({
						columns: 2,
						lastNeverTallest: true
					});
				});
				$('#detailthumbs ul li').hover(function(){
					$(this).find('.thumboff').fadeTo(300, 0); 
					},function(){
						$('.thumboff').fadeTo(150, 1.0);
				});
				$('#taalswitch a').click(function() {
					$(this).toggleClass('taalactive');
					$('#taalnl').fadeSliderToggle();
						return false;			
				});
				$('#taalswitch a').hover(function(){
					$(this).fadeTo(200, 0.5); 
					},function(){
						$('#taalswitch a').fadeTo(200, 1.0);
				});
												
});

