// standaard laden pagina
$(document).ready(function() {	
	// init fancybox voor impressie
	$("a[rel=impressie_groep]").fancybox({
		'padding'			: 0,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'              : 'image',
		'changeFade'        : 0
	});
});

// hover over div
$(".container_overzicht, .product_categorie").live('click', function() {
	var url = $(this).find("a").attr("href");
	window.location.href=url; return false;
}).live('mouseover', function() {
	$(this).toggleClass('hover');
}).live('mouseout', function() {
	$(this).toggleClass('hover');
});


// categorie-menu
function toggle_menu(o) {
	var target = $(o).attr('href');
	var rel = $(o).attr('rel');
	
	if ($("#"+rel).length>0) {
		$("#"+rel).slideDown();
		$(o).parent().addClass('actief');
	} else {
		window.location.href=target;
	}
}

// klapOpen per id
function klapOpen(id) {
	$("#"+id).slideDown(500);
}

// klapDicht per id
function klapDicht(id) {
	$("#"+id).slideUp(300);
}


// ##### specifieke website afhankelijke functies ##### //
// slide show voor Stal Vorselaars
function slideSwitch() {
	var $active = $('#slideshow IMG.active');
	if ( $active.length == 0 ) {
		$active = $('#slideshow IMG:last');
	}
	var $next =  $active.next().length ? $active.next() : $('#slideshow IMG:first');	
	// random
	// var $sibs  = $active.siblings();
	// var rndNum = Math.floor(Math.random() * $sibs.length );
	// var $next  = $( $sibs[ rndNum ] );

	$active.addClass('last-active');	
	$next.css({opacity: 0.0})
	.addClass('active')
	.animate({opacity: 1.0},1500, function() {
		$active.removeClass('active last-active');
	});
}	
$(function() {
	setInterval( "slideSwitch()",5000 );
});
