$(function() {	
	
	jQuery.httpbase = function( ){
		return $('base')[0].href;
	}
	
	$(document).ready(function(){
		$.setHeight();
	});
	
	$("#selecties .selectie").each( function() {
		$(this).find(".items").hide();
		$(this).hover( 
			function() {
				$(this).find(".items").show();
			}, 
			function() {
				$(this).find(".items").hide();
			}
		);
	});	

	$.Switch = function() {		
		$(".switch").each( function(i, e) {			    
		    
		    var $active = $(e).find('TABLE.active');
			
		    if ( $active.length == 0 ) $active = $(e).find('TABLE:last');
		
		    var $next =  $active.next().length ? $active.next() : $(e).find('TABLE:first');
				
		    $active.addClass('last-active');
		
		    $next.css({opacity: 0.0})
		        .addClass('active')
		        .animate({opacity: 1.0}, 1000, function() {
		            $active.removeClass('active last-active');
		    });	   		    
		});	
	}
    setInterval( "$.Switch()", 5000 ); 
	
	/* transparancy kleine afbeeldingen regelen */	
	$.setImagesTransparancy = function() {		
		$("#thumbs .thumb").each( function() {
			src1 = $(this).find('img')[0].src.replace('/75/','/270/').replace('/75/','/270/');
			src2 = $("#image img")[0].src;
			if (src1 != src2){
				$(this).animate({ 
	        	opacity: 0.4}, 200
	        	);
			}else{
				$(this).animate(
					{opacity: 1.0}, 
					200
	        	);
			}							
		});
	}
	$.setImagesTransparancy();
	
	/* kleine afbeeldingen vergroten naar large	*/
	$("#thumbs .thumb").click( function() {	
		$("#image img")[0].src = $(this).find('img')[0].src.replace('/90/','/300/').replace('/70/','/200/');
		$.setImagesTransparancy();
	});
	
	$("#image").click( function() {		
		src = $(this).find('img')[0].src.replace('/300/','/500/').replace('/200/','/500/');
		$.popup.show($(this).find('img').attr('alt'),'<div class="img"><table style="width: 500px; height: 500px;"><tr><td><img src="'+src+'" /></td></tr></table></div>');	
	});
});

jQuery.setHeight = function() {
	height = $('#kader').height() - $('#kader .bottom').height();
	$("#kader .right").css("height",height+"px");
}
