// Set slideShowSpeed (milliseconds) 
var slideShowSpeed1 = 12000; 
var slideShowSpeed2 = 7000; 
var slideShowSpeed3 = 10000; 

// Duration of crossfade (seconds) 
var crossFadeDuration = 3;  

//Specify the global path to the directory
var bigPath="";

// do not edit anything below this line 
var t1; 
var t2;
var t3;

var j1 = 0; 
var j2 = 0; 
var j3 = 0; 

var pic = new Array(); 
var smallPath="";

var preLoad1 = new Array(); 
var preLoad2 = new Array(); 
var preLoad3 = new Array(); 

var zuf = true;
var duplicate = false;
	
function init(category, zufall, slideNr) {
	zuf = zufall;

	switch (category) {
		case 'hotel':		pic[0]='images-slidehotel01.jpg'; pic[1]='images-slidehotel02.jpg'; pic[2]='images-slidehotel03.jpg'; pic[3]='images-slidehotel04.jpg'; pic[4]='images-slidehotel05.jpg'; pic[5]='images-slidehotel06.jpg'; pic[6]='images-slidehotel07.jpg'; pic[7]='images-slidehotel08.jpg'; pic[8]='images-slidehotel09.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'kulinarium':	pic[0]='images-slidekulinarium01.jpg'; pic[1]='images-slidekulinarium02.jpg'; pic[2]='images-slidekulinarium03.jpg'; pic[3]='images-slidekulinarium04.jpg'; pic[4]='images-slidekulinarium05.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'neutral':		pic[0]='images-slideneutral01.jpg'; pic[1]='images-slideneutral02.jpg'; pic[2]='images-slideneutral03.jpg'; pic[3]='images-slideneutral04.jpg'; pic[4]='images-slideneutral05.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'schlafen':	pic[0]='images-slideschlafen01.jpg'; pic[1]='images-slideschlafen02.jpg'; pic[2]='images-slideschlafen03.jpg'; pic[3]='images-slideschlafen04.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'wellness':	pic[0]='images-slidewellness01.jpg'; pic[1]='images-slidewellness02.jpg'; pic[2]='images-slidewellness03.jpg'; pic[3]='images-slidewellness04.jpg'; pic[4]='images-slidewellness05.jpg'; pic[5]='images-slidewellness06.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'winter':		pic[0]='images-slidewinter01.jpg'; pic[1]='images-slidewinter02.jpg'; pic[2]='images-slidewinter03.jpg'; pic[3]='images-slidewinter04.jpg'; pic[4]='images-slidewinter05.jpg'; pic[5]='images-slidewinter06.jpg'; pic[6]='images-slidewinter07.jpg'; pic[7]='images-slidewinter08.jpg'; pic[8]='images-slidewinter09.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'kinder':		pic[0]='images-slidekinder01.jpg'; pic[1]='images-slidekinder02.jpg'; pic[2]='images-slidekinder03.jpg'; pic[3]='images-slidekinder04.jpg'; smallPath=""; break; //set the direcotry name and pictures
	}
	
	p = pic.length;

	if (slideNr==1) { 	
		document.write("<img src='" + preLoad1[0] + "' hspace='0' vspace='0' name='Slide1'>");
	} 
	else if (slideNr==2) {
		document.write("<img src='" + preLoad2[0] + "' hspace='0' vspace='0' name='Slide2'>");
	} 
	else if (slideNr==3) {	
		document.write("<img src='" + preLoad3[0] + "' hspace='0' vspace='0' name='Slide3'>");
	} 
	
	random(slideNr);
}

function random(slideNr){
	z=0;
	var reihenfolge = new Array();
	
	while (z!=p){
		y=Math.floor(Math.random()*(p));
		for(i=0;i<reihenfolge.length;i++){	
			if (y==reihenfolge[i]){	
				duplicate=true;	
			}
		}
		if (duplicate==true){ 
			duplicate=false;
			continue;
		} 
		else if (duplicate==false) { 
			reihenfolge[z] = y; z+=1; 
		}
	}
	
	if(slideNr==1){
		if(zuf) {
			for(i = 0; i < p; i++){
				preLoad1[i] = new Image();
				preLoad1[i].src = bigPath + smallPath + pic[reihenfolge[i]];
			}
		} 
		else {
			for (i = 0; i < p; i++) { 
				preLoad1[i] = new Image(); 
				preLoad1[i].src = bigPath + smallPath + pic[i]; 
			} 
		}
	}
	
	else if(slideNr==2){
		if(zuf) {
			for(i = 0; i < p; i++){
				preLoad2[i] = new Image();
				preLoad2[i].src = bigPath + smallPath + pic[reihenfolge[i]];
			}
		} 
		else {
			for (i = 0; i < p; i++) { 
				preLoad2[i] = new Image(); 
				preLoad2[i].src = bigPath + smallPath + pic[i]; 
			} 
		}
	}
	
	else if(slideNr==3){
		if(zuf) {
			for(i = 0; i < p; i++){
				preLoad3[i] = new Image();
				preLoad3[i].src = bigPath + smallPath + pic[reihenfolge[i]];
			}
		} 
		else {
			for (i = 0; i < p; i++) { 
				preLoad3[i] = new Image(); 
				preLoad3[i].src = bigPath + smallPath + pic[i]; 
			} 
		}
	}
}

function runSlideShow1() { 
	if (document.all) { 
		document.images.Slide1.style.filter='blendTrans(duration='+crossFadeDuration+')'
		document.images.Slide1.filters.blendTrans.Apply(); 
	} 
	document.images.Slide1.src = preLoad1[j1].src; 
	if (document.all) { 
		document.images.Slide1.filters.blendTrans.Play(); 
	} 
	j1 = j1 + 1; 
	if (j1 > (preLoad1.length - 1)) {
		j1 = 0;
	}
	t1 = setTimeout('runSlideShow1()', slideShowSpeed1); 
} 

function runSlideShow2() { 
	if (document.all) { 
		document.images.Slide2.style.filter='blendTrans(duration='+crossFadeDuration+')'
		document.images.Slide2.filters.blendTrans.Apply(); 
	} 
	document.images.Slide2.src = preLoad2[j2].src; 
	if (document.all) { 
		document.images.Slide2.filters.blendTrans.Play(); 
	} 
	j2 = j2 + 1; 
	if (j2 > (preLoad2.length - 1)) {
		j2 = 0;
	}
	t2 = setTimeout('runSlideShow2()', slideShowSpeed2); 
} 

function runSlideShow3() { 
	if (document.all) { 
		document.images.Slide3.style.filter='blendTrans(duration='+crossFadeDuration+')'
		document.images.Slide3.filters.blendTrans.Apply(); 
	} 
	document.images.Slide3.src = preLoad3[j3].src; 
	if (document.all) { 
		document.images.Slide3.filters.blendTrans.Play(); 
	} 
	j3 = j3 + 1; 
	if (j3 > (preLoad3.length - 1)) {
		j3 = 0;
	}
	t3 = setTimeout('runSlideShow3()', slideShowSpeed3); 
}