var richtxb=1,richtxrb=1,richtxlb=1;
var richtyb=1,richtyrb=1,richtylb=1;
var xb =500,xrb=800,xlb=0;
var yb = 200,yrb=300,ylb=300;
var dxb=1,dyb=1,dxrb=1,dyrb=1,dxlb=1,dylb=1;

var richtx=1,richtx2=-1,richtxr=1,richtxl=1;
var richty=1,richty2=-1,richtyr=1,richtyl=1;
var x =0,x2 =1000,xr=100,xl=1000;
var y = 0,y2 =200,yr=200,yl=0;
var dx=1,dy=1,dx2=1,dy2=1,dxr=1,dyr=1,dxl=1,dyl=1;
var r=255,g=0,b=0,f=0,del=0;

var einblend=0;
var zeit=new Date();
zeit=zeit.getTime();

function bg1()
{
//	alert(document.getElementById("inhalt").offsetHeight);
	document.body.style.backgroundColor="#000";
	var cv1 = document.getElementById('bg');
	if (cv1.getContext)
	{
		f++;
		if(f<=255)r=255,g++,b=0;
		if(f>255 && f<=510)r--,g=255,b=0;
		if(f>510 && f<=765)r=0,g--,b++;
		if(f>765 && f<=1020)r++,g=0,b=255;
		if(f>1020)r=255,g=0,b--;
		if(f==1275)f=0;
//Linie unten
		richtxb=Math.random()*4-2;
		richtyb=Math.random()*4-2;
		if(richtxb<-0.5 || dxb>7)dxb--;
		if(richtxb>0.5 || dxb<-7)dxb++;
		if(richtyb<-0.5 || dyb>7)dyb--;
		if(richtyb>0.5 || dyb<-7)dyb++;
		richtxrb=Math.random()*4-2;
		richtyrb=Math.random()*4-2;
		if(richtxrb<-0.5 || dxrb>4)dxrb--;
		if(richtxrb>0.5 || dxrb<-4)dxrb++;
		if(richtyrb<-0.5 || dyrb>4)dyrb--;
		if(richtyrb>0.5 || dyrb<-4)dyrb++;
		richtxlb=Math.random()*4-2;
		richtylb=Math.random()*4-2;
		if(richtxlb<-0.5 || dxlb>4)dxlb--;
		if(richtxlb>0.5 || dxlb<-4)dxlb++;
		if(richtylb<-0.5 || dylb>4)dylb--;
		if(richtylb>0.5 || dylb<-4)dylb++;

		if(xb<0)dxb=8;
		if(xb>fensterX)dxb=-8;
		if(yb<140)dyb=8;
		if(yb>fensterY)dyb=-8;
		if(xrb<0)dxrb=1;
		if(xrb>fensterX)dxrb=-1;
		if(yrb<140)dyrb=1;
		if(yrb>fensterY)dyrb=-1;
		if(xlb<0)dxlb=1;
		if(xlb>fensterX)dxlb=-1;
		if(ylb<140)dylb=1;
		if(ylb>fensterY)dylb=-1;
		xb=xb+dxb;
		yb=yb+dyb;
		xrb=xrb+dxrb;
		yrb=yrb+dyrb;
		xlb=xlb+dxlb;
		ylb=ylb+dylb;
//Linie unten Ende		
//Farbige Linie
		richtx=Math.random()*4-2;
		richty=Math.random()*4-2;
		if(richtx<-0.5 || dx>7)dx--;
		if(richtx>0.5 || dx<-8)dx++;
		if(richty<-0.5 || dy>7)dy--;
		if(richty>0.5 || dy<-7)dy++;
		richtx2=Math.random()*4-2;
		richty2=Math.random()*4-2;
		if(richtx2<-0.5 || dx2>7)dx2--;
		if(richtx2>0.5 || dx2<-8)dx2++;
		if(richty2<-0.5 || dy2>7)dy2--;
		if(richty2>0.5 || dy2<-7)dy2++;
		richtxr=Math.random()*4-2;
		richtyr=Math.random()*4-2;
		if(richtxr<-0.5 || dxr>4)dxr--;
		if(richtxr>0.5 || dxr<-4)dxr++;
		if(richtyr<-0.5 || dyr>4)dyr--;
		if(richtyr>0.5 || dyr<-4)dyr++;
		richtxl=Math.random()*4-2;
		richtyl=Math.random()*4-2;
		if(richtxl<-0.5 || dxl>4)dxl--;
		if(richtxl>0.5 || dxl<-4)dxl++;
		if(richtyl<-0.5 || dyl>4)dyl--;
		if(richtyl>0.5 || dyl<-4)dyl++;

		if(x<0)dx=8;
		if(x>fensterX)dx=-8;
		if(y<0)dy=8;
		if(y>220)dy=-8;
		if(x2<0)dx2=8;
		if(x2>fensterX)dx2=-8;
		if(y2<0)dy2=8;
		if(y2>220)dy2=-8;
		if(xr<0)dxr=1;
		if(xr>fensterX)dxr=-1;
		if(yr<0)dyr=1;
		if(yr>200)dyr=-1;
		if(xl<0)dxl=1;
		if(xl>fensterX)dxl=-1;
		if(yl<0)dyl=1;
		if(yl>200)dyl=-1;
		x=x+dx;
		y=y+dy;
		x2=x2+dx2;
		y2=y2+dy2;
		xr=xr+dxr;
		yr=yr+dyr;
		xl=xl+dxl;
		yl=yl+dyl;
//Farbige Linie Ende		
		cv1 = cv1.getContext('2d');
		cv1.beginPath();
		cv1.strokeStyle =  "rgba("+r+","+g+","+b+",0.2)";
		cv1.lineWidth = 2;
		cv1.lineCap = "round";
		cv1.lineJoin = "round";
		cv1.moveTo(xlb, ylb );
		cv1.quadraticCurveTo( xb, yb, xrb, yrb );
		cv1.stroke();
		
		cv1.beginPath();
		cv1.strokeStyle =  "rgba("+r+","+g+","+b+",0.2)";
		cv1.lineWidth = 2;
		cv1.lineCap = "round";
		cv1.lineJoin = "round";
		cv1.moveTo(xl, yl );
		cv1.bezierCurveTo( x, y,x2, y2, xr, yr );
		cv1.stroke();

		del++;
		if(del*0.05==parseInt(del*0.05))
		{
			if(browser)
			{
				cv1.fillStyle = "rgba(0,0,0,0.04)";
				cv1.fillRect( 0, 0, fensterX, fensterY );
			}
			else if(!browser&&del==200)
			{
				cv1.clearRect(0, 0, fensterX, fensterY);
				del=0;
			}
		}
//Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---
//Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---Uhr---
		if(browser)
		{
			var xp=fensterX-120;
			var yp=20;
			var jetzt=new Date();
			jetzt=jetzt.getTime();
	//alert(zeit+';'+jetzt);
			var diff=jetzt-zeit;
			jSek=sek+diff*0.001;
			jSek=jSek-(parseInt(jSek/60)*60);
			jMin=mi+parseInt(diff/60000+sek/60);
			jMin=jMin-(parseInt(jMin/60)*60);
			jH=parseInt(hr+diff/3600000);
			if(jH>=24)setTimeout(location.reload(),100);
	//		alert(zeit2);
			var s=(Math.PI/30*jSek)-0.5*Math.PI;
			var m=(Math.PI/30*jMin)-0.5*Math.PI;
			var h=(Math.PI/6*jH)-0.5*Math.PI;
			var hm=h+Math.PI/360*parseInt(jMin);
			if (einblend<20)einblend++;
		
			cv1.strokeStyle =  "rgba(150,150,150,0.1)";
			cv1.lineWidth = 2;
			cv1.beginPath();
			cv1.moveTo(119+xp, 1+yp);
			cv1.arc( 11+xp, 11+yp, 10, -0.5*Math.PI, Math.PI, true);
			cv1.arc( 11+xp, 89+yp, 10, Math.PI, 0.5*Math.PI, true);
			cv1.lineTo(119+xp, 99+yp);
			cv1.stroke();
					
			cv1.strokeStyle =  "rgba(150,150,150,0.1)";
			cv1.lineWidth = 3;
			cv1.fillStyle = "rgb(0,0,0)";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 48, 0, 2*Math.PI, false);
			cv1.closePath();	
			cv1.fill();
			cv1.stroke();
			cv1.lineWidth = 1;
					
			cv1.fillStyle = "rgba("+r+","+g+","+b+","+einblend/20+")";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 48, 0, 2*Math.PI, false);
			cv1.closePath();	
			cv1.fill();			
	
			cv1.fillStyle = "rgb(0,0,0)";
			cv1.font = 'bold 8px Verdana';
			cv1.fillText('1', 67+xp, 15+yp);
			cv1.fillText('2', 84+xp, 31+yp);
			cv1.fillText('3', 91+xp, 52+yp);
			cv1.fillText('4', 84+xp, 75+yp);
			cv1.fillText('5', 70+xp, 90+yp);
			cv1.fillText('6', 47+xp, 96+yp);
			cv1.fillText('7', 25+xp, 90+yp);
			cv1.fillText('8', 10+xp, 75+yp);
			cv1.fillText('9', 4+xp, 52+yp);
			cv1.fillText('10', 8+xp, 31+yp);
			cv1.fillText('11', 24+xp, 15+yp);
			cv1.fillText('12', 44+xp, 10+yp);

			cv1.fillStyle = "rgb(0,0,0)";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 35, 0, 2*Math.PI, true);			
			cv1.fill();			
		
			for(i=0;i<60;i++)
			{
				var mz=(Math.PI/30*i)-0.5*Math.PI;			
				cv1.strokeStyle =  "rgb(255,255,255)";
				cv1.beginPath();
				cv1.moveTo(50+xp, 50+yp);
				cv1.arc( 50+xp, 50+yp, 33, mz, mz, false);
				cv1.closePath();	
				cv1.stroke();
			}

			cv1.fillStyle = "rgb(0,0,0)";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 30, 0, 2*Math.PI, true);			
			cv1.fill();			
		
			for(i=0;i<24;i++)
			{
				var hz=(Math.PI/6*i)-0.5*Math.PI;			
				cv1.strokeStyle =  "rgb(255,255,255)";
				cv1.beginPath();
				cv1.moveTo(50+xp, 50+yp);
				cv1.arc( 50+xp, 50+yp, 35, hz, hz, false);
				cv1.closePath();	
				cv1.stroke();
			}
			cv1.fillStyle = "rgb(0,0,0)";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 30, 0, 2*Math.PI, true);			
			cv1.fill();
						
			cv1.fillStyle = "rgba("+r+","+g+","+b+",0.5)";
			cv1.beginPath();
			cv1.arc( 50+xp, 50+yp, 30, 0, 2*Math.PI, false);
			cv1.closePath();	
			cv1.fill();			
	
			cv1.clearRect(29+xp, 53+yp, 42, 15);
			cv1.clearRect(29+xp, 30+yp, 42, 15);		
			cv1.fillStyle = "rgb(0,255,255)";
			cv1.font = 'bold 8px Verdana';
			if(tag<10&&String(tag).substr(0,1)!="0")tag="0"+tag;
			if(mon<10&&String(mon).substr(0,1)!="0")mon="0"+mon;
			if(jMin<10)jMin="0"+jMin;
			if(jSek<10)jSek="0"+parseInt(jSek);
			else jSek=parseInt(jSek);
			cv1.fillText(tag+"."+mon+"."+jahr, 29+xp, 40+yp);
			cv1.fillText(jH+":"+jMin+":"+jSek, 29+xp, 63+yp);
		
			cv1.strokeStyle =  "rgba(255,0,0,1)";
			cv1.beginPath();
			cv1.moveTo(50+xp, 50+yp);
			cv1.arc( 50+xp, 50+yp, 30, s, s, false);
			cv1.closePath();	
			cv1.stroke();
		
			cv1.strokeStyle =  "rgba(255,255,150,0.7)";
			cv1.fillStyle =  "rgba(255,255,150,0.7)";
			cv1.beginPath();
			cv1.moveTo(50+xp, 50+yp);
			cv1.arc( 50+xp, 50+yp, 43, m-0.02, m+0.02, false);
			cv1.closePath();	
			cv1.stroke();
			cv1.fill();
	
			cv1.strokeStyle =  "rgba(100,100,255,1)";
			cv1.fillStyle =  "rgba(100,100,255,1)";
			cv1.beginPath();
			cv1.moveTo(50+xp, 50+yp);
			cv1.arc( 50+xp, 50+yp, 35, hm-0.04, hm+0.04, false);
			cv1.closePath();	
			cv1.stroke();
			cv1.fill();
		}
	}
}
