// Sub-menu (sliders) javascript

Huurders = new Button('Huurders')
Aanbod = new Button('Aanbod')
Organisatie = new Button('Organisatie')
Beheer = new Button('Beheer')
Mijngegevens = new Button('Mijngegevens')

function Button(id)
{
    this.id = id
    this.Moving = false
    this.steps = 14
    this.step = 0

    this.Open = function()
    {
        this.Direction = 1
        if (this.Moving) return
        this.Moving = true
        this.Loop()
    }

    this.Close = function()
    {
        this.Direction = -1
        if (this.Moving) return
        this.Loop()
    }

    this.Loop = function()
    {
        this.step += this.Direction
        if (this.step > this.steps) this.step = this.steps
        if (this.step < 0) this.step = 0
        this.SetDiv(this.step/this.steps)
        if (this.step > 0 && this.step < this.steps)
        {
            setTimeout(this.id + ".Loop()", 10)
        }
        else
        {
            this.Moving = false
        }
    }

    this.SetDiv = function(factor)
    {
        factor = (.5 - Math.cos(factor * Math.PI) * .5);
        var hoogte = 40 + factor * 85;
        var mytop = .3 - factor * .3;
        var mywidth = factor * 15;
        document.getElementById(id+'Content').style.height = hoogte + 'px';
        document.getElementById(id+'Button').style.height = hoogte + 'px';
    }
}

/* timerfuncties voor het bedienen van het dropdown menu
 Berend Vervelde
 9-12-2008
de tijd wordt gezet in de menu.xsl 
*/ 
var vertraging;
function setTimer(tijd) {
	vertraging = window.setTimeout(hideMenu, tijd);
}

function hideMenu() {
	document.getElementById('submenuItems').style.visibility='hidden'
}
function showMenu() {
	window.clearTimeout(vertraging);
	document.getElementById('submenuItems').style.visibility='visible'
}

function clearTimer() {
	window.clearTimeout(vertraging);
}
