var active	=	new Array();
var images	=	new Array();
var divs	=	new Array();
var i_tabs	=	0;
var container	=	"";

function Tab(){

	container	=	document.getElementById('container');
	
	var imgs	=	document.getElementsByTagName("img");
	
	for(var i = 0; i < imgs.length; i++){
	
		if(tab = imgs[i].getAttribute("tab")){
		
			this.add(imgs[i]);
		
		}
	
	}

}

Tab.prototype.add		=	function(img){

	active[i_tabs]		=	0;
	
	images[i_tabs]		=	img;
	
	divs[i_tabs]		=	document.getElementById(img.getAttribute("tab"));
	
	var tab			=	i_tabs;
	
	img.onclick		=	function(){ Tab.prototype.switch_tab(tab) }
	
	if(i_tabs == 0){
		
		Tab.prototype.make_active(tab);
		
	}
	
	i_tabs++;
	
}

Tab.prototype.switch_tab	=	function(tab){
	
	if(active[tab] != 1){
		
		for(var i = 0; i < images.length; i++){
		
			if(active[i] == 1){
				
				Tab.prototype.make_inactive(i);
			
			}
		
		}
		
		Tab.prototype.make_active(tab);
		
	}

}

Tab.prototype.make_active	=	function(tab){
	
	if(tab == 3){
		if(document.getElementById('maps_iframe')){
			document.getElementById('maps_iframe').src	=	document.getElementById('maps_iframe').getAttribute('kaart');
		}
		
	}
	
	var image			=	images[tab].src;
	var new_image			=	image.replace("_on", "");
	
	images[tab].src			=	new_image;
	
	var height			=	divs[tab].offsetHeight;
	
	container.style.height		=	height+"px";
	
	divs[tab].style.visibility	=	"visible";
	
	active[tab]			=	1;
	
}

Tab.prototype.make_inactive	=	function(tab){

	var image			=	images[tab].src;
	var new_image			=	image.replace(".png", "_on.png");
		
	images[tab].src			=	new_image;
	
	divs[tab].style.visibility	=	"hidden";
			
	active[tab]			=	0;
	
}

