//---------------------------------------------------------------------------------------//
// 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] = ["","hochzeit_altar.jpg","hochzeit_blume.jpg","hochzeit_mann_frau.jpg","hochzeit_nah.jpg","hochzeit_paar_laeuft.jpg","hochzeit_paar_nah.jpg","hochzeit_panorama.jpg","hochzeit_vorkirche.jpg","hochzeit_wiese.jpg"];
images[1] = ["","kuli_daemmerung.jpg","kuli_service.jpg","kuli_gala.jpg","kuli_restaurant.jpg","kuli_torten.jpg","kuli_paar_ofen.jpg","kuli_essen.jpg","kuli_oben.jpg","kuli_paar.jpg","kuli_essen1.jpg","kuli_terr_nacht.jpg","kuli_terrasse_sonne.jpg"];
images[2] = ["","vin_drei_lachen.jpg","vin_flasche.jpg","vin_mann_nah.jpg","vin_paar_aelter.jpg","vin_vinothek.jpg","vin_verkostung.jpg","vin_pano.jpg"];
images[3] = ["","fam_3nah.jpg","fam_bausteine.jpg","fam_essen.jpg","fam_lachen.jpg","fam_spielzimmer.jpg","fam_tafel.jpg","fam_vater.jpg"];
images[4] = ["","amb_bibl_tisch.jpg","amb_jagdhorn.jpg","amb_blaeser.jpg","amb_bar.jpg","amb_bibliothek_frau.jpg","amb_bibliothek_sofa.jpg","amb_schach.jpg","amb_bilder.jpg","amb_frau_nah.jpg","amb_kamin.jpg"];
images[5] = ["","hot_bar.jpg","hot_haus_nah_sommer.jpg","hotel_restau.jpg","fam_spielzimmer.jpg","wellness_frau_gesichtsmassa.jpg","kuli_terrasse_sonne.jpg","hot_bibliothek.jpg","hot_paar_lacht.jpg","hot_bibliothek2.jpg","hotel_bibliothek_frau.jpg","hot_pool.jpg","hot_pano.jpg"];
images[6] = ["","wellness_frau_gesicht.jpg","well_anwendung.jpg","well_fraunah.jpg","well_frautraube.jpg","well_mannkosmetik.jpg","well_massage2.jpg","wellness_frau_gesichtsmassa.jpg","wellness_gymnastik.jpg","wellness_licht.jpg","wellness_mann_gesicht.jpg","wellness_matten.jpg","wellness_medidation.jpg","wellness_ruheraum.jpg","hot_pool.jpg"];
images[7] = ["","nock_auerhahhn.jpg","nock_bank.jpg","nock_berg2.jpg","nock_murmeltier.jpg","nock_nockalmstrasse.jpg","nock_see.jpg","nock_see2.jpg","nock_seebaum.jpg","nock_seeblume.jpg","nock_strasse.jpg"];
images[8] = ["","sport_bike_alm.jpg","sport_bike_gipfel.jpg","sport_biker.jpg","sport_golf_paar.jpg","sport_nordic.jpg","so_wandern2.jpg","sport_reiten.jpg","sport_tennis.jpg","winter_skifahrer.jpg","sport_golfplatz.jpg","wi_schneeschuh2.jpg","therme_paar_wasser.jpg","winter_apre.jpg"];
images[9] = ["","therme_aussen.jpg","therme_frauenwasser.jpg","therme_paar.jpg","therme_paar_wasser.jpg","therme_sauna.jpg"];
images[10] = ["","winter_apre.jpg","winter_huette.jpg","winter_kinder.jpg","winter_kinderskiclub.jpg","winter_ski.jpg","winter_ski2.jpg","winter_skifahrer.jpg","winter_skifahrer2.jpg","winter_snwoboarder.jpg","winter_tiefschnee.jpg"];
images[11] = ["","winter_apre.jpg","winter_huette.jpg","wi_kinder.jpg","wi_frau.jpg","wi_haus.jpg","winter_skifahrer.jpg","wi_panorama.jpg","wi_schlitten.jpg","wi_schneeschuh.jpg","wi_schneeschuh2.jpg","wi_schneewechte.jpg","wi_sonne.jpg","wi_therme.jpg"];
images[12] = ["","zimmer.jpg","zimmer_aussicht.jpg","zimmer_kachelofen.jpg","zimmer_aussicht2.jpg","zimmer_paar.jpg","zimmer2.jpg","zimmer3.jpg","zimmer4.jpg","zimmer1.jpg","zimmer_bad2.jpg","zimmer_paar_hut.jpg"];
images[13] = ["","fruehling.jpg","nock_berg2.jpg","paar_herbst.jpg","therme_paar_wasser.jpg","therme_sauna.jpg","fam_kind_haengematte.jpg","so_zaun.jpg","so_wassertrinken.jpg","so_paar_holzstoss.jpg","so_wasserfall.jpg","so_frau_trinkt.jpg","so_wandern.jpg","so_frausteine.jpg","so_gras.jpg"];
images[14] = ["","natur_laerche.jpg","natur_heu.jpg","winter_huette.jpg","natur_laerche.jpg","winter_skifahrer.jpg","natur_fraugeniest.jpg","fruehling.jpg","nock_berg2.jpg","so_zaun.jpg","natur_berg.jpg","wi_schlitten.jpg","natur_bauernhof.jpg","so_wassertrinken.jpg","wi_panorama.jpg","so_paar_holzstoss.jpg","so_wasserfall.jpg","so_frau_trinkt.jpg","so_gras.jpg"];
images[15] = ["","sem_tanz.jpg","sem_trac.jpg","sem_bogen.jpg","sem_miss.jpg","sem_ski.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); 
}