//
//   Javascript für eine Digitaluhr
//
//      © Arndt Brünner, 20.April 2001
//____________________________________________________________________________________________
//
//   Parameter anpassen:

var watchbilderpath="scripts/Uhr/";             // Pfad der Displaybildchen relativ zur html-Datei
                                    // Falls nicht im gleichen Verzeichnis, dann z.B.: = "../bilder/";
var qwatch=1;                       // Vergrößerungsfaktor für Display (natürliche Zahlen verwenden)
var WatchRand=4;                   // Rand zwischen Display und Rahmen
var WatchSpacing=3;                 // Abstand zwischen Displayelementen
var WatchBorderWidth=1;             // Rahmenstärke
var WatchBorderStyle="box";      // Rahmenart, Optionen: void, above, below, box, border, hsides, vsides, lhs, rhs
var WatchRandfarbe="#330000";        // Farbe zwischen Displayelementen und Rahmen

//___________________________________________________________________________________________


wimg=new Array(12);
for (i=0;i<12;i++) wimg[i]=new Image;
wimg[0].src=watchbilderpath+"disp100.gif"
wimg[1].src=watchbilderpath+"disp101.gif"
wimg[2].src=watchbilderpath+"disp102.gif"
wimg[3].src=watchbilderpath+"disp103.gif"
wimg[4].src=watchbilderpath+"disp104.gif"
wimg[5].src=watchbilderpath+"disp105.gif"
wimg[6].src=watchbilderpath+"disp106.gif"
wimg[7].src=watchbilderpath+"disp107.gif"
wimg[8].src=watchbilderpath+"disp108.gif"
wimg[9].src=watchbilderpath+"disp109.gif"
wimg[10].src=watchbilderpath+"disp1000.gif"
wimg[11].src=watchbilderpath+"disp1001.gif"
var iwimg=-1;
var Watchaktiv=false;


function InsertWatch()
{
tsp='<img src="'+watchbilderpath+'disp1002.gif" width="'+WatchSpacing*qwatch+'" height="'+21*qwatch+'">';
document.write('<table border="'+WatchBorderWidth+'"  frame="'+WatchBorderStyle+'"  cellpadding="'+WatchRand+'"><tr><td bgcolor="'+WatchRandfarbe+'" >');
document.write('<img name="watchH10" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img name="watchH1" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img src="'+watchbilderpath+'disp1001.gif" width="'+6*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img name="watchM10" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img name="watchM1" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img src="'+watchbilderpath+'disp1001.gif" width="'+6*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img name="watchS10" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">'+tsp);
document.write('<img name="watchS1" src="'+watchbilderpath+'disp1000.gif" width="'+11*qwatch+'" height="'+21*qwatch+'">');
document.write('</td></tr></table>');
}

function InitWatch()
{
	for (i=0;i<document.images.length;i++)
	{if(document.images[i].src.indexOf("disp1000.gif")>-1) {iwimg=i;break;}}
	if (iwimg==-1) {alert('Uhr nicht gefunden.\nFehler unbekannter U(h)rsache');return;}
	Watchaktiv=true;
	window.setTimeout("WatchTimer()",1000);
	RefreshWatch();
}

function CancelWatch()
{
	Watchaktiv=false;
}

function RefreshWatch()
{
	TimeNowD=new Date();
	TimeNowS=new String(TimeNowD.toLocaleString());
	TimeNowD=null;
	TNA=TimeNowS.substr(TimeNowS.length-8,8);
	TNA=TNA.split(":")

	document.images[iwimg].src=wimg[Number(TNA[0].charAt(0))].src;
	document.images[iwimg+2].src=wimg[Number(TNA[0].charAt(1))].src;
	document.images[iwimg+6].src=wimg[Number(TNA[1].charAt(0))].src;
	document.images[iwimg+8].src=wimg[Number(TNA[1].charAt(1))].src;
	document.images[iwimg+12].src=wimg[Number(TNA[2].charAt(0))].src;
	document.images[iwimg+14].src=wimg[Number(TNA[2].charAt(1))].src;
}

function WatchTimer()
{
	if (Watchaktiv==false) return;
	RefreshWatch();
	setTimeout("WatchTimer()",1000);
}
