var map = null;
var op = 1.0;
var faktor = -0.05;
var countp = 0;

var jheadline_count;
var jheadline_interval;
var jcurrent_headline = 0;
var jold_headline = 0;

addLoadEvent_Syn(function() {
    if (document.getElementById("slider")) {
        var h = "";
       for (countp = 0; countp < synapsis_menuimageids.length; countp++) {
            if (synapsis_menuimageids[countp] != null && synapsis_menuimageids[countp] != "undefined") {
                var i = document.createElement("img");
                i.src = "/images/cut/20/" + synapsis_menuimageids[countp] + "/490/320.png";
                i.width = 490;
                i.height = 320;
                i.alt = "";
                i.border = 0;
                var d = document.createElement("li");
                d.appendChild(i);
                document.getElementById("msl").appendChild(d);
            }
        }
        if (synapsis_menuimageids.length>1) {
        $("#slider").easySlider({
            auto: true,
            continuous: true,
            numeric: true,
            speed: 800,
            pause: 4000,
            nextId: "slider1next",
            prevId: "slider1prev"
        });
        }
    }
    if (document.getElementById("antenne_metropol_bilder")) {
        for (countp = 0; countp < synapsis_menuimageids.length; countp++) {
            if (synapsis_menuimageids[countp] != null && synapsis_menuimageids[countp] != "undefined") {
                var i = document.createElement("img");
                i.src = "/images/cut/20/" + synapsis_menuimageids[countp] + "/189/90.jpg";
                i.width = 189;
                i.height = 90;
                i.alt = "";
                i.border = 0;
                document.getElementById("antenne_metropol_bilder").appendChild(i);
            }
        }
    }
    if (document.getElementById("scrollup")) {
        jheadline_count = $("#scrollup div.aktuelles_item").size();
        $("#scrollup div.aktuelles_item:eq(" + jcurrent_headline + ")").css('top', '5px');
        jheadline_interval = setInterval(jheadline_rotate, 8000);
        $('#scrollup').hover(function() {
            clearInterval(jheadline_interval);
        }, function() {
            jheadline_interval = setInterval(jheadline_rotate, 8000);
            jheadline_rotate();
        });
    }
});

function jheadline_rotate() {
    jcurrent_headline = (jold_headline + 1) % jheadline_count;
    $("#scrollup div.aktuelles_item:eq(" + jold_headline + ")").animate({ top: -205 }, 1000, function() {
        $(this).css('top', '205px');
    });
    $("#scrollup div.aktuelles_item:eq(" + jcurrent_headline + ")").show().animate({ top: 5 }, 1000);
    jold_headline = jcurrent_headline;
}


function blend() {
    if (op >= 0 && op <= 1) {
        op = op + faktor;
        document.getElementById("hp1").style.opacity = op;
        document.getElementById("hp1").style.filter = "Alpha(opacity=" + (op * 100) + ")";
        window.setTimeout("blend()", 100);
    }
    else {
        if (op < 0) {
            op = 0.0;
            faktor = 0.05;
            if (synapsis_menuimageids[countp] != null && synapsis_menuimageids[countp] != "undefined") {
                document.getElementById("hp1").src = "/images/cut/20/" + synapsis_menuimageids[countp] + "/490/320.png";
            }
        }
        else {
            op = 1.0;
            faktor = -0.05;
            if (synapsis_menuimageids[countp] != null && synapsis_menuimageids[countp] != "undefined") {
                document.getElementById("hp2").src = "/images/cut/20/" + synapsis_menuimageids[countp] + "/490/320.png";
            }
        }
        countp++;
        if (countp > synapsis_menuimageids.length) {
            countp = 0;
        }
        window.setTimeout("blend()", 5000);
    }
}

function unitooltip(el, titel) {
    var s = document.getElementById("unitooltip");
    s.innerHTML = "<a href=\"" + el.parentNode.href + "\">" + titel + "</a>";
    var p = getDim(el);
    s.style.left = p.x + "px";
    s.style.top = p.y + 60 + "px";
    s.style.display = "block";
    if (cmsbox_timer == null) cmsbox_timer = window.setTimeout(uni_hide, 5000);
}
function uni_hide() {
    document.getElementById("unitooltip").style.display = "none";
    cmsbox_timer = null;
}
function GetMap(x, y, z) {
    if (typeof (VEMap) != "undefined") {
        map = new VEMap('mapviewer');
        map.LoadMap(new VELatLong(x, y), z, 'r', false);
        map.HideDashboard();
    }
}
function addPin(x, y, titel, text) {
    if (typeof (VEShape) != "undefined") {
        var shape = new VEShape(VEShapeType.Pushpin, new VELatLong(x, y));
        shape.SetTitle(titel);
        shape.SetDescription(text);
        map.AddShape(shape);
    }
}

