﻿var LocatieKaart = Class.create({
    initialize: function(){
        this.prepMapPoints();
        this.hideProvincieSubItems();
        this.prepProvincieItems();
    },
    
    prepMapPoints: function(){
        $$(".mapLink").each(function(point){
            new Tip(point.id, point.next().innerHTML, {
                className: "vestiging",
				hideAfter: 0.5,
                hideOn: false,                
				delay: 0
            });
        })
    },
    
    prepProvincieItems: function(){
        $$("#provincies ul li a").each(function(provincie){
            Event.observe(provincie, "click", this.showProvincieSubItems.bindAsEventListener(this), false);
        }.bind(this))
    },
    
    hideProvincieSubItems: function(){
        $$("#provincies ul li ul").each(function(list){
            list.hide();
        })
    },
    
    showProvincieSubItems: function(e){
        if (Event.element(e).next()) {
            this.hideProvincieSubItems();
            Event.element(e).next().show();
            Event.stop(e);
        }
        
    }
});

document.observe('dom:loaded', function(){
    new LocatieKaart();
});

