All pastes #503705 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-05-22 23:59 UTC
rendered paste body
<script>
<!-- Beginning of JavaScript -

var floatingspeed=8
var clipleft=new Array()
var clipright=new Array()
var cliptop=new Array()
var clipbottom=new Array()
var clipwidth=new Array()
var clipheight=new Array()
var clipwidthmax=500
var clipheightmax=400
var tempo=30
var numberofghosts=5
var shift_x=Math.floor(numberofghosts/2)*-1
var shift_y=Math.floor(numberofghosts/2)*-1
var stepx=new Array()
var stepy=new Array()
for (i=0;i<=numberofghosts;i++) {
	stepx[i]=randommaker(floatingspeed)
	stepy[i]=randommaker(floatingspeed)
}
var imgwidth=new Array()
var imgheight=new Array()

var marginbottom=0
var marginleft=0
var margintop=0
var marginright=0
var timer

function setValues() {
	if (document.all) {
		marginleft=document.all.ghost0.style.posLeft
		margintop=document.all.ghost0.style.posTop
    	marginbottom=document.body.clientHeight
    	marginright=document.body.clientWidth
		
		for (i=0;i<=numberofghosts;i++) {             	
        	clipleft[i]=randommaker(marginright)
			cliptop[i]=randommaker(margintop)
			clipheight[i]=randommaker(clipheightmax)
			clipwidth[i]=randommaker(clipwidthmax)
		}
		for (i=0;i<=numberofghosts;i++) { 
			var thisspan=eval("document.all.ghost"+(i)+".style")            	
        	thisspan.posLeft=document.all.mastercontent.style.posLeft+i+shift_x
			thisspan.posTop=document.all.mastercontent.style.posTop+i+shift_y
			
			if (shift_x==i) {
				thisspan.posLeft+=2
				thisspan.posTop+=2
			}
		}
		checkmovement()
	}
}

function randommaker(range) {		
	rand=Math.floor(range*Math.random())
	if (rand==0) {rand=Math.ceil(range/2)}
    return rand
}

function checkmovement() {
	if (document.all) {
		checkposition()
		movepictures()
    	timer=setTimeout("checkmovement()",tempo)
	}
}

function movepictures() {
		if (document.all) {
			for (i=0;i<=numberofghosts;i++) {  
    			var thisspan=eval("document.all.ghost"+(i)+".style")
    			clipleft[i]+=stepx[i]
				clipright[i]=clipleft[i]+clipwidth[i]
				cliptop[i]+=stepy[i]
				clipbottom[i]=cliptop[i]+clipheight[i]
				thisspan.clip ="rect("+cliptop[i]+" "+clipright[i]+" "+clipbottom[i]+" "+clipleft[i]+")"
    		}
		}
}

function checkposition() {
	if (document.all) {
		for (i=0;i<=numberofghosts;i++) {             
			var thisspan=eval("document.all.ghost"+i+".style")
			if (clipright[i]>marginright) {	
				clipleft[i]-=Math.abs(stepx[i]+1)
				clipright[i]=clipleft[i]+clipwidth[i]
				thisspan.clip ="rect("+cliptop[i]+" "+clipright[i]+" "+clipbottom[i]+" "+clipleft[i]+")"
				stepx[i]=randommaker(floatingspeed)*-1	
			}
			if (clipleft[i]<marginleft) {
				clipleft[i]+=Math.abs(stepx[i]+1)
				clipright[i]=clipleft[i]+clipwidth[i]
				thisspan.clip ="rect("+cliptop[i]+" "+clipright[i]+" "+clipbottom[i]+" "+clipleft[i]+")"
				stepx[i]=randommaker(floatingspeed)			
			}	
			if (clipbottom[i]>marginbottom) {
				cliptop[i]-=Math.abs(stepy[i])
				clipbottom[i]=cliptop[i]+clipheight[i]
				thisspan.clip ="rect("+cliptop[i]+" "+clipright[i]+" "+clipbottom[i]+" "+clipleft[i]+")"
				stepy[i]=randommaker(floatingspeed)*-1
			}
			if (cliptop[i]<margintop) {
				cliptop[i]+=Math.abs(stepy[i])
				clipbottom[i]=cliptop[i]+clipheight[i]
				thisspan.clip ="rect("+cliptop[i]+" "+clipright[i]+" "+clipbottom[i]+" "+clipleft[i]+")"
				stepy[i]=randommaker(floatingspeed)
			}
		}
	}
}

// - End of JavaScript - -->
</script>