var aktiv;
var aktivX;
var aktivY;
var aktivZ;
var run;
var mov;
var t=0;
var tb=0;
var tc=0;

function rand(){
	x1 = Math.round(Math.random()*10);
	y1 = Math.round(Math.random()*10);
	if(x1>5){this.x=1;}else{this.x=-1;}
	if(y1>5){this.y=-1;}else{this.y=1;}
}

function moving(lname,x,y,intVar){
	if(document.layers)	{
		this.aktiv = window.setInterval("document.layers['"+lname+"'].moveBy("+x+","+y+");tracking('"+lname+"',"+x+","+y+",'"+intVar+"')",100);
	}else if (document.all)	{
		this.aktiv = window.setInterval("tracking('"+lname+"',0,0,'"+intVar+"')",100);
	}else if (document.getElementById) {
		this.aktiv = window.setInterval("tracking('"+lname+"',0,0,'"+intVar+"')",100);
	} 
}

function pos(lname){
	if(document.all){
		this.l = (document.all[lname].style.left);
		this.t = (document.all[lname].style.top);
	}else{
		this.l = (document.getElementById(""+lname+"").style.left);
		this.t = (document.getElementById(""+lname+"").style.top);
	
	}
}

function tracking(lname,x,y,intVar){
	if(document.layers)	{
		lx=(document.layers[lname].left);
		ly=(document.layers[lname].top);
		if(lx>680 && t!=1){		t=1;	eval('window.clearInterval('+intVar+')');	x=x*-1;			var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");}
		else if(lx>680 && t==1){		eval('window.clearInterval('+intVar+')');	x=x*-1;	y=y*-1; var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");	t=0;}
		else if(ly>515 && t!=2){t=2;	eval('window.clearInterval('+intVar+')');	y=y*-1;			var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");}
		else if(ly>515 && t==2){		eval('window.clearInterval('+intVar+')');	x=x*-1;	y=y*-1;	var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");	t=0;}
		else if(lx<0 && t!=3){	t=3;	eval('window.clearInterval('+intVar+')');	x=x*-1;			var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");}
		else if(lx<0 && t==3){			eval('window.clearInterval('+intVar+')');	x=x*-1;	y=y*-1;	var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");	t=0;}
		else if(ly<0 && t!=4){	t=4;	eval('window.clearInterval('+intVar+')');	y=y*-1;			var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");}
		else if(ly<0 && t==4){			eval('window.clearInterval('+intVar+')');	x=x*-1;	y=y*-1;	var mov = new moving(lname,x,y,intVar);	eval(intVar+" = mov.aktiv");	t=0;}
	}else if (document.all)	{
		if(lname=='teaser1'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && t!=1){		t=1;	rx=-1;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx>680 && t==1){		rx=-1;	ry=-1; 	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly>515 && t!=2){t=2;	ry=-1;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly>515 && t==2){		rx=-1;	ry=-1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx<0 && t!=3){	t=3;	rx=1;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx<0 && t==3){			rx=1;	ry=1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly<0 && t!=4){	t=4;	ry=1;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly<0 && t==4){			rx=1;	ry=1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else{a=a+(1*rx);b=b+(1*ry);}
			document.all[lname].style.left = a;	document.all[lname].style.top = b;
		}else if(lname=='teaser2'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && tb!=1){	tb=1;	rbx=-1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx>680 && tb==1){		rbx=-1;	rby=-1; tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly>515 && tb!=2){tb=2;	rby=-1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly>515 && tb==2){		rbx=-1;	rby=-1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx<0 && tb!=3){	tb=3;	rbx=1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx<0 && tb==3){			rbx=1;	rby=1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly<0 && tb!=4){	tb=4;	rby=1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly<0 && tb==4){			rbx=1;	rby=1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else{c=c+(1*rbx);d=d+(1*rby);}
			document.all[lname].style.left = c;	document.all[lname].style.top = d;
		}else if(lname=='teaser3'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && tc!=1){	tc=1;	rcx=-1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx>680 && tc==1){		rcx=-1;	rcy=-1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly>515 && tc!=2){tc=2;	rcy=-1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly>515 && tc==2){		rcx=-1;	rcy=-1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx<0 && tc!=3){	tc=3;	rcx=1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx<0 && tc==3){			rcx=1;	rcy=1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly<0 && tc!=4){	tc=4;	rcy=1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly<0 && tc==4){			rcx=1;	rcy=1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else{f=f+(1*rcx);g=g+(1*rcy);}
			document.all[lname].style.left = f;	document.all[lname].style.top = g;
		}
	}else if (document.getElementById) {
		if(lname=='teaser1'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && t!=1){		t=1;	rx=-1;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx>680 && t==1){		rx=-1;	ry=-1; 	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly>515 && t!=2){t=2;	ry=-1;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly>515 && t==2){		rx=-1;	ry=-1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx<0 && t!=3){	t=3;	rx=1;	a=a+(1*rx);b=b+(1*ry);}
			else if(lx<0 && t==3){			rx=1;	ry=1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly<0 && t!=4){	t=4;	ry=1;	a=a+(1*rx);b=b+(1*ry);}
			else if(ly<0 && t==4){			rx=1;	ry=1;	t=0;	a=a+(1*rx);b=b+(1*ry);}
			else{a=a+(1*rx);b=b+(1*ry);}
			document.getElementById(""+lname+"").style.left = a; document.getElementById(""+lname+"").style.top = b;
		}else if(lname=='teaser2'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && tb!=1){	tb=1;	rbx=-1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx>680 && tb==1){		rbx=-1;	rby=-1; tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly>515 && tb!=2){tb=2;	rby=-1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly>515 && tb==2){		rbx=-1;	rby=-1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx<0 && tb!=3){	tb=3;	rbx=1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(lx<0 && tb==3){			rbx=1;	rby=1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly<0 && tb!=4){	tb=4;	rby=1;	c=c+(1*rbx);d=d+(1*rby);}
			else if(ly<0 && tb==4){			rbx=1;	rby=1;	tb=0;	c=c+(1*rbx);d=d+(1*rby);}
			else{c=c+(1*rbx);d=d+(1*rby);}
			document.getElementById(""+lname+"").style.left = c; document.getElementById(""+lname+"").style.top = d;
		}else if(lname=='teaser3'){
			l = new pos(''+lname+'');lx = l.l.replace(/px/,"");ly = l.t.replace(/px/,"");
			if(lx>680 && tc!=1){	tc=1;	rcx=-1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx>680 && tc==1){		rcx=-1;	rcy=-1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly>515 && tc!=2){tc=2;	rcy=-1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly>515 && tc==2){		rcx=-1;	rcy=-1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx<0 && tc!=3){	tc=3;	rcx=1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(lx<0 && tc==3){			rcx=1;	rcy=1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly<0 && tc!=4){	tc=4;	rcy=1;	f=f+(1*rcx);g=g+(1*rcy);}
			else if(ly<0 && tc==4){			rcx=1;	rcy=1;	tc=0;	f=f+(1*rcx);g=g+(1*rcy);}
			else{f=f+(1*rcx);g=g+(1*rcy);}
			document.getElementById(""+lname+"").style.left = f; document.getElementById(""+lname+"").style.top = g;
		}
	} 
}

