﻿/* LL.M. Versicherungsrecht (Insurance Law) */
/* Christoph Greggersen, 2011 */
/* JS functions.js */
/* ----------------------------------------------------------------------------------------- IMAGE PRELOAD */
function preloadImages() {
	var d = document;
	if (d.images) {
		if (!d.MM_p) d.MM_p=new Array();
		var i,j = d.MM_p.length, a = preloadImages.arguments;
		for (i=0; i<a.length; i++) if (a[i].indexOf("#") != 0) {
			d.MM_p[j] = new Image;
			d.MM_p[j++].src = a[i];
		}
	}
}
window.onload = function () {
	preloadImages(
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/mainnav_first_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/mainnav_first_active.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/mainnav_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/mainnav_active.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/subnav_top_hover.png',
        'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/subnav_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/subnav_level2_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/icon_print_act.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_lc_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_rc_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_lc_act.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_rc_act.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_lc_act_hover.png',
		'http://www.jura.uni-hamburg.de/fileadmin/llm_versicherungsrecht/img/footernav_link_lc_act_hover.png'
	);
};
/* ----------------------------------------------------------------------------------------- GENERAL */
jQuery(document).ready(function() {
    $('#searchword').focusin(function() {
        $('#searchbox').addClass('act');
    }).focusout(function(){
        $('#searchbox').removeClass('act');
    });
    $('#footernav_link').hover(function () {
        $('#footernav_link div').addClass('hover');
    },function () {
        $('#footernav_link div').removeClass('hover');
    });
    $('#footernav_link').toggle(function() {
        $('#footernav_link div').addClass('act');
        $('#footernav_link_lc span').text('Übersicht ausblenden');
        $('#footerline').hide();
        $('#footernav').fadeIn(200);
    }, function() {
        $('#footernav').fadeOut(200, function() {
            $('#footerline').show();
            $('#footernav_link div').removeClass('act');
            $('#footernav_link_lc span').text('Übersicht anzeigen');            
        });
    });
});
/* ----------------------------------------------------------------------------------------- ADD THIS */
$(function() {
    var delay = 400;
    function hideMenu() {
        if (!$('.custom_button').data('in') && !$('.hover_menu').data('in') && !$('.hover_menu').data('hidden')) {
            $('.hover_menu').fadeOut('fast');
            $('.custom_button').removeClass('active');
            $('.hover_menu').data('hidden', true);
        }
    }
    $('.custom_button, .hover_menu').mouseenter(function() {
        $('.hover_menu').fadeIn('fast');
        $('.custom_button').addClass('active');
        $(this).data('in', true);
        $('.hover_menu').data('hidden', false);
    }).mouseleave(function() {
        $(this).data('in', false);
        setTimeout(hideMenu, delay);
    });
});
