try { DD_belatedPNG.fix("img, .png_bg"); } catch(e) {}
$(function() {
    var containers = $('.tabbable');
    $(containers).find('div:first').show();
    $(containers).find('li:first').addClass('active');
    $.each($(containers), function(i,container) {
	    $(container).find('li a').click(function(event) {
		    event.preventDefault();
		    $(container).find('> div').hide();
		    $($(this).attr('href')).show();
		    $(container).find('li').removeClass('active');
		    $(this).parent().addClass('active');
	    });
    });
    if (document.location.hash != '') {
	    $.each($('.tabbable ul li a'), function(i,n) { 
		    if($(n).attr('href') == document.location.hash) { $(n).click(); }
	    });
    }
    
    if($('#themeSwitch')) {
    	$('#themeSwitch').click(function(event) {
    		$('body').toggleClass('light');
    		var theme = 'dark'; var mail = 'light'; var themePath = '';
    		
    		if($('body').hasClass('light') == true) {
    			theme = 'light'; themePath = theme+'/'; mail = 'dark';
    		}
    		$.ajax({url: '/?theme='+theme,type:'GET', success: function(headline) { $('#themeSwitch').parent().prev().html(headline); }});
    		var logoSrc = $('#logo img').attr('src');
    		var language = logoSrc.substr(logoSrc.lastIndexOf('-')+1,2);
    		$('#logo img').attr('src', '/theme/img/'+themePath+'logo-'+language+'.png');
    	});
    }
});
function clickTab(tabNode) {
	$(tabNode).parent().parent().parent().find('> div').hide();
	$($(tabNode).attr('href')).show();
}
