function getWinInnerDim(win){
	var x,y;
	if (win.innerHeight){ // all except Explorer
		x = win.innerWidth;
		y = win.innerHeight;
	}else if (win.document.documentElement && win.document.documentElement.clientHeight){
		// Explorer 6 Strict Mode
		x = win.document.documentElement.clientWidth;
		y = win.document.documentElement.clientHeight;
	}else if (win.document.body){ // other Explorers
		x = win.document.body.clientWidth;
		y = win.document.body.clientHeight;
	}
	return [x,y];
}

function getWinScrollOffset(win){
	var x,y;
	if (win.pageYOffset){ // all except Explorer
		x = win.pageXOffset;
		y = win.pageYOffset;
	}else if (win.document.documentElement && win.document.documentElement.scrollTop){
		// Explorer 6 Strict
		x = win.document.documentElement.scrollLeft;
		y = win.document.documentElement.scrollTop;
	}else if (win.document.body){ // all other Explorers
		x = win.document.body.scrollLeft;
		y = win.document.body.scrollTop;
	}
	return [x,y];
}

function setWinScrollOffset(win,x,y){
	if (win.pageYOffset){ // all except Explorer
		win.pageXOffset = x;
		win.pageYOffset = y;
	}else if (win.document.documentElement && win.document.documentElement.scrollTop){
		// Explorer 6 Strict
		win.document.documentElement.scrollLeft = x;
		win.document.documentElement.scrollTop = y;
	}else if (win.document.body){ // all other Explorers
		win.document.body.scrollLeft = x;
		win.document.body.scrollTop = y;
	}
}

function getWinPageDim(win){
	var x,y;
	var test1 = win.document.body.scrollHeight;
	var test2 = win.document.body.offsetHeight
	if (test1 > test2){ // all but Explorer Mac
		x = win.document.body.scrollWidth;
		y = win.document.body.scrollHeight;
	}else{ // Explorer Mac;
		 //would also work in Explorer 6 Strict, Mozilla and Safari
		x = win.document.body.offsetWidth;
		y = win.document.body.offsetHeight;
	}
	return [x,y];
}

var winAnimArray=new Array();

function winScrollToLoop(win,MaxSteps,StepTime,StepCounter){
	if(!win) win=self;
	if(!StepCounter) StepCounter=1;
	win.scrollBy(winAnimArray[StepCounter][0],winAnimArray[StepCounter][1]);
	StepCounter++;
	if(StepCounter<=MaxSteps) 
		//winScrollToLoop(win,MaxSteps,StepTime,Rest,StepCounter);
		win.setTimeout('winScrollToLoop(null,'+MaxSteps+','+StepTime+','+StepCounter+');', StepTime);
}

function winScrollToBottom(win){
	if(!win) win=self;
	var Pwh=getWinPageDim(win);
	var Iwh=getWinInnerDim(win);
	var Sco=getWinScrollOffset(win);
	var Rest=new Array();
	Rest[0]=Rest[2]=Pwh[0]-(Sco[0]+Iwh[0])+18;
	Rest[1]=Rest[3]=Pwh[1]-(Sco[1]+Iwh[1])+18;
	var Steps=20;
	var StepTime=25; 	//ms
	
	var MaxFaktor=-Math.log(Math.E*(1/Steps))+1;
	
	var xToGo1=Rest[0];
	var yToGo1=Rest[1];
	
	for(var StepCounter=1;StepCounter<=Steps;StepCounter++){
		var Faktor=-Math.log(Math.E*(StepCounter/Steps))+1;
		var FPercent=Faktor/MaxFaktor;
		
		winAnimArray[StepCounter]=new Array();
		
		var xToGo2=FPercent*Rest[0];
		winAnimArray[StepCounter][0]=xToGo1+xToGo2;
		xToGo1=xToGo2;

		var yToGo2=FPercent*Rest[1];
		winAnimArray[StepCounter][1]=yToGo1-yToGo2;
		yToGo1=yToGo2;
		
	}
	winScrollToLoop(null,Steps,StepTime)
}





