<!-- 

// CREDITS:
// PicturePong by Urs Dudli and Peter Gehrig 
// Copyright (c) 2000 Peter Gehrig and Urs Dudli. All rights reserved.
// Permission given to use the script provided that this notice remains as is.
// Additional scripts can be found at http://www.24fun.com.
// info@24fun.ch
// 8/6/2000

// IMPORTANT: 
// If you add this script to a script-library or a script-archive 
// you have to insert a link to http://www.24fun.com right into the webpage where the script
// will be displayed.

// CONFIGURATION:
// Go to http://www.24fun.com, open category 'animation' and 
// download the ZIP-file of this script containing
// the script-file with step-by-step instructions for easy configuration.

//var your_image="testimage86.gif"
var tempo=40
var stepx=17
var stepy=17
var numberofimages=13
var imgpreload=new Image()
//imgpreload.src=your_image

imgpreloadarray=new Array(
             "/graphics/trail-b.gif",
             "/graphics/trail-a.gif",
             "/graphics/trail-u.gif",
             "/graphics/trail-t.gif",
             "/graphics/trail-i.gif",
             "/graphics/trail-s.gif",
             "/graphics/trail-t.gif",
             "/graphics/trail-a.gif",
             "/graphics/trail-f.gif",
             "/graphics/trail-a.gif",
             "/graphics/trail-m.gif",
             "/graphics/trail-i.gif",
             "/graphics/trail-l.gif",
             "/graphics/trail-y.gif");


var x,y
var marginbottom
var marginleft=0
var margintop=0
var marginright
var timer
var trailId
var xpos=new Array()
var ypos=new Array()
var spancontent=new Array()

for (i=0; i<=numberofimages;i++) {
    xpos[i]=0
	ypos[i]=0
}

for (i=0;i<=numberofimages;i++) {
	spancontent[i]= "<img src='" + imgpreloadarray [i] + "'>"
}

function startTrail() {
    var firsttimer= setTimeout("trailInterval()",4000)
}

function trailInterval() {
	if (document.all) {
    	marginbottom=document.body.clientHeight-5
    	marginright=document.body.clientWidth-5
		for (i=0;i<=numberofimages;i++) {             
			var thisspan = eval("document.all.span"+i)
    		thisspan.innerHTML=spancontent[i]
			var thisspan = eval("document.all.span"+(i)+".style")
           	thisspan.posLeft=0 
			thisspan.postop=0  
		}
                trailId = setInterval("moveball()",tempo);
	}
	
	if (document.layers) {
    	marginbottom=window.innerHeight-5
    	marginright=window.innerWidth-5
		for (i=0;i<=numberofimages;i++) {             
			var thisspan=eval("document.span"+i+".document")
    		thisspan.write(spancontent[i])
			thisspan.close()
			var thisspan=eval("document.span"+i)
           	thisspan.left=0 
			thisspan.top=0  
		}
    	moveball()
	}
}

function randommaker(range) {		
	rand=Math.floor(range*Math.random())
    return rand
}

function moveball() {
	if (document.all) {
		checkposition()
   		makesnake()
   		document.all.span0.style.posTop+=stepy
	}
	if (document.layers) {
		checkposition()
   		makesnake()
   		document.span0.top+=stepy
	}
}

function makesnake() {
		for (i=numberofimages; i>=1; i--) {
   			xpos[i]=xpos[i-1]
			ypos[i]=ypos[i-1]
    	}
		if (document.all) {
			xpos[0]=document.all.span0.style.posLeft+stepx
			ypos[0]=document.all.span0.style.posTop+stepy
			for (i=0;i<=numberofimages;i++) {  
    			var thisspan=eval("document.all.span"+(i)+".style")
    			thisspan.posLeft=xpos[i]
				thisspan.posTop=ypos[i]
    		}
		}
		if (document.layers) {
			xpos[0]=document.span0.left+stepx
			ypos[0]=document.span0.top+stepy
			for (i=0;i<=numberofimages;i++) {  
    			var thisspan = eval("document.span"+i)
    			thisspan.left=xpos[i]
				thisspan.top=ypos[i]
    		}
		}
}

function checkposition() {
	if (document.all) {
		if (document.all.span0.style.posLeft>marginright) {
			stepx=(stepx+randommaker(2))*-1
			document.all.span0.style.posLeft-=1
		}
		if (document.all.span0.style.posLeft<marginleft) {
			stepx=(stepx+randommaker(2))*-1
			document.all.span0.style.posLeft+=1
		}	
		if (document.all.span0.style.posTop>marginbottom) {
			stepy=(stepy+randommaker(2))*-1
			document.all.span0.style.posTop-=1
		}
		if (document.all.span0.style.posTop<margintop) {
			stepy=(stepy+randommaker(2))*-1
			document.all.span0.style.posTop+=1
		}
	}
	if (document.layers) {
		if (document.span0.left>=marginright) {
			stepx=(stepx+randommaker(2))*-1
			document.span0.left-=10
		}
		if (document.span0.left<=marginleft) {
			stepx=(stepx+randommaker(2))*-1
			document.span0.left+=10
		}	
		if (document.span0.top>=marginbottom) {
			stepy=(stepy+randommaker(2))*-1
			document.span0.top-=10
		}
		if (document.span0.top<=margintop) {
			stepy=(stepy+randommaker(2))*-1
			document.span0.top+=10
		}
	}
}

function stopTrail() {
         clearInterval(trailId);
         parent.frames[2].location = "/cgi-bin/lognthrow.cgi?pagekey=a-stoptrail";
}

function restartTrail() {
         clearInterval(trailId);
         trailId = setInterval("moveball()",tempo);
         parent.frames[2].location = "/cgi-bin/lognthrow.cgi?pagekey=a-restarttrail";
}

//-->
