var interval = 7000; // Zeit in ms zwischen Bildwechsel
var duration = 1500; // Dauer Fade in ms 

function arrayShuffle(){
	  var tmp, rand;
	  for(var i =0; i < this.length; i++){
	    rand = Math.floor(Math.random() * this.length);
	    tmp = this[i]; 
	    this[i] = this[rand]; 
	    this[rand] =tmp;
	  }
	}
	
	Array.prototype.shuffle =arrayShuffle;

Images.shuffle();

jQuery(function() {
	setInterval("changeImage()", interval);
	if (isset("Images")) {
		jQuery(Images).each(function(Key, Image) {
			if (Key == 0)  {
				jQuery("#headimg img:first").replaceWith("<img style='display:block' src='" + Image + "' />");
			}
			else {
				jQuery("#headimg").append("<img src='" + Image + "' style='display: none' />");
			}
		});
	}
});

var current = 1;
var pos = 0;

function changeImage() {
	if (isset("Images")) {
		if (current == Images.length)
			current = 0;
			
		jQuery('#headimg').children(":nth(" + current + ")").hide().css("z-index", pos).fadeIn(duration);
			
		pos++;
		current++;
	}
}

function isset(varname){    
	if(typeof( window[ varname ] ) != "undefined") return true;    else return false;
}

