// JavaScript Document

/*
===========================================================
Script:   JavaScript Cross-Browser SlideShow Script
          With Cross-Fade Effect between Images
          Adjustable Timing and Unlimited Images
Function: Displays images continuously in a slideshow
          presentation format, with a fade effect on
          image transitions.
Browsers: All common browsers: NS3-6, IE 4-6
          Fade effect only in IE; others degrade gracefully
Author:   etLux
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this  header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully
===========================================================
*/

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 2000;

// Duration of crossfade (seconds)
var crossFadeDuration = 1;

// Specify the image files
var Pic = new Array() 
Pic[0] = 'history00.jpg';
Pic[1] = 'history01.jpg';
Pic[2] = 'history02.jpg';
Pic[3] = 'history03.jpg';
Pic[4] = 'history04.jpg';
Pic[5] = 'history05.jpg';
Pic[6] = 'history06.jpg';
Pic[7] = 'history07.jpg';
Pic[8] = 'history08.jpg';
Pic[9] = 'history09.jpg';
Pic[10] = 'history10.jpg';
Pic[11] = 'history11.jpg';
Pic[12] = 'history12.jpg';
Pic[13] = 'history13.jpg';
Pic[14] = 'history14.jpg';
Pic[15] = 'history15.jpg';
Pic[16] = 'history16.jpg';
Pic[17] = 'history17.jpg';
Pic[18] = 'history18.jpg';
Pic[19] = 'history19.jpg';
Pic[20] = 'history20.jpg';
Pic[21] = 'history21.jpg';
Pic[22] = 'history22.jpg';
Pic[23] = 'history23.jpg';

var t;
var stop = false;
var running = 3; 				// [ 0 | 1 | 2 ] slideshow steuern
var j = 0;						// aktuelle Stunde
var h = "";						// aktuelle Stunde als String
var d = "";						// aktueller Tag als String
var m = "";						// aktuelle Minute als String
var p = Pic.length;
var preLoad = new Array();
var Jetzt = new Date();
var Stunden = Jetzt.getHours();
	j = Stunden;
var imagetele = new Image();
var	imagelive = new Image();



function vorLaden(){
	Jetzt = new Date();
	d = String(Jetzt.getDate());
	h = String(Jetzt.getHours());
	m = String(Jetzt.getMinutes());
	nocache_stunde = d + h;
	nocache_minute = d + h + m;
    imagetele.src = "http://www.maennedorf.ch/webcam/tele/mdf_picconvert.php" + "?nocache=" + nocache_minute;  // Bildausschnitt generieren

	for (i = 0; i < p; i++){
	   preLoad[i] = new Image();
	   preLoad[i].src = "http://www.maennedorf.ch/webcam/history/" + Pic[i] + "?nocache=" + nocache_stunde;
   }
	imagetele.src = "http://www.maennedorf.ch/webcam/tele/mdf_ost_tele_640x320_converted.jpg" + "?nocache=" + nocache_minute;
};

function callRunSlideShow(){
	stop = false;
	switch(running) {
  	case 1: 
  		slideShowSpeed = 1000; 
  		running = 2; 
  		break;
  	case 2: 
  		slideShowSpeed = 2000; 
  		running = 1; 
  		break;
  	default: 
  	   	slideShowSpeed = 2000; 
  		running = 1; 
  		runSlideShow(); 
  		break;
 	};
};

// document.all gibt es nur bei IE
function runSlideShow(){
	if ( stop ) return;
	
	j = j + 1; 
	if (j > p-1) j=0;
	
	if (document.all){
		//document.images.SlideShow.style.filter="blendTrans(duration=1)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();  
	}
	document.images.SlideShow.src = preLoad[j].src;
	if (document.all) document.images.SlideShow.filters.blendTrans.Play();
	t = setTimeout('runSlideShow()', slideShowSpeed);
}

function stopSlideShow(){
	stop = true;
	running = 0;
};

function showImage(h){
	stopSlideShow();
	j = h;
   	document.images.SlideShow.src = preLoad[h].src;
};

function showImageLive(){
	stopSlideShow();
	Jetzt = new Date();
	d = String(Jetzt.getDate());
	h = String(Jetzt.getHours());
	m = String(Jetzt.getMinutes());
	nocache_stunde = d + h;
	nocache_minute = d + h + m;
   	imagelive.src  = "http://www.maennedorf.ch/webcam/mdf_ost_weit_std.jpg" + "?nocache=" + nocache_minute;
	document.images.SlideShow.src = imagelive.src ;
};

function showImageTele(){
	stopSlideShow();
	dummy = new Image();
	Jetzt = new Date();
	d = String(Jetzt.getDate());
	h = String(Jetzt.getHours());
	m = String(Jetzt.getMinutes());
	nocache_stunde = d + h;
	nocache_minute = d + h + m;
	// alert(nocache_minute);   
	// Bildausschnitt generieren
	dummy.src = "http://www.maennedorf.ch/webcam/tele/mdf_picconvert.php" + "?nocache=" + nocache_minute;  
   	imagetele.src = "http://www.maennedorf.ch/webcam/tele/mdf_ost_tele_640x320_converted.jpg" + "?nocache=" + nocache_minute ;
	document.images.SlideShow.src = imagetele.src ;
};

window.onload = vorLaden;
