
// Newscroller

jQuery(document).ready(function(){
		
	$('#events').animateEventsCarousel();
	

	
	var backgroundImages = new Array("/wp-content/themes/jagerland/img/01.jpg","/wp-content/themes/jagerland/img/02.jpg","/wp-content/themes/jagerland/img/03.jpg","/wp-content/themes/jagerland/img/04.jpg","/wp-content/themes/jagerland/img/05.jpg");
	jQuery.preLoadImages("/wp-content/themes/jagerland/img/01.jpg","/wp-content/themes/jagerland/img/02.jpg","/wp-content/themes/jagerland/img/03.jpg","/wp-content/themes/jagerland/img/04.jpg","/wp-content/themes/jagerland/img/05.jpg");
	var backgroundImagesInterval = 60000;
	var loopInterval = 0;
	
	shuffle(backgroundImages);
	$('body').css("background", "black url('" + backgroundImages[1] + "') top center fixed");
	
	backgroundRotator = setInterval(function(){
			$('body').css("background", "black url('" + backgroundImages[loopInterval] + "') center top fixed");
			loopInterval = loopInterval+1;
			if(loopInterval == backgroundImages.length) loopInterval = 0;
		},backgroundImagesInterval);

	
});

shuffle = function(o){ //v1.0
	for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
	return o;
};

(function($) {
  var cache = [];
  // Arguments are image paths relative to the current page.
  $.preLoadImages = function() {
    var args_len = arguments.length;
    for (var i = args_len; i--;) {
      var cacheImage = document.createElement('img');
      cacheImage.src = arguments[i];
      cache.push(cacheImage);
    }
  }
})(jQuery)
