var bf_imageslideshow = {
	intervalduration: 5,
	
	
	intervalid: null,
	totalimgs: null,
	nextimg: null,
	activeimg: null,
	
	
	shownext: function() {
		//alert("next");
		var nextimg = bf_imageslideshow.activeimg + 1;
		if (nextimg >= bf_imageslideshow.totalimgs) nextimg = 0;
		bf_imageslideshow.nextimg = nextimg;
		bf_imageslideshow.displayimg();
	},
	
	displayimg: function() {
		if (this.activeimg !== null) {
			$("#bfslimg"+this.activeimg).fadeOut(1000);
		}
		$("#bfslimg"+this.nextimg).fadeIn(2000);
		$("#bfslimg"+this.nextimg).removeClass('invisible');	
		this.activeimg = this.nextimg;	
	}
	
}

$(document).ready(function () {  
	var count = 0;
	$('#header #slideshow img.bf_slideshowimg').each(				
  			function (i,v) {  			
  				$(this).attr('id', 'bfslimg'+count);
  				count++;
  			}
  	);
  	bf_imageslideshow.totalimgs = count;
  	bf_imageslideshow.nextimg = 0;
  	//alert("totalimgs = "+bf_imageslideshow.activeimg+" / "+bf_imageslideshow.totalimgs);
	//alert("document_ready; duartion="+bf_imageslideshow.intervalduration);
	bf_imageslideshow.displayimg();
	bf_imageslideshow.intervalid = setInterval(bf_imageslideshow.shownext, (bf_imageslideshow.intervalduration*1000));	
	//alert("intid="+bf_imageslideshow.intervalid);
});	
