// vi forventer at brull_art_id er satt som peker til artikkel-id'en som inneholder bildene
// denne er noe ala #art346
// 
// alternativt kan artikkelen settes opp med en artikkelmal som gir den klassen "bilderull"

$(function() {

$brull 					= (window.brull_art_id != undefined) 		? $('#' + brull_art_id + ' ul') : $('.bilderull ul');
brull_delay 			= (window.brull_delay != undefined) 		? brull_delay 					: 6000;
brull_fade_speed 		= (window.brull_fade_speed != undefined) 	? brull_fade_speed 				: 800;

brull_length 			= $brull.children().length;
brull_last_idx 			= null;
brull_current_idx 		= 0;

$brull.children().hide()
brull_swap_loop();


});

function brull_swap_loop() {
	if (brull_last_idx != null) {
		$brull.children(':eq(' + brull_last_idx + ')').fadeOut(brull_fade_speed);
	}
	$brull.children(':eq(' + brull_current_idx + ')').fadeIn(brull_fade_speed);
	brull_last_idx = brull_current_idx;
	if (++brull_current_idx > brull_length - 1) brull_current_idx = 0;
	
	setTimeout(brull_swap_loop, brull_delay)
}
