// Set slideShowSpeed (milliseconds) 
var slideShowSpeed1 = 5000; 
var slideShowSpeed2 = 5000; 
var slideShowSpeed3 = 5000; 

// Duration of crossfade (seconds) 
var crossFadeDuration = 3;  

//Specify the global path to the directory
var bigPath="images/slide/";

// 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]='hotel01.jpg'; pic[1]='hotel02.jpg'; pic[2]='hotel03.jpg'; pic[3]='hotel04.jpg'; pic[4]='hotel05.jpg'; pic[5]='hotel06.jpg'; pic[6]='hotel07.jpg'; pic[7]='hotel08.jpg'; pic[8]='hotel09.jpg'; pic[9]='hotel10.jpg'; pic[10]='hotel11.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'ambiente':	pic[0]='ambiente01.jpg'; pic[1]='ambiente02.jpg'; pic[2]='ambiente03.jpg'; pic[3]='ambiente04.jpg'; pic[4]='ambiente05.jpg'; pic[5]='ambiente06.jpg'; pic[6]='ambiente07.jpg'; pic[7]='ambiente08.jpg'; smallPath=""; break; //set the direcotry name and pictures
		case 'freizeit':	pic[0]='freizeit01.jpg'; pic[1]='freizeit02.jpg'; pic[2]='freizeit03.jpg'; pic[3]='freizeit04.jpg'; pic[4]='freizeit05.jpg'; pic[5]='freizeit06.jpg'; pic[6]='freizeit07.jpg'; pic[7]='freizeit08.jpg'; pic[8]='freizeit09.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); 
}