function SkiftBagrund()
{
back++
Farver=''
for (i=1;i<6;i++)
Farver+= 'blaa'+i+'.gif|';

Farver+= 'groen1.gif|groen5.gif|';
for (i=4;i<6;i++)
Farver+= 'graa'+i+'.gif	|';
farv=Farver.split("|");

(back<farv.length)?document.body.background = farv[back]:back=0;
alert(farv[back])

}

ord=ordene.split(",")
function Start()
{
	skjulLayers();
	StartAnim();
}


function WriteDivs()
{
//Skriver dynamiskt antal af layers (Div) der svarer til antallet af ord.
//Diverne bliver skrevet sidst på siden sådan at resten af siden ikke bliver overskrevet.(Afslutningen </body> bliver også skrvet her.
for(i=0;i<ord.length;i++)
	{
	document.write('<div id="move'+i+'"   style="position:absolute; visibility:hidden;"><h3>'+ord[i]+'</h3></div>')
	document.write('</body>')
	document.write('</html>')


	}
CreateTheDiv()	
}	



function VisBilled(TheOpacity,FinishOpacity,Style)
{
	BilledDiv.style.visibility ="visible"
	ISO14001.filters.item('DXImageTransform.Microsoft.alpha').opacity = TheOpacity;
	ISO14001.filters.item('DXImageTransform.Microsoft.alpha').finishOpacity = FinishOpacity
	ISO14001.filters.item('DXImageTransform.Microsoft.alpha').style = 2
		
}

function makeArray(n)
{
//Laver et tomt array af længden n
//Skal kaldes med parameteren new
this.length = n;
for(var i= 1; i<=n; i++)
	{
	//Sæt alle værdier til null
	this[i]=null;
	}
//returner det ny array	
return this;
}
function makeSubObjects(X,Y,moveRight,moveDown,StartVinkel,TheStep,FontSize)
{
//Laver et objekt med  undervariable bruges til  arrayen som herved bliver array objekt
//Husk at brug new keyword når du bruger den.
this.X=X;
this.Y=Y;
this.moveRight=moveRight;
this.moveDown=moveDown;
this.StartVinkel=StartVinkel;
this.TheStep=TheStep;
this.FontSize=FontSize
}
function CreateTheDiv()
	{
	X=bredde/3
	Y=hoejde/3
	TheDivVars=new makeArray(ord.length)	
	TheDiv= new makeArray(ord.length)
	for(i=0;i<ord.length;i++)
		{
		TheDiv[i]=eval('move'+i)
	
		moveRight=true
		moveDown=true
		TheStep=1
		StartVinkel=Math.PI*(i+1) /(ord.length+2) + Math.random()*0.3
		FontSize=12
		TheDivVars[i]=new makeSubObjects(X,Y,moveRight,moveDown,StartVinkel,TheStep,FontSize)
		}			
	}
function VisBilleder()
{
for (i=0;i<document.images.length;i++) alert(document.images.item[i]);

}
function StartAnim()
{

		StopAnimation=true
		ANIMER=clearTimeout()

		//VisBilled(0,0,0)
		BilledDiv.style.visibility="hidden"
		

		theCounter=1


		for(i=0;i<ord.length;i++)
		{


	

		

		TheDivVars[i].moveRight=false;
		if(Math.cos(TheDivVars[i].StartVinkel)>0) TheDivVars[i].moveRight=true;
		TheDivVars[i].moveDown=true;
		if(Math.sin(TheDivVars[i].StartVinkel)>0) TheDivVars[i].moveDown=false;
		TheDiv[i].style.visibility='visible'				
		}
	StopAnimation=false	
	
	TheHref=document.location.href
	CommingFrom=TheHref.split("?")
	if (CommingFrom.length >1)
	{//kommer fra en intern side
	ANIMER=window.setTimeout("ShortAnimation()",Tick)


	}
	else
	{//kommer udefra
	ANIMER=setTimeout("Animation()",Tick)

	}


	
	
	
	
		
}

function ShortAnimation()
{


for(i=0;i<ord.length;i++)
	{


	
	
		
	theCounter++
	if (TheDivVars[i].X<=EndLeft)
	{
	TheDivVars[i].X=LeftBound+Math.floor(theCounter*(ord.length-i));
	TheDivVars[i].Y=UpBound+Math.floor(theCounter/2*(i+1));
	}
	else
	{
	TheDivVars[i].X=EndLeft;
	TheDivVars[i].Y=EndFirstElementTop+DeltaElement*i;
	}
	
	
	//TheDiv[i].innerHTML=theCounter
	TheDiv[i].style.top=TheDivVars[i].Y
	TheDiv[i].style.left=TheDivVars[i].X


	if (theCounter>5)
		{
		//Billedet kaldes frem her fra
		FinishOpacity=theCounter/2-30
		if(FinishOpacity>finalFinishOpacity) FinishOpacity=finalFinishOpacity;
		Opacity=theCounter/2-25
		if (Opacity>finalOpacity) Opacity=finalOpacity;
		//VisBilled(Opacity,FinishOpacity,2)
		}
		
	}//For I=ord.length

if(theCounter<60)
	{ //Man kan godt skrive en if sætning på en linie ! er negation StopAnimation er nødt til at blive
	//sat ellers kan man ikke få stoppet setTimeouten.
	if(!StopAnimation)	ANIMER=setTimeout("ShortAnimation()",Tick);
	}
else
	{
	BilledDiv.style.visibility="visible"
	ANIMER=clearTimeout()
	StopAnimation=true
	vis('1')
	

	}
	
}
function Animation()
{
//ordene springer mellem grænserne der er definieret i variablene var LeftBound,RightBound Upbound og DownBound)
for(i=0;i<ord.length;i++)
	{
	switch(TheDivVars[i].TheStep)
	{
	case 1:
	MoveAround()

	break; //0
	case 2:
		{
		MoveToPosition(i,200,FirstYToMoveTo )
		TheColor=MakeColor()
		forstoerFont(i,TheColor,1)		


		}
	break;
	case 3:
		{
		MoveToPosition(i,EndLeft,EndFirstElementTop+DeltaElement*i)
		TheColor=MakeColor()
	
	
		forstoerFont(i,TheColor,-2)		
		}
	break;
	case 4:	
		TheDiv[i].style.visibility='visible'
		TheDivVars[i].FontSize=14
		forstoerFont(i,'000000'-2)
		//lodret
		TheDivVars[i].Y=EndFirstElementTop+i*DeltaElement
		//vandret
		TheDivVars[i].X=EndLeft

	break;	
	}//Switch(TheStep)

	TheDiv[i].style.top=TheDivVars[i].Y
	TheDiv[i].style.left=TheDivVars[i].X
if(theCounter==(i+1)*TheShifInc+40)
{//First change (Move to left expand fontsize)
	FirstYToMoveTo=Math.floor(200*Math.random())
	TheDivVars[i].FontSize=12
	TheDivVars[i].TheStep=2;


}	
if(theCounter==(i+1)*TheShifInc+80)
{//Second Chagne Movetowards end lreduce fontsize
	TheDivVars[i].FontSize=60
	TheDivVars[i].TheStep=3;


}
if(theCounter==(i+2)*TheShifInc+80) TheDivVars[i].TheStep=4;
}//Third change (ending)

theCounter++
//Time line
if (theCounter>50)
{
//Billedet kaldes frem her fra
FinishOpacity=theCounter/3-30
if(FinishOpacity>finalFinishOpacity) FinishOpacity=finalFinishOpacity;
Opacity=theCounter/3-25
if (Opacity>finalOpacity) Opacity=finalOpacity;
//VisBilled(Opacity,FinishOpacity,2)
}

switch(theCounter)
{





}


if(theCounter<65*ord.length)
	{ //Man kan godt skrive en if sætning på en linie ! er negation StopAnimation er nødt til at blive
	//sat ellers kan man ikke få stoppet setTimeouten.
	if(!StopAnimation)	ANIMER=setTimeout("Animation()",Tick);
	}
else
	{
	ANIMER=clearTimeout()
	StopAnimation=true
	vis('1')
	

	}

}
function MakeColor()
{
	chr1=Math.floor(TheDivVars[i].FontSize/4)
		chr2=TheDivVars[i].FontSize%10
		if (TheDivVars[i].FontSize>=40) chr1='A'
		if (TheDivVars[i].FontSize>=50) chr1='B'
		if (TheDivVars[i].FontSize>=60) chr1='C'
		if (TheDivVars[i].FontSize>=70) chr1='D'	
		if (TheDivVars[i].FontSize>=100) chr1='E'			
		TheColor=''+chr1+chr2+chr1+chr2+chr1+chr2
return TheColor;
}

function MoveToPosition(j,XPos,YPos)

{
	if(Math.abs(TheDivVars[j].X-XPos)>10)
		{
		TheDivVars[j].X-=(TheDivVars[j].X-XPos)/10
		}
	else
		{
		TheDivVars[j].X=XPos
		}
	if(Math.abs(TheDivVars[j].Y*1-YPos*1)>10)
		{
		TheDivVars[j].Y-=(TheDivVars[j].Y-YPos)/10

		}
	else
		{
	
		TheDivVars[j].Y=YPos
		}
	

}



function MoveAround()
	{
		if(TheDivVars[i].X<LeftBound) 
			{
			Indx++
			if (Indx>ord.length-1) Indx=0;		
			}
		if(TheDivVars[i].X>RightBound) TheDivVars[i].moveRight=false;
		if(TheDivVars[i].X<LeftBound) TheDivVars[i].moveRight=true;
		if (TheDivVars[i].moveRight)
			{
			TheDivVars[i].X+=TheMove*Math.abs(Math.cos(TheDivVars[i].StartVinkel))
			
			}
		else
			{
			TheDivVars[i].X-=TheMove*Math.abs(Math.cos(TheDivVars[i].StartVinkel))
			}
			//TheDiv[i].innerHTML=TheDivVars[i].moveDown
		if(TheDivVars[i].Y<UpBound) TheDivVars[i].moveDown = true;
		if(TheDivVars[i].Y>DownBound) TheDivVars[i].moveDown = false;
		if (TheDivVars[i].moveDown)
			{
			TheDivVars[i].Y+=TheMove*Math.abs(Math.sin(TheDivVars[i].StartVinkel))
			}
		else
			{
			TheDivVars[i].Y-=TheMove*Math.abs(Math.sin(TheDivVars[i].StartVinkel))
			}
			
	}

function forstoerFont(Indx,TheColor,incr)
{	
	
	TheDivVars[Indx].FontSize+=incr
	if	(TheDivVars[Indx].FontSize<12)TheDivVars[Indx].FontSize=12;
	TheDiv[Indx].innerHTML='<font color="'+TheColor+'" ><h3><span style="Font-size:'+TheDivVars[Indx].FontSize+'pt">'+ord[Indx]+'</span></h3></font>'


}
function EndPosition()
{
for (i=0;i<TheDiv.length;i++)
	{	//lodret
		TheDivVars[i].Y=EndFirstElementTop+i*DeltaElement
		//vandret
		TheDivVars[i].X=EndLeft
		TheDiv[i].style.top=TheDivVars[i].Y
		TheDiv[i].style.left=TheDivVars[i].X

	}
 
}

function StopAnim()
{
//stopper animationen og gemmer div-erne 
StopAnimation=true;
ANIMER=clearTimeout();
EndPosition()

for(i=0;i<ord.length;i++)
	{
	TheDiv[i].style.visibility='visible'
	TheDivVars[i].FontSize=14
	forstoerFont(i,'000000',0)

	}
An=window.setTimeout("EndPosition()",100)
}

function skjulLayers()
{
//skjuler alle sider
//Her bestemmer du hvor skarpt vandmærket skal være
	
//VisBilled(finalOpacity,finalFinishOpacity,2)
StopAnim()

for(i=1;i<NoOfLayers*1+1;i++)
	{
	Siden=eval('vignet'+i);
	Siden.style.visibility="hidden"
	}
	
}
function vis(Side)
{
//viser vignet siderne argumentet er nummer på Div id fulgt af vignet
	StopAnim();
	skjulLayers()
	Siden=eval('vignet'+Side)
	Siden.style.visibility="visible"
	Siden.style.top=LayerTop
	Siden.style.left=LayerLeft
	BilledDiv.style.visibility="visible"
	
}
function skjul(Side)
{
//skjuler siden (er ikke brugt da alle sider skules med SkjulLayers
	Siden=eval('vignet'+Side)
	Siden.style.visibility="hidden"
	BilledDiv.style.visibility="hidden"
}
