var interval = 7000; // Zeit in ms zwischen Bildwechsel

var duration = 1500; // Dauer Fade in ms 





/////////////////// Funktion um ein Array zu mischen //////////////////////////////////

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;

	

	

/////////////////////// Das Array wird erstellt ////////////////////////

Images = new Array(

		"http://www.golfequipment.ch/data/media/img/header/header1.jpg",

		"http://www.golfequipment.ch/data/media/img/header/header2.jpg",

		"http://www.golfequipment.ch/data/media/img/header/header3.jpg",
		"http://www.golfequipment.ch/data/media/img/header/header4.jpg",
		"http://www.golfequipment.ch/data/media/img/header/header5.jpg",
		"http://www.golfequipment.ch/data/media/img/header/header6.jpg"

	);



/***************** und gemischt *********************/

Images.shuffle();





//////////////////// Hauptfunktion //////////////////////////////////////

jQuery(function() {

	setInterval("changeImage()", interval);

	if (isset("Images")) {

		jQuery(Images).each(function(Key, Image) {

			if (Key == 0)  {

				jQuery("#head_img img:first").replaceWith("<img style='position:absolute' src='" + Image + "' />");

			}

			else {

				jQuery("#head_img").append("<img src='" + Image + "' style='position:absolute;display: none' />");

			}

		});

	}

});



var current = 1;

var pos = 0;



function changeImage() {

	if (isset("Images")) {

		if (current == Images.length)

			current = 0;

			

		jQuery('#head_img').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;

}


