window.onload = init;

function init() {
    if ($("lang-current")) {
        $("lang-current").onmouseover = Eurospace.showLang;
    }

    $("nav").getElementsByClassName("m").each(function(s) {
        s.onmouseover = Eurospace.Nav.show;
        s.onmouseout = Eurospace.Nav.resetImg;
    });
    $("inv").onmouseover = Eurospace.Nav.hide;
    //IE has problems with height: 100%;
    (document.all) ? $("inv").style.height = document.documentElement.clientHeight+"px" : null;
}

var Eurospace = {
    showLang: function() {
        if (!$("languages"))
            return;
        $("languages").style.display = "block";
        $("inv").style.display = "block";
    },
    startGoTo: function(that) {
        (that.value != "NIL") ? document.location = that.value : null;
    },
    Nav: {
        show: function() {
            var el = this.id.replace(/m-/,"d-");
            this.oldSrc = this.src;
            this.src = this.src.replace(/_.gif/,"_on.gif");
            Eurospace.Nav.hide();
            if ($(el)) {
                $(el).style.display = "block";
                $("inv").style.display = "block";
            }
        },
        hide: function() {
            $("header").getElementsByClassName("dropdown").each(function(s) {
                s.style.display = "none";
            });
            $("inv").style.display = "none";
            if ($("languages")) {
                $("languages").style.display = "none";
            }
        },
        resetImg: function() {
            if (this.oldSrc) {
                this.src = this.oldSrc;
                this.oldSrc = false;
            }
        }
    }
}
