$(document).ready(function(){
    if ('overflowY' in document.body.style) {
    $('body').css('overflow','hidden');
    $('#material,#kontakt,#links,#willkommen,#texte,#zeitschriften').css('overflow-y','scroll');
    $('#kontakt').hide();
    $('#links').hide();
    $('#texte').hide();
    $('#material').hide();
    $('#zeitschriften').hide();
    $('#willkommen').show();
    $('#willkommen-kopf').addClass('aktiv')
    $('#willkommen-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#kontakt').hide();
	$('#links').hide();
	$('#material').hide();
	$('#texte').hide();
	$('#material').hide();
	$('#zeitschriften').hide();
	$('#willkommen').show();
	$(this).addClass('aktiv');
    });
    $('#material-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#willkommen').hide();
	$('#kontakt').hide();
	$('#links').hide();
	$('#texte').hide();
	$('#zeitschriften').hide();
	$('#material').show();
	$(this).addClass('aktiv');
    });
    $('#kontakt-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#willkommen').hide();
	$('#links').hide();
	$('#material').hide();
	$('#texte').hide();
	$('#zeitschriften').hide();
	$('#kontakt').show();
	$(this).addClass('aktiv');
    });
    $('#links-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#willkommen').hide();
	$('#kontakt').hide();
	$('#material').hide();
	$('#texte').hide();
	$('#zeitschriften').hide();
	$('#links').show();
	$(this).addClass('aktiv');
    });
    $('#texte-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#willkommen').hide();
	$('#kontakt').hide();
	$('#material').hide();
	$('#links').hide();
	$('#zeitschriften').hide();
	$('#texte').show();
	$(this).addClass('aktiv');
    });
    $('#zeitschriften-kopf').click(function(){
	$('.aktiv').removeClass('aktiv');
	$('#willkommen').hide();
	$('#kontakt').hide();
	$('#material').hide();
	$('#links').hide();
	$('#texte').hide();
	$('#zeitschriften').show();
	$(this).addClass('aktiv');
    });

    // Hauptbereich berechnen
    console.log($(document).height());
    var height = $(document).height() - ($('h2:first').outerHeight(true) * 5) - $('h1').outerHeight(true);
    $('#kontakt').css('height',height);
    $('#links').css('height',height);
    $('#material').css('height',height);
    $('#willkommen').css('height',height);
    $('#texte').css('height',height);
    $('#zeitschriften').css('height',height);

    if (location.hash.match(/\#li/) !== null) {
	$('.aktiv').removeClass('aktiv');
	$('#kontakt').hide();
	$('#links').hide();
	$('#willkommen').hide();
	$('#material').hide();
	$('#texte').show();
	$('#zeitschriften').hide();
	$('#texte-kopf').addClass('aktiv');
	var old_hash = location.hash;
	location.hash = '#top'
	location.hash = old_hash
    }

    }
});
