
function popup(html) {
    $(".modul_tip").hide();
    close_popup();
    //$(".close-floatbox").click();
    scrollTo(0,0);
    $.floatbox({
        content:html
    });
}

function close_popup() {
    $("#floatbox-background").hide().remove();
    $("#floatbox-box").hide().remove();
    document.title = "Træneren";
}

var currentAnchor = null;

function checkAnchor() {
    if (currentAnchor != document.location.hash) {
        currentAnchor = document.location.hash;
        if (currentAnchor == '') {
            // Close popup
            close_popup();
            //$(".close-floatbox").click();
        } else {
            var splits = currentAnchor.substring(1).split('&');
            if (splits[0] == "bogkort") {
                open_bogkort(splits[1]);
            } else if (splits[0] == "producent") {
                open_producent(splits[1]);
            } else if (splits[0] == "rapporter-problem") {
                open_rapporter_problem(splits[1]);
            } else if (splits[0] == "teamsite") {
                var url = splits[1];
                open_teamsite(url);
            }
        }
    }
}

$().ready(function(){
    checkAnchor();
    // IE8 in IE7 mode defines window.onhashchange, but never fires it...
    if ('onhashchange' in window && !('documentMode' in document && document.documentMode < 8)) {
        window.onhashchange = checkAnchor;
    } else {
        setInterval(checkAnchor, 250);
    }
});

// Fix IE stacking-error. See http://www.quirksmode.org/bugreports/archives/2006/01/Explorer_z_index_bug.html
/*
$(function() {
	var zIndexNumber = 500;
	$('div').not('.leavez').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 1;
	});
});
*/

var modul_tip_timeouts = [];

// Styring af modul-tips
function modul_tip_show(id) {
    modul_tip_timeouts[id] = setTimeout(function() {
        $("#"+id).show();
        modul_tip_timeouts[id] = 0;
    }, 500);
}

function modul_tip_hide(id) {
    var timer = modul_tip_timeouts[id];
    if (timer) {
        clearTimeout(timer);
        modul_tip_timeouts[id] = 0;
    }
    $("#"+id).hide();
}


