//---------------------------------------------------------------------------------------//
// name:       js-slideShow                                                                                  //
// version:   2.1                                                                                                //
// made by:  melko                                                                                             //
// email: melko@gmx.at                                                                                      //
//                                                                                                                    //
// info:                                                                                                             //
//         this script enables you to use so many slideShows as you want to                //
//         have on your page without any extra-programming.                                    //
//         Only you must do is to set the paths and image-names!                               //
//                                                                                                                     //
// features:                                                                                                       //
//              - so many slideShows as you want to have                                             //
//              - easy implementation in the sourcecode                                              //
//              - each slideShow has its own slideShowSpeed and crossFadeDuration      //
//              - choose between random or in the order                                              //
//              - set a fix picture at the start of a slideShow                                       //
//												         //
// important:										         //
//	       - The slideShow MUST be initialized with the same number as the index    //
//                of the images it is containing!! example: images[1] = slideShowNr 1        //
//             - You should never have more slideShows than images defined!!                 //
//----------------------------------------------------------------------------------------//

//Specify the global path to the directory
var bigPath="../slides/";

// pic arrays! FIRST POSITION IN THE ARRAY is the SMALLPATH to the pictures!
// if you no path want, then set "" !! Images starts allways with 0 !
var images = new Array();
// The FIRST slideShow with slideNr = 0 and so on... 

// SLIDEs
images[0] = ["","zimmer_panosuite.jpg","winter_daemmerung2.jpg","bett_paar.jpg","tv_paar.jpg","winter_sonnenuntergang.jpg","pano_bad.jpg","winter_eisloch.jpg"];
images[1] = ["","artstetten.jpg","duernstein.jpg","poeggstein.jpg","rosenburg.jpg","schallaburg.jpg"];
images[2] = ["","wellness_hamam.jpg","massage.jpg","pano_bad.jpg","wellness_pool.jpg","pool_sekt.jpg","wellness_fitnessraum.jpg","wellness_solarium.jpg","wellness_sauna.jpg","wellness_sauna2.jpg","wellness_pool_nah.jpg"];
images[3] = ["","seminar_raum2.jpg","seminar_frei.jpg","seminar_seminarraum.jpg","seminar_raum5.jpg"];
images[4] = ["","basilika.jpg","feststpielhaus.jpg","melk.jpg","natur_pano.jpg","stpoelten.jpg","grein.jpg","poechlarn.jpg","wien.jpg"];
images[5] = ["","feiern.jpg","feier.jpg","feiern_saal2.jpg","ballons.jpg","feiern_saal3.jpg","feiern_rolle.jpg","feiern_tisch.jpg","rest_saal.jpg","rest_saal2.jpg"];
images[6] = ["","golf_driving.jpg","golf_gesamt.jpg","golf_pano.jpg","golf_platz1.jpg","golfplatz_luft.jpg"];
images[7] = ["","suess1.jpg","don_paar.jpg","haupt_3er.jpg","rest_donauterrasse.jpg","rest_buffet2.jpg","suess_marillen.jpg","haupt.jpg"];
images[8] = ["","rest_smaragd2.jpg","sm1.jpg","smaragd_paar.jpg","sm2.jpg","haupt1.jpg","haupt_krebs.jpg"];
images[9] = ["","kleines_rest.jpg","kl_paar.jpg","suess.jpg","haupt_schwammerl.jpg","rest_buffet2.jpg","haupt3.jpg","haupt_nudeln.jpg"];
images[10] = ["","dachterrasse.jpg","tischgedeck.jpg","pool-outdoor.jpg","gastgarten2.jpg","pano-nacht.jpg","pool-indoor.jpg","gastgarten.jpg","pano3.jpg","speisen.jpg","rest_smaragd.jpg","paar_ufer.jpg"];
images[11] = ["","sky.jpg","sky_titel.jpg","lounge.jpg","sky_wein.jpg","skylounge_2.jpg","natur_sonnenuntergang.jpg","paar_skylounge.jpg"];
images[12] = ["","bar_keller2.jpg","bar_keller3.jpg","bar_keller.jpg","vino_glaeser.jpg"];
images[13] = ["","zimmer_zi1.jpg","paarbett.jpg","verwoehn.jpg","zimmer_basic.jpg","zimmer_kaiser.jpg","zimmer_standard.jpg","zimmer_2er.jpg","zimmer_honey.jpg","zimmer_wein.jpg","zimmer_panosuite.jpg","zimmer.jpg","zimmer_honey_fernseher.jpg"];
images[14] = ["","pano_bad.jpg","pano1.jpg","rest_smaragd.jpg","pano2.jpg","ppp.jpg","rest_saal2.jpg","gg4.jpg","gg3.jpg","rest_tisch.jpg"];
images[15] = ["","kaiserhof_nah.jpg","ssgg.jpg","seminar_raum3.jpg","seminar_raum4.jpg","seminar_seminarraum.jpg","kaiserhof_bar.jpg","kaiserhof_recept.jpg"];
images[16] = ["","sport_rad.jpg","sport_laufen.jpg","sp_donauradweg.jpg","pool.jpg","mountainbike.jpg","golf_platz.jpg"];
images[17] = ["","winter_loipe.jpg","winter_daemmerung2.jpg","winter_wandern.jpg","winter_reiter.jpg","wnter_reiter_nah.jpg","winter_eisloch.jpg","winter_strasse.jpg","winter_langlauefer.jpg"];
images[18] = ["","wachau_weingaerten.jpg","rad_weg.jpg","natur_weingartenherbst.jpg","natur_wachau.jpg","natur_trauben.jpg","wachau_sonnenuntergang.jpg","natur_herbst.jpg","natur_pano.jpg","natur_pano_fluss.jpg","rad_weg1.jpg"];
images[19] = ["","wald1.jpg","wald3.jpg","wald4.jpg","wald5.jpg","wald6.jpg","wald2.jpg","rosenburg.jpg","mohnfeld.jpg"];
images[20] = ["","bl1.jpg","bl3.jpg","bl4.jpg","bl5.jpg","bl7.jpg","bl6.jpg","mohnfeld.jpg"];
images[21] = ["","dachterrasse.jpg","tischgedeck.jpg","pool-outdoor.jpg","gastgarten2.jpg","pano-nacht.jpg","pool-indoor.jpg","gastgarten.jpg","pano3.jpg","zimmer_panosuite.jpg","tv_paar.jpg","natur_sonnenuntergang.jpg","bett_paar.jpg","pano_bad.jpg","maria_taferl.jpg","natur_wachau.jpg","rad_weg.jpg"];
images[22] = ["","familie_schachner.jpg","fam1.jpg","fam2.jpg"];
images[23] = ["","gl2.jpg","gl1.jpg","gl3.jpg","gl5.jpg"];
images[24] = ["","zimmer_panosuite.jpg","bl7.jpg","gg1.jpg","tv_paar.jpg","natur_sonnenuntergang.jpg","bl3.jpg","bett_paar.jpg","bl4.jpg","maria_taferl.jpg","mohnfeld.jpg","natur_pano.jpg","rad_weg.jpg"];


// do not edit anything below this line 
//-------------------------------------------------------------------------------------//
var slideSpeed = new Array();
var crossFade = new Array();  
var index = new Array(); 
var pic = new Array(); 
var smallPath = new Array();
var preLoad = new Array(); 

// Initialize the slideShow... 
// @param slideNr - The slideNr of the slideShow... Every slide shoud start with 1
// @param slideShowSpeed - The speed of the slideShow in ms! (1sec. = 1000ms)
// @param crossFadeDuration - The duration of the crossFade (changing one picture through an other) values: 1, 2, 3,...
// @param random - Indicates if the slideShow shoud choose the pictures randomly or in the order. values; true, false
// @param fixStartPic - Indicates if the slideShow, with random = true, should have a fixStart picture at refreshing the page. Its the first image in the array. values: true, false
function init(slideNr, slideShowSpeed, crossFadeDuration, random, fixStartPic) {

	index[slideNr] = 0;
	slideSpeed[slideNr] = slideShowSpeed;
	crossFade[slideNr] = crossFadeDuration;
	smallPath[slideNr] = images[slideNr][0];
	pic[slideNr] = new Array();
	
	for(var i = 0; i < images[slideNr].length-1; i++){
		pic[slideNr][i] = images[slideNr][i+1];
	}
	
	prepareSlide(slideNr, fixStartPic, random, pic[slideNr].length);
}

// prepareSlide the slideShow, set the pictures-order, fixStartPic and load it into PreLoad-Object
// @param slideNr - The slideNr of the slideShow... Every slide shoud start with 1
// @param fixStartPic - Indicates if the slideShow, with random = true, should have a fixStart picture at refreshing the page. Its the first image in the array. values: true, false 
// @param random - Indicates if the slideShow shoud choose the pictures randomly or in the order. values; true, false
// @param picLength - It's the length of the pic-Array of this slideShow
function prepareSlide(slideNr, fixStartPic, random, picLength){
	
	var duplicate = false;
	var reihenfolge = new Array();
	var z=0;
	
	if(fixStartPic){
		reihenfolge[0] = 0;
		z=1;
	}
	
	while (z != picLength){
		y=Math.floor(Math.random()*(picLength));
		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; 
			
		}
	}
	preLoad[slideNr] = new Array();
	
	if(random) {
		for(i = 0; i < picLength; i++){
			preLoad[slideNr][i] = new Image();
			preLoad[slideNr][i].src = bigPath + smallPath[slideNr] + pic[slideNr][reihenfolge[i]];	
		}
	} 
	else {
		for (i = 0; i < picLength; i++) { 
			preLoad[slideNr][i] = new Image(); 
			preLoad[slideNr][i].src = bigPath + smallPath[slideNr] + pic[slideNr][i]; 
		} 
	}
}

// Run the slideShow with the slideNr that indicates the special slide. It makes a pause of "slideShowSpeed" before starting it...
// @param slideNr - The slideNr of the slideShow... Every slide shoud start with 1
function runSlideShow(slideNr){
	setTimeout('runSlide('+slideNr+')', slideSpeed[slideNr]); 
}

// Run the slideShow with the slideNr that indicates the special slide
// @param slideNr - The slideNr of the slideShow... Every slide shoud start with 1
function runSlide(slideNr) { 
	var element = document.getElementById("slide"+slideNr);
	
	if (document.all) { 
		element.style.filter='blendTrans(duration='+crossFade[slideNr]+')'
		element.filters.blendTrans.Apply(); 
	} 
	element.src = preLoad[slideNr][index[slideNr]].src; 
	
	if (document.all) { 
		element.filters.blendTrans.Play(); 
	} 
	index[slideNr] += 1; 
	
	if (index[slideNr] > (preLoad[slideNr].length - 1)) {
		index[slideNr] = 0;
	}
	runSlideShow(slideNr); 
}