
var currentTab = "radio";
$(document).ready(function(){



$(".items").each(function(i){
	
//	alert(i);
//	$(this).css("display","none");
});

$(".items").append("<div class='clear'></div>");


$(".tabs").append("<div class='clear'></div>");


setSameHeight($("#beleidsstaf .function"))
setSameHeight($("#beleidsstaf .item"))
setSameHeight($(".tab .header"))
setSameHeight($(".tab"))
$(".items").each(function(){setSameHeight($(this).children())});
jQuery.each(jQuery.browser, function(i) {
  if($.browser.version.substr(0,1) == 6){

		
		$(".tab").height(155);
		$("#beleidsstaf .item").height(155);
		$("#raad_van_toezicht .item").height(60);
  }
});



$(".email").each(function(){
	
	var mail = $(this).html();
	mail = mail.replace(/\[atsign\]/gi,'@');
	
	$(this).html('');
	
	var link = $(document.createElement('a'));
	link.html("e-mail");
	link.attr("href","mailto:"+mail)
	//link.href = "test";
	
	$(this).append(link);
});



$("#organogram_tab_content").html('test');

$(".tab").prepend("<div class='tab_border_line'></div>");



$(".tab").mousedown(function(i){ 
	
	currentTab = $(this).attr("id");
	
	setTabNormal(".tab");
	setTabHover(this);
	$("#organogram_tab_content").html("test");
	
	var html = $("#"+$(this).attr("id")+" .items").html()
	
	$("#organogram_tab_content").html(html);
	$("#organogram_tab_content .item .function").css({"font-weight":"bold"})
	$("#organogram_tab_content .item div").css({"display":"inline","margin-left":"0px"})
	$("#organogram_tab_content .item").css({"height":"auto"});
	$("#organogram_tab_content .item:odd").css("background-color","#e7eaea");
	$("#organogram_tab_content .item").each(function(i){$(this).children().each(function(j){if(j > 0){$(this).prepend(" - ");}})});
	
})

$(".tab").hover(function(){setTabHover(this);},function(){setTabNormal(this);})
	

	$(".tab:first").each(function(i){
	
		currentTab = $(this).attr("id");
		setTabHover(this);
		//$("#organogram_tab_content").html($(this).html());	
		var html = $("#"+$(this).attr("id")+" .items").html()
		$("#organogram_tab_content").html(html);
		$("#organogram_tab_content .item .function").css({"font-weight":"bold"})
		$("#organogram_tab_content .item div").css({"display":"inline","margin-left":"0px"})
		$("#organogram_tab_content .item").css("height","auto");
		$("#organogram_tab_content .item:odd").css("background-color","#e7eaea");
		$("#organogram_tab_content .item").each(function(i){$(this).children().each(function(j){if(j > 0){$(this).prepend(" - ");}})});
	});
});


function setTabHover(selector){
	
	
	$(selector).css({'background-image':"url(/static/images/style/organogram_tab_background_hover.png)","background-color":"#c2c2c2","border-color":"#97c6c0"} );	
	$("#" + $(selector).attr("id") + " > .tab_border_line").css({'background-image':"url(/static/images/style/organogram_tab_border_hover.png)"});	
}


function setTabNormal(selector){
	
	$(selector).each(function(){
		
		if($(this).attr("id") != currentTab){
			$(this).css({'background-image':"url(/static/images/style/organogram_tab_background.png)","background-color":"#cbd1d1","border-color":"transparent"});
			$("#" + $(this).attr("id") + " > .tab_border_line").css({'background-image':"url(/static/images/style/organogram_tab_border.png)"});
		
	
		
		}	
	
	})
}


function setSameHeight(selector){
	
	var currentHeight = 0;
	$(selector).each(function(){
		if(currentHeight<$(this).height()){
			
			currentHeight = $(this).height();	
		}
	});
	
	$(selector).height(currentHeight);
	$(".clear").height(0);
	$.log(currentHeight);
}
