//---------------------------------------------------------------------------------------//
// 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] = ["","hotel09/hotel_bar_leute.jpg","hotel09/hotel_blumen.jpg","hotel09/hotel_blumen_panhans.jpg","hotel09/hotel_chefkoch.jpg","hotel09/hotel_hall.jpg","hotel09/hotel_honeymoon.jpg","hotel09/hotel_hotel.jpg","hotel09/hotel_innen.jpg","hotel09/hotel_musiker.jpg","hotel09/hotel_paar.jpg","hotel09/hotel_panhans_blumen.jpg","hotel09/hotel_restaurant.jpg","hotel09/hotel_tanzbar.jpg","hotel09/hotel_umgebung.jpg","hotel09/hotel_weinkeller.jpg","hotel09/hotel_wellness.jpg","hotel09/herbst1.jpg","hotel09/herbst3.jpg","hotel09/herbst5.jpg"];
images[1] = ["","kuli_gedeck.jpg","kuli_kamin.jpg","cafe1.jpg","kuli_speisen_wein.jpg","kuli_speisesaal.jpg","kuli_kamin1.jpg","kuli_tafel.jpg","kuli_vinothek_paar.jpg","hot_bar_new.jpg"];
images[2] = ["","wellness09/wellness_beauty.jpg","wellness09/wellness_beauty_frau.jpg","wellness09/wellness_drinks.jpg","wellness09/wellness_ergometer.jpg","wellness09/wellness_hantel.jpg","wellness09/wellness_massage.jpg","wellness09/wellness_medidation.jpg","wellness09/wellness_pool.jpg","wellness09/wellness_sauna.jpg","wellness09/wellness_sauna2.jpg","wellness09/wellness_stone_mann.jpg","wellness09/wellness_whirlpool.jpg","wellness09/wellness_yoga.jpg","wellness09/wellness_yoga2.jpg","wellness09/img_headbild_wellness.jpg","wellness09/img_headbild_wellness2.jpg"];
images[3] = ["","seminar_festsaal.jpg","seminar_geschaeftsfrau.jpg","seminar_raum_frau.jpg","seminar_seminar.jpg"];
images[4] = ["","winter_sonnenuntergang.jpg","winter_skigebiet.jpg","winter_ski_tag.jpg","winter_rodeln.jpg","winter_rodelbahn.jpg","winter_panorama.jpg","winter_paar.jpg","winter_natur.jpg","winter_kinder.jpg","winter_kutsche.jpg","winter_flutlicht.jpg"];
images[5] = ["","zimmer_bad_bett.jpg","zimmer_designer.jpg","zimmer_designer2.jpg","zimmer_doppelbett.jpg","zimmer_eremitage2.jpg","zimmer_honey_paar.jpg","zimmer_honeymoon.jpg","zimmer_honeymoon2.jpg","zimmer_kachelofen.jpg","zimmer_sonne.jpg","zimmer_toskana.jpg"];
images[6] = ["","hotelwinter09/hotel_bar_leute.jpg","hotelwinter09/hotel_festsaal.jpg","hotelwinter09/hotel_winter1.jpg","hotelwinter09/hotel_innen.jpg","hotelwinter09/hall.jpg","hotelwinter09/hall_stiege.jpg","hotelwinter09/hotel_weinkeller.jpg","hotelwinter09/hotel_winter2.jpg","hotelwinter09/hotel_honeymoon.jpg","hotelwinter09/hotel_musiker.jpg","hotelwinter09/hotel_winter.jpg","hotelwinter09/img_headbild_winter3.jpg","hotelwinter09/img_headbild_winter4.jpg","hotelwinter09/img_headbild_winter5.jpg","hotelwinter09/img_headbild_winter6.jpg"];
images[7] = ["","gloggnitz.jpg","graz.jpg","wien.jpg","rosegger.jpg","muerzzuschlag.jpg"];
images[8] = ["","theater09/event_raketen_bogen.jpg","theater09/events.jpg","theater09/chaoskellner.jpg","theater09/hotel_musiker.jpg","theater09/hotel_saal_rot.jpg","theater09/events2.jpg","theater09/klingingwaiters.jpg","theater09/opera.jpg","theater09/royaldinner.jpg","theater09/tartufo.jpg"];
images[9] = ["","incent_armbrust.jpg","incent_huette.jpg","incentive1.jpg","sem_incent1.jpg","inc.jpg","inc_walk.jpg"];
images[10] = ["","sommer_bahn.jpg","sommer_biker.jpg","sommer_biker_bruecke.jpg","sommer_drinks.jpg","sommer_drinks2.jpg","sommer_golf.jpg","sommer_gondel.jpg","sommer_kids.jpg","sommer_pan.jpg","sommer_pano.jpg","sommer_pano2.jpg","sommer_panorama.jpg","sommer_panorama3.jpg","sommer_sehenswuerd.jpg","sommer_sonnenterrasse.jpg","sommer_wander_pan.jpg"];
images[11] = ["","xmas09/headimage_xmas_buffet1.jpg","xmas09/headimage_xmas_buffet2.jpg","xmas09/headimage_xmas_feuerwerk.jpg","xmas09/headimage_xmas_kinder.jpg","xmas09/headimage_xmas_saal.jpg","xmas09/headimage_xmas_winter1.jpg","xmas09/headimage_xmas_winter2.jpg","xmas09/headimage_xmas_winter3.jpg","xmas09/headimage_xmas_zauberdamen.jpg","xmas09/headimage_xmas_restaurant.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); 
}