﻿/*   Animation with Colocated Images and Eight Colored Filters. Copyright  2004, RomanticRoad e.K. Munich      */


var objsnr = 5;
var slowdt = 100;
var animimgw = 300; 
var animimgh  = 225; 
var animimgleft = 675; 
var animimgtop = 400;
var dxdis = 2;
var dxdis5 = 1;
var fastdt = 40;


var dydis = 2;
var dydis5 = 1;
var objswidth;
var objswidth5;
var objsheight;
var objsheight5;
var objsleft;
var objsleft5;
var objsleftpx;
var objstop;
var objstop5; 
var objstoppx;
var objsxcen;
var objsxcenpx;
var objsycen;
var objsycenpx;

var f11top;
var f12top;
var f13top;
var f14top;
var f11left;
var f12left;
var f13left;
var f14left; 
/*
var dlpf11 = 0;
var dtpf11 = 0;
var lpf11temp= 0;
var tpf11temp= 0;
*/
var dlpf12 = 0;
var dtpf12 = 0;
var lpf12temp= 0;
var tpf12temp= 0;
var dlpf13 = 0;
var dtpf13 = 0;
var lpf13temp= 0;
var tpf13temp= 0;
var dlpf14 = 0;
var dtpf14 = 0;
var lpf14temp= 0;
var tpf14temp= 0;

var dwd = 1;
var dht  = 1;
var callctr = 0;
var drawnr = 0;
var timer1 = null;
var timer2 = null;
var timerf = null;
var animObjs = new Array();
var filter11Obj;
var filter12Obj;
var filter13Obj;
var filter14Obj;
var stdBrowser = true;


function animValues()
{
	objswidth    = Math.floor(animimgw * scrw / 1024);
	objsheight   = Math.floor(animimgh * scrw / 1024);
	objswidth5  = Math.ceil(objswidth  / 2);
	objsheight5 = Math.ceil(objsheight  / 2);

	objsleft    = Math.floor(animimgleft * scrw / 1024);
	objstop   =  Math.floor(animimgtop * scrw / 1024);
	objsxcen = Math.floor(objsleft + objswidth / 2); 
	objsycen = Math.floor(objstop + objsheight / 2); 
	objsleft5  = Math.ceil(objsleft + objswidth / 2 );
	objstop5  = Math.ceil(objstop + objsheight / 2 );

	objsleftpx   =  objsleft + "px";
	objstoppx   =  objstop + "px";
	objsxcenpx = objsxcen + "px";
	objsycenpx = objsycen + "px";
	
	if (scrw > 1025) {fastdt = Math.floor( fastdt * 1024 / scrw); }
	dydis   =  Math.round(dxdis * animimgh / animimgw);
	dydis5 =  Math.round(dxdis5 * animimgh / animimgw);
}

function initColorFilters()
{
	
	if (document.getElementById)
	{
		filter11Obj =  document.getElementById("filter11").style;
		filter12Obj =  document.getElementById("filter12").style;
		filter13Obj =  document.getElementById("filter13").style;
		filter14Obj =  document.getElementById("filter14").style;
	}
	else
	{
		filter11Obj  =  document.filter11;
		filter12Obj  =  document.filter12;
		filter13Obj  =  document.filter13;
		filter14Obj  =  document.filter14;
 	}
}	


function initAnim()
{
	animValues();
	initColorFilters();
	for ( var i = 1; i <= objsnr; i++)
	{
		var animtemp = "anim1" + i;
		if (document.getElementById)
		{
			animObjs[i]  = document.getElementById(animtemp).style;
		}
		else
		{
			animObjs[i] = document[animtemp];
		 	
		}
		animObjs[i].visibility = "hidden";
	}
	animObjs[objsnr].visibility = "visible";
}	


	
function chgvis()
{
	if (callctr > 1)
	{
		animObjs[callctr - 1].visibility  = "hidden";
	}
	else
	{
		animObjs[objsnr].visibility  = "hidden";
	}
	animObjs[callctr].visibility  = "visible";
}


function counter()
{
	clearTimeout(timerf);
	clearTimeout(timer1);
	clearTimeout(timer2);
	if (callctr < objsnr)
	{
		callctr = callctr + 1; 
	}
	else
	{
		callctr = 1;
	}
}


/*   Start Animation   */

function startAnim()
{

	if (document.getElementById) 
	{
		filter11Obj.visibility = "visible";  
		filter12Obj.visibility = "visible";  
		filter13Obj.visibility = "visible";  
		filter14Obj.visibility = "visible";
		// if (navigator.appName == "Netscape") {    }
		callctr = 1;
		initFilter();
	}
	else
	{
		filter11Obj.visibility = "hidden";  
		filter12Obj.visibility = "hidden";  
		filter13Obj.visibility = "hidden";  
		filter14Obj.visibility = "hidden";
		callctr = 0;
		slowdt = 6000;
		timer1 = setTimeout("animBasic()",slowdt); 
	}
}



function animBasic()
{
	counter();
	chgvis();
	timer = setTimeout("animBasic()",slowdt);
}


function initFilter()
{
	document.black11.width  = 0;
	document.black12.height  = 0;	
	document.black13.width  = 0;
	document.black14.height  = 0;	
	document.black11.height  = 0;
	document.black12.width  = 0;	
	document.black13.height = 0;
	document.black14.width  = 0;	
	
	// drawnr = Math.ceil(Math.random() * 6);
	drawnr = 5;

	if (drawnr == 1)
	 {
		// left to right
		filter11Obj.top = objstoppx; filter11Obj.left = objsleftpx; document.black11.width = 0; document.black11.height = objsheight;
		timer1 = setTimeout("filter1r()",slowdt);
	}
	if (drawnr == 2)
	{ 
		// top to bottom
		filter12Obj.top = objstoppx; filter12Obj.left = objsleftpx; document.black12.width  = objswidth; document.black12.height = 0;
		timer1 = setTimeout("filter2r()",slowdt);
	}
	if (drawnr == 3)
	{ 
		// right to left
		filter13Obj.top = objstoppx; filter13Obj.left = objsleft + objswidth + "px";document.black13.width=0;document.black13.height=objsheight;
		f13left = objsleft + objswidth; dlpf13 = 0;
		timer1 = setTimeout("filter3r()",slowdt);
	}
	if (drawnr == 4)
	{ 
		// bottom to top
		filter14Obj.top = objstop+objsheight + "px";filter14Obj.left=objsleftpx;document.black14.width=objswidth;document.black14.height=0;
		f14top = objstop + objsheight; dtpf14 = 0;
		timer1 = setTimeout("filter4r()",slowdt);
	}

	if  (drawnr == 5)
	{ 
		// right to left and left to right (curtains opening and closing)
		filter11Obj.top = objstoppx; filter11Obj.left = objsleftpx; document.black11.width  = 0; document.black11.height = objsheight;
		filter13Obj.top = objstoppx; filter13Obj.left = objsleft + objswidth + "px";document.black13.width=0;document.black13.height=objsheight;
		f13left = objsleft + objswidth;dlpf13 = 0;
		timer1 = setTimeout("filter6r()",slowdt);
	}
	if  (drawnr == 6)
	{
		// outer to inner (inward expanding border)
		filter11Obj.top = objstoppx; filter11Obj.left = objsleftpx; document.black11.width  = 0; document.black11.height = objsheight;
		filter12Obj.top = objstoppx; filter12Obj.left = objsleftpx; document.black12.width  = objswidth; document.black12.height = 0;
		filter13Obj.top = objstoppx; filter13Obj.left = objsleft + objswidth + "px"; document.black13.width=0;document.black13.height=objsheight;
		filter14Obj.top = objstop+objsheight + "px";filter14Obj.left=objsleftpx;document.black14.width=objswidth;document.black14.height=0;
		f13left = objsleft + objswidth; dlpf13 = 0; f14top = objstop + objsheight; dtpf14 = 0;
		timer1 = setTimeout("filter5r()",slowdt);
	}
	
	if (drawnr == 7 )
	{
		// inner to outer (expanding rectange)
		filter11Obj.top = objsycenpx; filter11Obj.left = objsxcenpx; document.black11.width  = 0; document.black11.height = 0;
		filter12Obj.top = objsycenpx; filter12Obj.left = objsxcenpx; document.black12.width  = 0; document.black12.height = 0;
		filter13Obj.top = objsycenpx; filter13Obj.left = objsxcenpx; document.black13.width  = 0; document.black13.height = 0;
		filter14Obj.top = objsycenpx; filter14Obj.left = objsxcenpx; document.black14.width  = 0; document.black14.height = 0;
		f12left = objsxcen; f13left = objsxcen; f13top = objsycen; f14top = objsycen; dlpf12 = 0; dlpf13 = 0; dtpf13 = 0; dtpf14 = 0;
		timer1 = setTimeout("filterDrvr()",slowdt);
	}
	if (drawnr == 8)
	{
		// outer to inner (contracting cross pattern)
		filter11Obj.top = objstoppx;  filter11Obj.left = objsleftpx; document.black11.width  = 0; document.black11.height = 0;
		filter12Obj.top = objstoppx;  filter12Obj.left = objsleft + objswidth + "px"; document.black12.width  = 0; document.black12.height = 0;
		filter13Obj.top = objstop + objsheight + "px"; filter13Obj.left = objsleft + objswidth + "px"; document.black13.width = 0; document.black13.height = 0;
		filter14Obj.top = objstop + objsheight + "px"; filter14Obj.left = objsleftpx; document.black14.width  = 0; document.black14.height = 0;
		f12left = objsleft + objswidth; f13left = objsleft + objswidth; f13top = objstop + objsheight; f14top = objstop + objsheight; 
		dlpf12 = 0; dlpf13 = 0; dtpf13 = 0; dtpf14 = 0;
		timer1 = setTimeout("filterDrvr()",slowdt);
	}

}




/*  Filter 1  Horizontal  left to right and back */

function filter1()
{	
	document.black11.width = document.black11.width - dxdis;
	if (document.black11.width < dwd)
	{
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter1()",fastdt);
	}
}

function filter1r()
{
	document.black11.width = document.black11.width + dxdis;
	if (document.black11.width > objswidth )
	{
		document.black11.width = objswidth;
		chgvis();
		filter1();
	}
	else
	{
		timerf = setTimeout("filter1r()",fastdt);
	}
}

/*    Filter 2   Vertical  top to bottom and back */

function filter2()
{
	
	document.black12.height = document.black12.height - dydis;
	if (document.black12.height < dht)
	{
		counter();		
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter2()",fastdt);
	}
}

function filter2r()
{
	document.black12.height = document.black12.height + dydis;
	if (document.black12.height > (objsheight - dht)) 
	{
		document.black12.height = objsheight;
		chgvis();
		filter2();
	}
	else
	{
		timerf = setTimeout("filter2r()",fastdt);
	}
}

/* Filter 3 Horizontal from right to left and back */

function filter3()
{
	document.black13.width = document.black13.width - dxdis;
	dlpf13 = dlpf13 +  dxdis; lpf13temp =  objsleft + dlpf13; filter13Obj.left =  lpf13temp + "px";
	if  ( (document.black13.width < 0) || (lpf13temp > f13left - dwd) )
	{
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter3()",fastdt);
	}
}

function filter3r()
{
	document.black13.width = document.black13.width + dxdis; 
	dlpf13 = dlpf13 - dxdis; lpf13temp =  f13left + dlpf13; filter13Obj.left =  lpf13temp + "px";
	if   ( (document.black13.width > objswidth) || (lpf13temp < objsleft) )
	{
		document.black13.width = objswidth;
		filter13Obj.left  = f13left - objswidth + "px";
		dlpf13 = 0;
		chgvis();
		filter3()
	}
	else
	{
		timerf = setTimeout("filter3r()",fastdt);
	}
}

/* Filter 4   f14:bottom to top */

function filter4()
{
	document.black14.height = document.black14.height - dydis;
	dtpf14 = dtpf14 +  dydis; tpf14temp =  objstop + dtpf14; filter14Obj.top =  tpf14temp + "px";
	if  ( (document.black14.height < dwd) || (tpf14temp > (f14top - dwd)) )
	{
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter4()",fastdt);
	}
}

function filter4r()
{
	document.black14.height = document.black14.height + dydis;
	dtpf14 = dtpf14 - dydis; tpf14temp =  f14top + dtpf14; filter14Obj.top =  tpf14temp + "px";
	if ( (document.black14.height > (objsheight - dwd)) || (tpf14temp < (objstop - dwd)) )
	{
		document.black14.height = objsheight;
		filter14Obj.top  = f14top - objsheight + "px";
		dtpf14 = 0;
		chgvis();
		filter4();
	}
	else
	{
		timerf = setTimeout("filter4r()",fastdt);
	}
}

/*  Filter 5,   Filters 1,2,3 and 4 Running at the same time  */

function filter5()
{
	document.black13.width  = document.black13.width   - dxdis5;
	document.black11.width  = document.black11.width  - dxdis5;
	dlpf13 = dlpf13 + dxdis5;  lpf13temp  =  f13left - objswidth5 + dlpf13;  filter13Obj.left =  lpf13temp + "px";
	dtpf14 = dtpf14 + dydis5; tpf14temp  =  f14top - objsheight5 + dtpf14;  filter14Obj.top =  tpf14temp + "px";
	document.black12.height = document.black12.height - dydis5;
	document.black14.height = document.black14.height - dydis5;
	if ( (document.black12.height < dht) || (document.black11.width < dwd) || (tpf14temp > (f14top-dht)) || (lpf13temp > (f13left-dwd))  )
	{
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter5()",fastdt);
	}
}

function filter5r()
{
	document.black11.width  = document.black11.width  + dxdis5;
	document.black12.height = document.black12.height + dydis5;
	document.black13.width  = document.black13.width   + dxdis5;
	document.black14.height = document.black14.height  + dydis5;
	dlpf13 = dlpf13 - dxdis5; lpf13temp  =  f13left + dlpf13; filter13Obj.left =  lpf13temp + "px";
	dtpf14 = dtpf14 - dydis5; tpf14temp =  f14top + dtpf14; filter14Obj.top =  tpf14temp + "px";
	if ( (document.black12.height > (objsheight5-dht)) || (document.black11.width > (objswidth5-dwd)) || (lpf13temp < (objsleft5-dwd)) || (tpf14temp < (objstop5-dht))  ) 
	{
		document.black11.width  = objswidth5;
		document.black12.height = objsheight5;
		document.black13.width  = objswidth5;
		document.black14.height = objsheight5; 
		filter13Obj.left  = f13left - objswidth5 +  "px"; dlpf13 = 0;
		filter14Obj.top = f14top - objsheight5 + "px"; dtpf14 = 0;
		chgvis();
		filter5();
	}
	else
	{
		timerf = setTimeout("filter5r()",fastdt);
	}
}

/*  Filter 6,   Filters 1 and 3  Running at the same time  */

function filter6()
{
	document.black11.width  = document.black11.width  - dxdis5;
	document.black13.width  = document.black13.width   - dxdis5;
	dlpf13 = dlpf13 + dxdis5;  lpf13temp  =  objsleft5 + dlpf13;  filter13Obj.left =  lpf13temp + "px";
	if ( (document.black11.width < 1) && (lpf13temp > f13left)  )
	{
		
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filter6()",fastdt);
	}
}

function filter6r()
{
	document.black11.width  = document.black11.width  + dxdis5;
	document.black13.width  = document.black13.width   + dxdis5;
	dlpf13 = dlpf13 - dxdis5; lpf13temp  =  f13left + dlpf13; filter13Obj.left =  lpf13temp + "px";
	// if ( (document.black11.width > (objswidth5 + dxdis5) ) && (lpf13temp < (objsleft5  - dxdis5)) ) 
	if (  (document.black11.width > objswidth5 ) && (lpf13temp < objsleft5 )  )
	{
		document.black11.width  = objswidth5;
		document.black13.width  = objswidth5;
		filter13Obj.left  = f13left - objswidth5 + "px"; 
		dlpf13 = 0;
		chgvis();
		// filter6();
		timer2 = setTimeout("filter6()",2000);
		
	}
	else
	{
		timerf = setTimeout("filter6r()",fastdt);
		
	}
}


/*  Filter Driver for filters 7 and 8:     f11;stationary,  f12;rt-lft,  f13;rt-lft and bot - top,  f14;bot-top   */

function filterDrv()
{	
	document.black11.width   = document.black11.width -  dxdis5;
	document.black11.height  = document.black11.height - dydis5;
	document.black12.width   = document.black12.width -  dxdis5;
	document.black12.height  = document.black12.height - dydis5;
	document.black13.width   = document.black13.width -  dxdis5;
	document.black13.height  = document.black13.height - dydis5;
	document.black14.width   = document.black14.width -  dxdis5;
	document.black14.height  = document.black14.height - dydis5;
	dlpf12 = dlpf12 +  dxdis5; lpf12temp =  f12left  - objswidth5 + dlpf12; filter12Obj.left =  lpf12temp + "px";
	dlpf13 = dlpf13 +  dxdis5; lpf13temp =  f13left  - objswidth5  + dlpf13; filter13Obj.left =  lpf13temp + "px";
	dtpf13 = dtpf13 + dydis5; tpf13temp =  f13top  - objsheight5 + dtpf13; filter13Obj.top =  tpf13temp + "px";
	dtpf14 = dtpf14 + dydis5; tpf14temp =  f14top  - objsheight5 + dtpf14; filter14Obj.top =  tpf14temp + "px";
	if (  (document.black11.width < dwd)  ||  (document.black11.height <dht)  ) 
	{
		counter();
		initFilter();
	}
	else
	{
		timerf = setTimeout("filterDrv()",fastdt);
	}
}

function filterDrvr()
{
	document.black11.height = document.black11.height  + dydis5;
	document.black11.width  = document.black11.width  + dxdis5;
	document.black12.height = document.black12.height + dydis5;
	document.black12.width  = document.black12.width  + dxdis5;
	document.black13.height = document.black13.height + dydis5;
	document.black13.width  = document.black13.width  + dxdis5;
	document.black14.height = document.black14.height + dydis5;
	document.black14.width  = document.black14.width  + dxdis5;
	dlpf12 = dlpf12 - dxdis5;  lpf12temp =  f12left + dlpf12; filter12Obj.left =  lpf12temp + "px";
	dlpf13 = dlpf13 - dxdis5;  lpf13temp =  f13left + dlpf13; filter13Obj.left =  lpf13temp + "px";
	dtpf13 = dtpf13 - dydis5; tpf13temp =  f13top + dtpf13; filter13Obj.top = tpf13temp + "px";
	dtpf14 = dtpf14 - dydis5; tpf14temp =  f14top + dtpf14; filter14Obj.top =  tpf14temp + "px";
	
	if ( (document.black11.width > (objswidth5 - dwd))  ||  (document.black11.height > (objsheight5 - dht)) )
	{
		document.black11.height = objsheight5;
		document.black11.width = objswidth5;
		document.black12.height = objsheight5;
		document.black12.width = objswidth5;
		document.black13.height = objsheight5;
		document.black13.width = objswidth5;
		document.black14.height = objsheight5;
		document.black14.width = objswidth5;
		filter12Obj.left  =  f12left  - objswidth5   + "px"; dlpf12 = 0;
		filter13Obj.left  =  f13left  - objswidth5   + "px"; dlpf13 = 0;
		filter13Obj.top  =  f13top  - objsheight5  + "px"; dtpf13 = 0;
		filter14Obj.top  =  f14top  - objsheight5  + "px"; dtpf14 = 0;
		chgvis();
		filterDrv();
	}
	else
	{
		timerf = setTimeout("filterDrvr()",fastdt);
	}
}




