Pete Hines Peekaboo Script

This script causes an image of Pete Hines to appear and disappear along the right and left edges of the browser window. It works in Firefox and in IE *if* the doctype of the page is set to HTML 4 Strict.

var pete_xcoord = -24, pete_xalign = 0, pete_shwmax = 1000, pete_hidmax = 1000, pete_movmax = 100
var pete_lftimg, pete_rgtimg, pete_shwbeg, pete_shwmov, pete_xspeed

function pete_init()
{
	pete_lftimg = document.createElement('img')
	pete_lftimg.src = '../images/pete_lft.png'
	pete_lftimg.id = 'pete_lft'
	pete_lftimg.style.position = 'fixed'
	pete_lftimg.style.width = '24px'
	pete_lftimg.style.height = '40px'
	pete_lftimg.style.left = pete_xcoord + 'px'
	pete_lftimg.style.top = '-200px'
	pete_lftimg.style.zIndex = '10'
	pete_lftimg.alt = 'Pete Hines peekaboo!'
	pete_lftimg.title = 'Peekaboo!'
	document.body.appendChild(pete_lftimg)
	pete_rgtimg = document.createElement('img')
	pete_rgtimg.src = '../images/pete_rgt.png'
	pete_rgtimg.id = 'pete_rgt'
	pete_rgtimg.style.position = 'fixed'
	pete_rgtimg.style.width = '24px'
	pete_rgtimg.style.height = '40px'
	pete_rgtimg.style.right = pete_xcoord + 'px'
	pete_rgtimg.style.top = '-200px'
	pete_rgtimg.style.zIndex = '10'
	pete_rgtimg.alt = 'Pete Hines peekaboo!'
	pete_rgtimg.title = 'Peekaboo!'
	document.body.appendChild(pete_rgtimg)
	pete_shwbeg = window.setTimeout(show_begin, Math.floor(Math.random() * pete_hidmax))
}

function show_begin()
{
	if (Math.random() < 0.5)
	{
		pete_xalign = 0
		pete_lftimg.style.top = Math.floor(Math.random() * (screen.height - 40)) + 'px'
	}
	else
	{
		pete_xalign = 1
		pete_rgtimg.style.top = Math.floor(Math.random() * (screen.height - 40)) + 'px'
	}
	pete_xspeed = Math.floor(Math.random() * pete_movmax)
	pete_shwmov = window.setInterval(show_move, pete_xspeed)
}

function show_move()
{
	if (pete_xcoord < 0)
	{
		pete_xcoord += 1
		if (pete_xalign == 0)
			pete_lftimg.style.left = pete_xcoord + 'px'
		else
			pete_rgtimg.style.right = pete_xcoord + 'px'
	}
	else
	{
		window.clearInterval(pete_shwmov)
		pete_hidbeg = window.setTimeout(hide_begin, Math.floor(Math.random() * pete_shwmax))
	}
}

function hide_begin()
{
	pete_hidmov = window.setInterval(hide_move, pete_xspeed)
}

function hide_move()
{
	if (pete_xcoord > -24)
	{
		pete_xcoord -= 1
		if (pete_xalign == 0)
			pete_lftimg.style.left = pete_xcoord + 'px'
		else
			pete_rgtimg.style.right = pete_xcoord + 'px'
	}
	else
	{
		window.clearInterval(pete_hidmov)
		pete_shwbeg = window.setTimeout(show_begin, Math.floor(Math.random() * pete_hidmax))
	}
}

Download the script here.