var ie = (document.all)																		// browser detection by feature
var ns = (document.layers)
var opera = (navigator.userAgent.indexOf("Opera")>-1)								// only opera needs to be detected by name, as it emulates other features.
var dom = (document.getElementById)														// Gecko based

var steps = 24																				// number of steps for each scrolling action

var x = 0																						// scroll position of the user
var y = 0
var width = 0																					//	width of document area in window
var height = 0																					// height of document area in window
var animationtimer = 0																		// pointer to interval, needed for detecting if scrolling already going on
var steplist = new Array()																	// timeline with xy coordinate pairs
var animationstep = 0																		// the current position in this timeline

function teleport(xgoal, ygoal)																// this function calculates the steps from the current
	{
	get_position()
	// position to the desired position.
	steplist = new Array()																	// initialize new animation coordinate timeline
	animationstep = 0																			// and set pointer to its start

	xgoal = xgoal-(width/2)
	xd = (xgoal-x) / steps																	// each frame of the timeline the scrolling moves by
	yd = (ygoal-y) / steps																	// xd and yd pixels
	
	for( i=0; i<steps ;i++)																	// x and y coordinates are put together into
		{																							// the timeline array. values are rounded to
		steplist[i*2] = Math.round(x + (xd*i))											// integer coz they are pixel values
		steplist[(i*2)+1] = Math.round(y + (yd*i))
		}
	
	steplist[steps*2] = xgoal																// because of rounding errors and not scrollbars taking away
	steplist[(steps*2)+1] = ygoal															// screenspace, the last set of coordinates set to the goal 
																									// position, just to make sure.

	animationtimer = setInterval("swoosh()",100)										// start the scrolling!

	return false
	}


function swoosh()																				// scrolling going on
	{
	if(animationstep < steplist.length)													// animation pointer should be in steplist still
		{
		scrollTo(steplist[animationstep],steplist[animationstep+1])				// scroll to this steplist position
		animationstep += 2																	// and move forward in list
		}																							// move 2 because of x and y are in same
	else																							// array
		{
		clearInterval(animationtimer)														// if list is over and goal is reached
		animationstep = 0																		// stop animation and reset pointer in
		
		saveposition()
		}																							// timeline
	}

function saveposition()																		// when user leaves page, the coordinates must be saved
	{																								// and restored when user returns. coz browsers only save
	get_position()																				// position of vertical scrollbar. to spare cookies and
	savestring = "K0A1AX" + x + "Y" + y									// sessions, the coordinates are just saved in the window
	this.name = savestring																	// name, together with the id "K0A1A". this is
	}																								// is of course not perfect, but good enough

function restoreposition()																	// position is restored from the window name
	{
	var x = 0																					// scroll to x=0 as default
	var y = 0																					// scroll to y=0 as default
	params = this.name
	if(params.indexOf("K0A1A")>-1)											// is there the "K0A1A" id?
		{																							// extract saved coordinates
		x = parseInt(params.substring((params.indexOf("X")+1), params.indexOf("Y")))
		y = parseInt(params.substring((params.indexOf("Y")+1), params.length))
		}
	scrollTo(x,y)
	}

function get_position()																		// size of window and position of scrollbars is captured.
	{																								// name of this properties are different in the different
	if(ie && (!opera))																		// browsers
		{
		width = document.body.offsetWidth
		height = document.body.offsetHeight+16											// +16 coz explorer doesn't care about scrollbar size

		x = document.body.scrollLeft
		y = document.body.scrollTop
		}
	else
		{
		width = innerWidth+16																// +16 and +20 for mozilla coz again scrollbars are not
		height = innerHeight+20																// taken into account correctly

		x = pageXOffset
		y = pageYOffset
		}
	}

// -----------------------------------------------------------------------    INIT FUNCTION

function init()																				// things that happen right at the start:
	{
	restoreposition()																			// restore the old scrollbar-status
	}