var posscrlldv = 0;
var flagthisison = 1;
var moveboekdicht = 5;
var fadeinbookind = 10;
var posscrlldv = 0;

var kreuk;
var proph;
var sluitsw;
var scrlltdwn;
var scrlltup;
var smlistblock;
var cntscllt;
var menufuck;
var geweikrab;
var boekdicht;
var boek;
var boekind;
var handje;
var blogind;
var kreuktxt;
var iframer;

var mywidth = 0;
var myheight = 0;


function startswitchpaper()	{

// Declare variables GOLBAL!

kreuk=document.getElementById("kreukvel");
proph=document.getElementById("propholder");
sluitsw=document.getElementById("sluitswitch");
scrlltdwn=document.getElementById("scrollitdown");
scrlltup=document.getElementById("scrollitup");
smlistblock = document.getElementById("smlist");
cntscllt=document.getElementById("scrlldv");
menufuck = document.getElementById("menuffkrab");
geweikrab=document.getElementById("gewei2");
boekdicht=document.getElementById("boekdicht");
boek=document.getElementById("boek");
boekind=document.getElementById("boekindex");
handje=document.getElementById("hand");
blogind = document.getElementById("blogtitels");


kreuktxt=document.getElementById("showpane");
iframer= document.getElementById("blogpager");


//////////////////////////////////////////////////////////////////////////////////////////////////////////

getsizeofwindow();

/////////////////////////////////////////////////////////////////////////////////////////////////////////

//Get the list of artickle links;
var theentrylinks = document.getElementById("smlist").getElementsByTagName("a");
// Onclick make the index fade away, and the artickle fade in.
for(i=0; i<theentrylinks.length; i++)	{
theentrylinks[i].onclick=function(){
showitnow();
	}
}


// Make sure the propholder is visible, to be able to trigger events.
if(proph)	{
proph.style.display = "block";
proph.onclick = function(){ 
stepone();
	}
}


if(scrlltdwn)	{
scrlltdwn.onmouseover = function()	{
scrollit(smlistblock, "d");
	}
scrlltdwn.onmouseout = function()	{
scrollit(smlistblock, "stop");
	}
}

if(scrlltup)	{
scrlltup.onmouseover = function()	{
scrollit(smlistblock, "up");
	}
scrlltup.onmouseout = function()	{
scrollit(smlistblock, "stop");
	}
}

if(sluitsw)	{
sluitsw.onclick = function()	{
scrlltdwn.style.display = "none";
scrlltup.style.display = "none";
sluitsw.style.display = "none";
blogind.style.display = "none";
kreuk.style.display = "none";
boekdicht.style.bottom = "50000px";
setopacity(boekind, 0);
setopacity(menufuck, 0);
setopacity(geweikrab, 0);
proph.style.display = "block";
moveopacity(proph, 0, 100, 50, 10);
scrollit(smlistblock, "reset");
	}
}



if(geweikrab)	{
geweikrab.style.display = "block";
geweikrab.style.opacity = "0";
geweikrab.style.MozOpacity = "0";
geweikrab.style.khtmlOpacity = "0";
geweikrab.style.filter = "alpha(opacity = 0 )"; 
}
	
if(menufuck)	{
menufuck.style.display = "block";
menufuck.style.opacity = "0";
menufuck.style.MozOpacity = "0";
menufuck.style.khtmlOpacity = "0";
menufuck.style.filter = "alpha(opacity = 0 )"; 
}	


if(boekind)	{
boekind.style.display = "block";
boekind.style.opacity = "0";
boekind.style.MozOpacity = "0";
boekind.style.khtmlOpacity = "0";
boekind.style.filter = "alpha(opacity = 0 )"; 	
	
	}
	
if(iframer)	{
iframer.style.display = "none";
	}
	
if(handje)	{
handje.onclick =  function()	{
frames['blogpage'].location.href = "blog/bin/hourglass.html";
iframer.style.display = "none";
handje.style.display  = "none";
scrlltdwn.style.display = "block";
scrlltup.style.display = "block";
sluitsw.style.display = "block";

		}
	}	
	
}
///////////////////////


function stepone()	{

var flagstepone = 0;

//This functions function is to hide the menu and antlers, and to present te Log-book.
moveopacity(proph, 100, 0, 50, 10)
moveopacity(menufuck, 0, 100, 100, 10);
moveopacity(geweikrab, 0, 100, 100, 10);

stepone.eventtriggertimer = window.setInterval(

function()	{

if( flagstepone === 0 )	{

if( geweikrab.style.opacity == 1 )	{

moveit2(boekdicht,"bottomdown",myheight,25,5,50);

flagstepone++;
			}
		}
	
if( flagstepone === 1 )	{

if( boekdicht.style.bottom.replace(/px/,"") < 30 && boekdicht.style.bottom.replace(/px/,"") > 15)	{

proph.style.display = "none";
kreuk.style.display = "block";
blogind.style.display = "block";
moveopacity(boekind, 0, 100, 100, 10);
flagstepone++;

		}
	}
	
if( flagstepone === 2 && boekind.style.opacity > 0.5)	{

boekdicht.style.display = "none";
scrlltdwn.style.display = "block";
scrlltup.style.display = "block";
sluitsw.style.display = "block";


window.clearInterval(stepone.eventtriggertimer);
	
	}
}
	
, 100);

}


function showitnow()	{

iframer.style.display = "block";
handje.style.display = "block";
scrlltdwn.style.display = "none";
scrlltup.style.display = "none";
sluitsw.style.display = "none";
	}

function scrollit(obj, direction)	{

if(obj.Scrolltimer) window.clearInterval(obj.Scrolltimer);

if(direction !=="stop"){
obj.Scrolltimer= window.setInterval(
function(){


if(direction == "d"){
posscrlldv -= 5;
//alert("down scroll asked");

}
if(direction == "up"){
//alert("up scroll asked");
posscrlldv += 5;
	}
if(direction == "reset" || posscrlldv > 0)	{
window.clearInterval(obj.Scrolltimer);
posscrlldv = 0;
	}
obj.style.top=posscrlldv+"px";
}
, 20);
	}
	
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

// This code block takes care of the opacity of elements indicated by  "ID" 
// It consists of functions:
// Moveopacity
// Setopacity

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////

function moveopacity(id, itsopacity, endopacity, speed, step)	{

var i = 0;
i = itsopacity;
	if(id.Opacitytimer)	{
window.clearInterval(id.Opacitytimer);
}

if(itsopacity > 100 )	{
itsopacity = (itsopacity / 100 );
	}

if(  itsopacity < endopacity )	{

id.Opacitytimer = window.setInterval(

function(){
	setopacity(id,i);
		i += step;
				if( i >= endopacity )	{
			if(endopacity == 100)	{
			setopacity(id,100);}
window.clearInterval(id.Opacitytimer);
					}
			}
	, speed );
	}
if( itsopacity > endopacity )	{

id.Opacitytimer = window.setInterval(

function(){

	setopacity(id, i);
		i -= step;
				if( i <= endopacity )	{
			if(endopacity == 0)	{
			
			setopacity(id, 0);	}
			
window.clearInterval(id.Opacitytimer);
					}
				}
		, speed );
	}
}

function setopacity(id, opacity)	{
var obj = id.style;
obj.opacity = (opacity / 100);
obj.MozOpacity = (opacity / 100);
obj.khtmlOpacity = (opacity / 100);
obj.filter = "alpha(opacity=" + opacity  + ")"; 
}


// End of sector Opacity functions
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// This function returns the height and widht of the window/document.

function getsizeofwindow()	{

//Check for Innerwidth, as in non IE browsers
if( typeof(window.innerWidth) == 'number' )	{
mywidth = window.innerWidth;
myheight = window.innerHeight;

	}
else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight ))	{
mywidth = document.documentElement.clientWidth;
myheight = document.documentElement.clientHeight;
		}
		
	}

/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
function moveit2(id,dir,start,end,step,speed)	{

if(id.Movetwo) window.clearInterval(id.Movetwo);
	
var pos = start;
var sp = speed;
var st =step;
var x = end - start;
var y = start - end;
var str = 1;
var delayup = 0;
var flagversnel = 1;
// Begin recurring loop here:

id.Movetwo = window.setInterval(
function()	{
switch (dir)	{
case "bottomdown": {

if( start == pos) {
id.style.display="block";
	}

	if(flagversnel > 0)	{	
if(start > (pos - (y/2)))	{
step +=2;
	}
	
if(start < (pos - (y/2)))	{
step -= 2;
	}
	
if(step == st){
flagversnel = 0;
	}
	
}	

if(start < (end + (y/14)))	{
step -= 1;
	}
	
if(step < 1){ step = 1;}
start -= step;
id.style.bottom = start+"px";

if(start < end)	{
	window.clearInterval(id.Movetwo);
	//alert(id.style.bottom);
		}
break;
	}

		
default: alert("Het menu heeft een script fout. Herlaad de pagina");
	}
}
, speed)
}
// End of function moveittwo;


