//slide in script voor Umbraco

ie=document.all?1:0
n=document.layers?1:0
calunits=document.layers? "" : "px"
ns6=document.getElementById&&!document.all?1:0

//These are the variables you have to set:
//How much of the layer do you wan't to be visible when it's in the out state?
lshow=10
lshow2=70

//How many pixels should it move every step? 
var move=10;

//At what speed (in milliseconds, lower value is more speed)
menuSpeed=10

//Do you want it to move with the page if the user scroll the page?
var moveOnScroll=true

//You should't have to change anything below this.
//Defining variables

var ltop;
var maxwidth;
var tim=0;

//Object constructor
function makeMenu(obj,nest){

try
{
	nest=(!nest) ? '':'document.'+nest+'.'
    if (n) this.css=eval(nest+'document.'+obj)
    else if (ns6) this.css=document.getElementById(obj).style
    else if (ie) this.css=eval(obj+'.style')						
	this.state=1
	this.go=0
        if (n) this.width=this.css.document.width
        else if (ns6) this.width=document.getElementById(obj).offsetWidth
        else if (ie) this.width=eval(obj+'.offsetWidth')
	this.right=b_getleft
	this.width=b_getWidth
    this.obj = obj + "Object"; 	eval(this.obj + "=this")	
}
catch(err)
{}
}
//Get's the top position.
function b_getleft(){
        if (n||ns6){ gleft=parseInt(this.css.right)}
        else if (ie){ gleft=eval(this.css.pixelRight)}
	return gleft;
}

//Get's the top position.
function b_getWidth(){
        if (n||ns6){ gWidth=parseInt(this.css.width)}
        else if (ie){ gWidth=eval(this.css.pixelWidth )}
	return gWidth;					   
}
/***********************************
Deciding what way to move the menu (this is called onmouseover, onmouseout or onclick)
************************************/
function moveMenu(){
	if(!oMenu.state){
		clearTimeout(tim)
		mIn()	
	}else{
		clearTimeout(tim)
		mOut()
	}
}

function menuOut(){
	if(oMenu.state){
		clearTimeout(tim)
		mOut()
	}
}

function menuIn(){
	if(!oMenu.state){
		clearTimeout(tim)
		mIn()
	}
}

//Menu in
function mIn(){
	if(oMenu.right() > 0){
		oMenu.go=1
	oMenu.css.right=oMenu.right()-move+calunits
	
		tim=setTimeout("mIn()",menuSpeed)
	}else if(oMenu.width()>lshow)
	{
		oMenu.css.width = oMenu.width()-10+calunits;
	
			tim=setTimeout("mIn()",menuSpeed)
	}
	
	else{
		oMenu.go=0
		oMenu.state=1

	}	
}
//Menu out
function mOut(){


	if(oMenu.width()<maxWidth){
		oMenu.go=1
		
oMenu.css.width = oMenu.width() +10+calunits;
		tim=setTimeout("mOut()",menuSpeed)
	}else if(oMenu.right() < lshow2)
	{
	oMenu.css.right=oMenu.right()+move+calunits
	tim=setTimeout("mOut()",menuSpeed)
	}
	
	else{

		oMenu.go=0
		oMenu.state=0
	}	
}
/*********************************
Checking if the page is scrolled, if it is move the menu after
**********************************/
function checkScrolled(){
	if(!oMenu.go) oMenu.css.top=eval(scrolled)+parseInt(ltop)
	if(n||ns6) setTimeout('checkScrolled()',30)
}
/*********************************
Inits the page, makes the menu object, moves it to the right place, 
show it
**********************************/
function menuInit(){
	try
	{
	oMenu=new makeMenu('divMenu')
        if (n||ns6) scrolled="window.pageYOffset"
        else if (ie) scrolled="document.body.scrollTop"

	maxWidth=oMenu.width();
	oMenu.css.width=lshow+calunits

        if (n||ns6) ltop=oMenu.css.top
        else if (ie) ltop=oMenu.css.pixelTop
	oMenu.css.visibility='visible'
	if(moveOnScroll) ie?window.onscroll=checkScrolled:checkScrolled();
	}
	catch(err)
	{}
}

//Initing menu on pageload
window.onload=menuInit;
