var sel = false, sel_to = null, latlng = [51.393924,7.773975];

function showSub(o, immediate) {
    $(o).stop(true);
    if ((sel!==false || $(o).parent().find('.sel').length) && sel!==o && !$(o).hasClass('sel')) {
        window.clearTimeout(sel_to);
        if (jQuery.support.opacity) {
            $(sel).fadeTo(240, 0.35);
        }
    } else if ($(o).hasClass('sel') && parseFloat($(o).css('opacity')) < 1) {
        window.clearTimeout(sel_to);
        if (jQuery.support.opacity) {
            $(o).fadeTo(120, 1);
        }
    }
    if (typeof immediate != 'undefined' && immediate === true) {
        $(o).css('bottom', 0).find('a:first').css('paddingTop', 18).end().find('.bg:first').css('opacity', 0.35);
    } else {
        $(o).animate({
            'bottom' : 0
        }, 420, 'easeout')
        .find('a:first').stop(true).animate({'paddingTop':18}, 280)
        .end().find('.bg:first').stop(true).fadeTo(320, 0.75);
    }
}

function hideSub(o) {
    if (!$(o).hasClass('sel')) {
        if ((sel!==false || $(o).parent().find('.sel').length) && jQuery.support.opacity) {
            sel_to = window.setTimeout(function() {
                $(sel).fadeTo(120, 1);
            }, 120);
        }
        $(o).stop(true).animate({
            'bottom' : -228
        }, 240, 'easein')
        .find('a:first').animate({'paddingTop':4}, 420)
        .end().find('.bg:first').fadeTo(200, 0.35);
    }
}

function initNav() {
    if ($('#nav li.sel').length) {
        sel = $('#nav li.sel:first');
        $(sel).css('bottom', -158).find('a:first').css('paddingTop', 4);
        showSub(sel, true);
        if (jQuery.support.opacity) {
            window.setTimeout(function() { $(sel).find('.bg:first').fadeTo(1200, 0.75); }, 60);
        } else {
            $(sel).find('.bg:first').css('opacity', 0.75);
        }
    }
    $('#nav .main-nav .bg').css('opacity', 0.35);
    $('#nav .main-nav').each(function(i, o) {
        $(o).data('o_bottom', $(o).css('bottom'));
        $(o).hover(function() { showSub(o); }, function() { hideSub(o); });
    });
}

function renderMap() {
    if (GBrowserIsCompatible()) {
        var con = document.getElementById('map');
        map = new GMap2(con);
        var pnt = new GLatLng(latlng[0], latlng[1]);
        mrk = new GMarker(pnt);

        map.addOverlay(mrk);
        map.addControl(new GMapTypeControl());
    	map.addControl(new GSmallMapControl());
    	map.addControl(new GScaleControl());
        
        map.setCenter(pnt, 16, G_HYBRID_MAP);
        GEvent.addListener(mrk, 'click', function() {
            openInfoBox();
        });
        
        $(window).load(function() {
            map.panDirection(0,1);
            openInfoBox();
        });
    }
}

jQuery().ready(function() {
    initNav();
    $('a').each(function() {
        $(this).bind('click', function() {
            if (this.blur) {this.blur();}
        });
    });
    $('a[rel=external]').attr('target','_blank');
    
    $('a[href$=".jpg"], a[href$=".png"]').fancybox({
        'overlayColor': '#000000'
    });

	if($('#pruef-liste')) {
		$('ul').find('dd').hide().end().find('dt').click(function (event) {
			$(this).next().slideToggle();
			event.preventDefault();
		});
	}

});


	

