// tabsize: 3
// Zombie and Mummy Banner

// low-ambitious browser detection ....
// netscape 4 has got to go
var zombieandmummy_dom = (document.getElementById)
var zombieandmummy_ie = (document.all)
var zombieandmummy_opera = (navigator.userAgent.indexOf("Opera")>-1)


var zombieandmummy_obj						// cross-browser dhtml-object
var zombieandmummy_direction = 1			// moving direction of zombie and mummy
var zombieandmummy_pos = -124				// initial position: outside
var zombieandmummy_dir = "left"			// default direction: they sit at left win border
var zombieandmummy_otherdir = "top"		// this is the other axis
var zombieandmummy_otherpos = 0			// offset in the non-moving direction

if(zombieandmummy_zufall(100)>49)		// by 50% chance they sit at the
	{												// top window border
	zombieandmummy_dir = "top"
	zombieandmummy_otherdir = "left"
	}


if(zombieandmummy_ie || zombieandmummy_opera || zombieandmummy_dom)	// if fitting browser is here
	{

	zombieandmummy_otherpos = zombieandmummy_zufall(300)					// generate the stable offset

	document.write																		// generate dhtml tags
		(
		'<div id="zombieandmummytop" style="position:absolute;', 
		zombieandmummy_dir, ':-124px;', zombieandmummy_otherdir, ':', zombieandmummy_otherpos, 'px;">',
		'<a href="http://www.zombie-and-mummy.org/" title="Fresh entertainment for our networked society!" target="_blank">',
		'<img src="http://www.zombie-and-mummy.org/banner_', zombieandmummy_dir, '.gif" border="0" alt="Z&amp;M"></a>',
		'</div>'
		)
	
	if(zombieandmummy_ie)															// depending on browser
		{																					// different object references
		zombieandmummy_obj = document.all.zombieandmummytop.style		// are needed
		}
	else
		{
		zombieandmummy_obj = document.getElementById("zombieandmummytop").style
		}
	
	setInterval("zombieandmummy_display()", 50)										// 20 times per second 
																									// position update.
	setTimeout("zombieandmummy_move()",(zombieandmummy_zufall(7)+2)*1000)	// after some time they 
																									// start to move.
	}


// _display makes zombie and mummy always reside at the Window's border
function zombieandmummy_display()
	{
	
	var zombieandmummy_x_offset					// distance from left window border
	var zombieandmummy_y_offset					// distance from top window border

	if(zombieandmummy_ie && (!zombieandmummy_opera))			// find offsets
		{																		// (browser dependant)
		zombieandmummy_y_offset = document.body.scrollTop
		zombieandmummy_x_offset = document.body.scrollLeft
		}
	else
		{
		zombieandmummy_y_offset = pageYOffset
		zombieandmummy_x_offset = pageXOffset
		}
		
	
	if(zombieandmummy_dir == "top")
		{
		zombieandmummy_obj.top	= (zombieandmummy_pos + zombieandmummy_y_offset) + "px"
		zombieandmummy_obj.left	= (zombieandmummy_otherpos + zombieandmummy_x_offset) + "px"
		}
	else
		{
		zombieandmummy_obj.top	= (zombieandmummy_otherpos + zombieandmummy_y_offset) + "px"
		zombieandmummy_obj.left	= (zombieandmummy_pos + zombieandmummy_x_offset) + "px"
		}
	}


// zombie and mummy are appearing/disappearing
function zombieandmummy_move()
	{
	zombieandmummy_pos +=  zombieandmummy_direction									// add movement to
																									// current position
	
	if(zombieandmummy_pos == 0)															// if they are completely
		{																							// visible
		zombieandmummy_direction = -18													// reverse the movement
		setTimeout("zombieandmummy_move()", zombieandmummy_zufall(4)*1000)	// direction after some time
		}
	else if(zombieandmummy_pos <= -124)													// also reverse direction
		{																							// if they are completely
		zombieandmummy_direction = 1														// invisible. change position
		zombieandmummy_otherpos = zombieandmummy_zufall(300)						// as well
		setTimeout("zombieandmummy_move()", zombieandmummy_zufall(5)*1000)
		}
	else																							// in between: just move
		{
		setTimeout("zombieandmummy_move()", 50)
		}
	}





// return random number between 1 and n
function zombieandmummy_zufall(n)
	{
	return Math.round(Math.random()*n)+1
	}