  
        function onShowboxContact(o){
        
        }
        
        function onShowboxContactKaart(o){
        infowindow.open(map,marker);
        google.maps.event.trigger(map, 'resize');
        map.setCenter(latlng_map);        
        }

        (function($) {
        	$.fn.closestChildren = function(selector) {
        		// breadth first search for the first matched node
        		if (selector && selector != '') {
        			var store = [];
                    var queue = [];
        			queue.push(this);
        			while(queue.length > 0) {
        				var node = queue.shift();
        				var children = node.children();
        				for(var i = 0; i < children.length; ++i) {
        					var child = $(children[i]);
        					if (child.is(selector)) {
        						store.push(child); //well, we found one
        					}
        					queue.push(child);
        				}
        			}
        			return store; // return all
        		}
        		return $(); //nothing found
        	};
        })(jQuery); 
        
        (function($) {
        	$.fn.closestChild = function(selector) {
        		// breadth first search for the first matched node
        		if (selector && selector != '') {
        			var queue = [];
        			queue.push(this);
        			while(queue.length > 0) {
        				var node = queue.shift();
        				var children = node.children();
        				for(var i = 0; i < children.length; ++i) {
        					var child = $(children[i]);
        					if (child.is(selector)) {
        						return child; //well, we found one
        					}
        					queue.push(child);
        				}
        			}
        		}
        		return $();//nothing found
        	};
        })(jQuery);
        
        (function($) {
        	$.fn.ucfirst = function() {
                
                var x = this.selector.split(/\s+/g);
                
                for (var i = 0; i < x.length; i++) {
                
                    // Splits the word into two parts. One part being the first letter,
                    // second being the rest of the word.
                    var parts = x[i].match(/(\w)(\w*)/);
                
                    // Put it back together but uppercase the first letter and
                    // lowercase the rest of the word.
                    x[i] = parts[1].toUpperCase() + parts[2].toLowerCase();
                    
                }
                
                return x.join(' ');
            };
        })(jQuery);
        
    // assign a showbox to a ul containing all scenes as li
    var oShowbox;
    
    $(document).ready(function() {
    
        $('#lagevuursche-showbox').css("max-height", ($(window).height() - 140) + 'px');
        $('#container').height($(window).height() - 240);

        
        $(window).resize(function() {
              
            $('#container').height($(window).height() - 240);
            $('#lagevuursche-showbox').css("max-height", ($(window).height() - 140) + 'px');
        });

        
        if(window.location.hash == "") window.location.hash = "#nieuws/no-bericht";
        
        oShowbox = new Showbox('lagevuursche-showbox');
        oShowbox.setupScenes();
        pulseShowbox();
        setInterval('pulseShowbox()', 100);
    });
    
    function pulseShowbox(){
        
        // updating the hash with active subscenes not included in the hash
        // usefull for measuring height & updating buttons
        if(oShowbox.finishHash() != "") window.location = window.location.hash + oShowbox.finishHash();
        
        if(oShowbox.newHash()){
           
           // returns an array with scene objects
           if(!oShowbox.validateRequest()) return "Invalid request";
           
           var aScenes = oShowbox.getScenes();
           var animating = false;
                
           if(oShowbox.firstLoop()) {
           oShowbox.setAnimationSpeed(0);
           } else {
           oShowbox.setAnimationSpeed(400);
           }
                
           for(var i in aScenes)
           {
               var oScene = aScenes[i];
                
               // staring with first scene
               // if its a new scene it will animate and the nested scenes will automaticly update
               if(oScene.isActive() && !animating){
                   
                   animating = true;
                   
                   var oActiveSibling = oScene.getActiveSibling();
                   
                   if(oScene.getIndex() > oActiveSibling.getIndex()){
                   
                       oScene.animateIn('left');
                       oActiveSibling.animateOut('left');
                   } else {
                               
                       oScene.animateIn('right');
                       oActiveSibling.animateOut('right');
                   }
                   
               } else {
               
                   oScene.makeVisible();
               }
               // make active  
               oScene.makeActive();
           }
           
                       
            $('.showbox-scene.load-img-trigger.sb-active').each(function(){

                var a = $(this).children('a.img');
                
                if(a.length > 0);
                for(i = 0; i < a.length; i++){
                    var src = a.attr('href');
                    var height = a.attr('height');
                    $(this).append("<img height="+height+" src="+src+" />");
                    a.removeClass('img');
                } 
            });
           
           
           oShowbox.resize(oShowbox.getMaxHeight(aScenes));
           oShowbox.makeButtonsActive();
           oShowbox.callSceneFunctions();
        }
    }
    
    // constructor class Showbox
    
    function Showbox(id){
       
        this.dom = $('#' + id);
    }
    
        // reset method
    
        Showbox.prototype.firstLoop = function()
        {
            if(typeof this.first_loop == "undefined"){
            this.first_loop = true;
            } else {
            this.first_loop = false;
            }
            return this.first_loop;
        }
        
        // reset method
    
        Showbox.prototype.setAnimationSpeed = function(i)
        {
            this.animation_speed = i;
        }
        
        // reset method
    
        Showbox.prototype.getAnimationSpeed = function(i)
        {
            if(typeof this.animation_speed == "undefined") return 0;
            return this.animation_speed;
        }
        
        // reset method
    
        Showbox.prototype.setupScenes = function()
        {
    
           var ul = $(this.dom).parent().find('ul.showbox-scenes');
           
           // for in loop gave strange error, investigate!
           for(i = 0; i < ul.length; i++){
               var li = $(ul[i]).children('.showbox-scene');
    
               for(j = 0; j < li.length; j++){
                   
                   if(j == 0){
                       $(li[j]).css('display','block');
                       $(li[j]).addClass('sb-active');
                   } else {
                       $(li[j]).css('display','none');
                       $(li[j]).removeClass('sb-active');
                   }
               }
           }
        }
        
        // request methods
       
        Showbox.prototype.newHash = function()
        {
           if(this.hash === window.location.hash.substring(1)) return false;
           
           this.hash = window.location.hash.substring(1);
           return true;
        }
       
        Showbox.prototype.getHashArray = function()
        {
       
           return window.location.hash.substring(1).split('/');
        }
       
        // showbox validate method, check if all scenes exist
       
        Showbox.prototype.validateRequest = function(y)   
        {
    
           var ul = this.dom;
           var hash_array = this.getHashArray();
           
           for(var i in hash_array){
           
               var children = $(ul).children('li');
               
               for(j = 0; j < children.length; j++){
    
                   if($(children[j]).attr('ref') == hash_array[i]) {
                   
                   ul = $(children[j]).closestChild('ul.showbox-scenes');
                   break;
                   }
    
                   if((children.length - 1) == j) return false;
               }            
           }
           return true;
        }
       
        // generate scene objects and return in array
       
        Showbox.prototype.getScenes = function()  
        {
           var aScenes = new Array();
           var ul = this.dom;
           var hash_array = this.getHashArray();
           
           for(var i in hash_array){
           
               var children = $(ul).children();
               
               for(j = 0; j < children.length; j++){
    
                   if($(children[j]).attr('ref') == hash_array[i]) {
                   var oScene = new Scene(children[j]);
                   aScenes.push(oScene);
                   ul = $(children[j]).closestChild('ul.showbox-scenes');
                   break;
                   }
               }            
           }
           
           return aScenes;
        }
        
        // request methods
 
           
        Showbox.prototype.callSceneFunctions = function()
        {
            
            var aScenes = this.getScenes();
 
            var function_name = 'onShowbox';
            
            for(i = 0; i < aScenes.length; i++){
                
                function_name += $($(aScenes[i].dom).attr('ref')).ucfirst();
                
                if (eval("typeof " + function_name + " == 'function'")){
                var f = function_name + "('" + aScenes[i] + "');";
                eval(f);
                }                
            }
        }
        // request methods
       
        Showbox.prototype.finishHash = function()
        {
            
            var missing_hash = "";
            var aScenes = this.getScenes();
            if(aScenes.length == 0){
            var aMissingScenes = $(this.dom).closestChildren('.sb-active');
            missing_hash += "#";
            } else {
            var aMissingScenes = $(aScenes[aScenes.length - 1].dom).closestChildren('.sb-active');
            }
            
            for(i = 0; i < aMissingScenes.length; i++){
                
                missing_hash += "/" + $(aMissingScenes[i]).attr('ref');
            }
            
            return missing_hash;
        }
        
        // request methods
       
        Showbox.prototype.makeButtonsActive = function()
        {
            
            $('a').removeClass('sb-highlight');
 
            $('a').each(function(){
            
            var hash = window.location.hash;
            var pattern = new RegExp( $(this).attr('href') + "$|" + $(this).attr('href') + "\/", "gi");            
            match = pattern.exec(hash);
            
            if(match){
                $(this).addClass('sb-highlight');
            }
            });     
        }
        
        // get offset
       
        Showbox.prototype.getOffset = function()  
        {
            
            return $(this.dom).offset();            
        }
        // get height
       
        Showbox.prototype.resize = function(height)  
        {
        
          this.dom.animate({
           'height': Math.round(height) + 'px'
           }, oShowbox.getAnimationSpeed(), function() {
           });    
        }
        
        // get height
       
        Showbox.prototype.getMaxHeight = function(aScenes)  
        {
            
            var max_height = 0;
            
            for(var i in aScenes){
                
                if(aScenes[i].getMaxHeight() > max_height) max_height = aScenes[i].getMaxHeight();
            }
            
            return max_height;
                   
        }
    // constructor class Scene
    
    function Scene(dom){    
        this.dom = $(dom);      
    }
       
        // methods
       
        Scene.prototype.isActive = function()
        {
           if($(this.dom).siblings('.sb-active').length > 0) return true;
           return false;
        }
       
        Scene.prototype.getActiveSibling = function()   
        {
           return new Scene($(this.dom).siblings('.sb-active'));
        }
       
        Scene.prototype.getIndex = function()  
        {
          return $(this.dom).index();
        }
       
        Scene.prototype.setWidth = function()  
        {
            $(this.dom).css('width', ($(this.dom).parent().width() - this.getHorisontalPadding()) + 'px');
        }
        
        Scene.prototype.getHorisontalPadding = function()  
        {
            return parseInt($(this.dom).css('padding-left')) + parseInt($(this.dom).css('padding-right'));
        }
 
        Scene.prototype.animateIn = function(dir)   
        {
           var left = 0;
           var right = 0;
           var container = this.getContainer();
           
           this.setWidth();
           
           switch(dir)
           {
           default:
           case 'left':
                       
               $(this.dom).css('left', container.width() + 'px');
               $(this.dom).css('display','block');
 
               $(this.dom).animate({
               'left': '0px'
               }, oShowbox.getAnimationSpeed(), function() {
                   $(this).css('display','block');
               });
               
           break;
           case 'right':
    
               $(this.dom).css('left', container.width() - (container.width() * 2) + 'px');
               $(this.dom).css('display','block');
    
               $(this.dom).animate({
               'left': '0px'
               }, oShowbox.getAnimationSpeed(), function() {
                   $(this).css('display','block');
               });
               
           break;
           }
        }
    
        Scene.prototype.animateOut = function(dir)   
        {

           var left = 0;
           var right = 0;
           var container = this.getContainer();
            
           this.setWidth();

           switch(dir)
           {
           default:
           case 'left':
               
               left = container.width() - (container.width() * 2);
    
               $(this.dom).animate({
               'left': left + 'px'
               }, oShowbox.getAnimationSpeed(), function() {
                   $(this).css('display','none');
               });
               
           break;
           case 'right':
           
               left = container.width();
               
               $(this.dom).animate({
               'left': left + 'px'
               }, oShowbox.getAnimationSpeed(), function() {
                   $(this).css('display','none');
               });
               
           break;
           }
        }
       
        Scene.prototype.getContainer = function()   
        {
           return $(this.dom).parent();
        }
        
        Scene.prototype.getMaxHeight = function()   
        {
            
            if($(this.dom).children().length == 0){
            var text = $(this.dom).text();
            $(this.dom).html('<span class="measure-height">'+text+'</span>');
            }
            
            var max_height = 0;
            var padding_bottom = parseInt($(this.dom).css("padding-bottom"));
 
            $(this.dom).children().not('li.showbox-scene, ul.showbox-scenes').each(function(){
            
                var offset_showbox = oShowbox.getOffset();
                var offset = $(this).offset();
                
                var height  = (offset.top + $(this).outerHeight() + padding_bottom) - offset_showbox.top;
                if(height > max_height) max_height = height;
            });
 
            return max_height;
        }
 
        Scene.prototype.makeVisible = function()   
        {
           $(this.dom).css('left','0px');
           $(this.dom).css('display','block');
           $(this.dom).siblings().css('display', 'none');
        }
              
        Scene.prototype.makeActive = function()   
        {           
           $(this.dom).addClass('sb-active');
           $(this.dom).siblings().removeClass('sb-active');
        }

