/**
 * @author EP
 */



var Controller = Class.create({
    initialize: function(){
		var arr = $$('li.productGroep');
        for (var index = 0, len = arr.length; index < len; ++index) {
			var item = arr[index];
			var func = this.displayChildren.bind(this, item.id);
			$(item.id).observe('click', func, true);
		} 
    },
	
	displayChildren: function(li){
		$(li+'_div').show();
		var func = this.hideChildren.bind(this, li);
		$(li).observe('click', func, false);
	},
	
	hideChildren: function(li){
		$(li+'_div').hide();	
		var func = this.displayChildren.bind(this, li);		
		$(li).observe('click', func, false);
	}
    
});

var overlayDiv = {
    build: function(){
        this.createOverlay();
        if (!document.getElementById("floatDiv")) {
            var h = document.createElement('div');
            h.id = 'floatWrap';
            document.body.appendChild(h);
            
            var y = document.createElement('div');
            y.id = 'floatDiv';
            h.appendChild(y);
        }
    },
    createOverlay: function(){
        if (!document.getElementById('overlay')) {
            var x = document.createElement('div');
            x.id = 'overlay';
            document.body.appendChild(x);
        }
    },
    close: function(){
        if (document.getElementById('overlay')) {
            document.body.removeChild(document.getElementById('overlay'));
        }
        if (document.getElementById('floatWrap')) {
            document.body.removeChild(document.getElementById('floatWrap'));
        }
        if ($('floatDiv')) {
            $('floatDiv').hide();
        }
    }
};
Event.onDOMReady(function(){
    controller = new Controller();
});

