var timeout=50;
var iStep = 1;
var Top, Height, parentHeight;

var divS

function StartScroller()
{
	var divParent = document.getElementById("guestbook_middle")
	parentHeight = divParent.offsetHeight;
	divS = document.getElementById("scroller")
	Height = divS.offsetHeight;
	Top = GetScrollerPos();
	//Top = divS.style.top;
	if(Top==999999 || isNaN(Top))
		Top = divS.style.top + parentHeight;
	//window.status=Top;
	divS.style.top = Top;
	window.setTimeout("ScrollGuestbook()",timeout);
	divS.style.display = "block";
}

function ScrollGuestbook() 
{
	if(Height==0) Height = divS.offsetHeight;
	Top = Top - iStep;
	divS.style.top = Top;
	if(Top + Height < 0)
		Top = parentHeight;
	//
	if(Top>Height+50)
		Top=Height+50;
	//window.status="Top: "+Top+" ("+Height+")";
	window.setTimeout("ScrollGuestbook()",timeout);
}

function SaveScrollerPos()
{
	//alert("Bewaren="+(Top*-1));
	if(isNaN(Top))
		createCookie('ScrollerPos',999999,5000);
	else
		createCookie('ScrollerPos',Top*-1,5000);
}

function GetScrollerPos()
{
	var pos;
	var tmp = ""+readCookie('ScrollerPos');
	if(tmp=="" || tmp=="NaN" || isNaN(tmp))
		pos=Height;
	else
		pos = parseInt(tmp)*-1;
	//alert("Lezen:  "+pos);
	return pos;
}

function createCookie(name,value,minutes)
{
	if (minutes)
	{
		var date = new Date();
		date.setTime(date.getTime()+(minutes*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else 
		var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	//alert(document.cookie);
}

function readCookie(name)
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name)
{
	createCookie(name,"",-1);
}