var cpr = new Array(
            "Verkehrsmeldungen",
            "v3.12.04",
            "© 2006 - 2012 Entwicklungszentrum POLIZEI-ONLINE",
            "Update: 13.01.2012"
            );

var imgPath = "img/";
var signPath = "signs/";
var showMap = true;
var updateTimer = 60;
var timerStart;

var params = window.location.search;

if (params.indexOf("region=germany") != -1) {
    var vwdMsgUrl = "MessagesGer.aspx";
    var vwdRssUrl = "RssFeedGer.aspx";
}
else {
    var vwdMsgUrl = "InternetVwd.aspx";
    var vwdRssUrl = "RssFeed.aspx";
}

var timer = window.setInterval("Ajax('Alle Meldungen')", updateTimer * 1000);
var countdownTimer;

Ajax('Alle Meldungen');

function Ajax(filter) {
    if (filter != "Alle Meldungen") {
        window.clearInterval(timer);
        timer = window.setInterval("Ajax('" + filter + "')", updateTimer * 1000);
    }
    else {
        window.clearInterval(timer);
        timer = window.setInterval("Ajax('Alle Meldungen')", updateTimer * 1000);
    }

    $("vwd_updater").innerHTML = "Verkehrsmeldungen werden aktualisiert.....";

    window.clearTimeout(countdownTimer);

    $("vwd_imgprog").style.display = "inline";
    $("vwd_timer").style.display = "none";

    var xmlHttp = false;

    try {
        xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e) {
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e) {
            xmlHttp = false;
        }
    }

    if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
        xmlHttp = new XMLHttpRequest();
    }

    if (xmlHttp) {
        xmlHttp.open('GET', vwdMsgUrl, true);
        xmlHttp.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT");
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    Traffic(xmlHttp, filter);
                }
            }
        };

        xmlHttp.send(null);
    }
}

function Traffic(xmlHttp, filter) {
    if (filter != "map") {
        trSigns = new Array(
    	"250.gif", "gesperrt", "Strassensperrung", "~", "Fahrstreifen gesperrt", "Standstreifen gesperrt", "Fähre", "Schifffahrt", "?",
    	"101.gif", "Schlaglöcher", "~", "?",
    	"101.gif", "Nebel", "Hochwasser", "Überflutung", "Überschwemmung", "~", "?",
    	"101.gif", "unbeleuchtetes Fahrzeug", "ungesichertes Fahrzeug", "defektes Fahrzeug", "~", "?",
    	"101.gif", "ungesicherte Unfallstelle", "~", "?",
    	"101.gif", "Verunreinigung", "Trinkwasserversorgung", "~", "?",
    	"101.gif", "Falschfahrer", "entgegenkommendes Fahrzeug", "querstehender LKW", "~", "?",
    	"112.gif", "Gegenstände", "Hindernisse", "verlorene Ladung", "Bäume", "Straßenschäden", "~", "?",
    	"113.gif", "Schnee", "Hagel", "~", "?",
    	"114.gif", "Glatteis", "Eisglätte", "Schneeglätte", "Straßenglätte", "überfrierende Nässe", "Aquaplaning", "Verschmutzung", "verschmutzt", "Ölspur", "~", "Luftverschmutzung", "Trinkwasser", "?",
    	"115.gif", "Steinschlag", "Erdrutsch", "~", "?",
    	"117.gif", "Wind", "Sturm", "Windhose", "~", "Winden", "Geschwindigkeit", "Höchstgeschwindigkeit", "?",
    	"120.gif", "Fahrbahnverengung", "verengt", "2 Fahrstreifen blockiert", "2 Fahrstreifen gesperrt", "beide Fahrstreifen blockiert", "~", "?",
    	"125.gif", "Falschfahrer", "entgegenkommendes Fahrzeug", "~", "?",
    	"131.gif", "Ampel", "Lichtzeichen", "~", "?",
    	"133.gif", "Personen", "~", "?",
    	"136.gif", "Kinder", "~", "?",
    	"138.gif", "Fahrrad", "~", "?",
    	"140.gif", "Tier", "Rind", "Bullen", "Schaf ", "Schafe", "~", "Wild ", "(Wild)", "Reh", "Pferd ", "Pferde", "?",
    	"142.gif", "Wild ", "(Wild)", "Reh", "~", "?",
    	"Pferde.gif", "Pferd ", "Pferde", "~", "?",
    	"261.gif", "Gefahrgut", "~", "?",
    	"267.gif", "Einfahrt blockiert", "~", "?",
    	"268.gif", "Schneeketten", "~", "?",
    	"121-li.gif", "linker Fahrstreifen blockiert", "~", "?",
    	"531-li.gif", "linker Fahrstreifen gesperrt", "~", "?",
    	"121-re.gif", "rechter Fahrstreifen blockiert", "~", "?",
    	"531-re.gif", "rechter Fahrstreifen gesperrt", "~", "?",
    	"223_2.gif", "Standstreifen blockiert", "~", "?",
    	"224.gif", "öffentliche Verkehrsmittel", "~", "?",
    	"314.gif", "Parkplatz", "Parkplätze", "~", "?",
    	"327.gif", "Tunnel", "tunnel", "~", "?",
    	"392.gif", "Grenzübergang", "Grenzübergänge", "Gemeinschaftszollanlage", "~", "Notruf", "?",
    	"Transport.jpg", "Schwertransport", "~", "?",
    	"Veranstaltung.jpg", "Veranstaltung", "~", "?",
    	"Fastnacht.jpg", "Fastnacht", "~", "?",
    	"Feuergefahr.gif", "brennenden Gegenstände", "brennende Gegenstände", "Kraftstoff", "~", "?",
    	"Notrufsaeule.jpg", "Notruf", "~", "?",
    	"Faehre.gif", "Fähre", "Schifffahrt", "~", "?",
    	"Rotphase.gif", "Rotphase", "Phase Rot", "~", "?"
    	);
    }

    var itemCount = 0;

    if (window.ActiveXObject) {
        doc = new ActiveXObject("Microsoft.XMLDOM");
        doc.async = false;
        doc.load(xmlHttp.responseXML);

        vwd = doc.documentElement;
        netcheck = (vwd.attributes[0]) ? vwd.attributes[0].text : "";
        update = (vwd.attributes[1]) ? vwd.attributes[1].text : "";
        topical = (vwd.attributes[2]) ? vwd.attributes[2].text : "";
        source = (vwd.attributes[3]) ? vwd.attributes[3].text : "";

        referrer = (vwd.attributes[5]) ? vwd.attributes[5].text : "";
        clientip = (vwd.attributes[6]) ? vwd.attributes[6].text : "";

        items = (vwd.firstChild.nodeName == "item") ? vwd.childNodes.length : 0;
        noMsg = (vwd.firstChild.nodeName == "nomessages") ? true : false;

        errMsg = (items == 0) ? vwd.firstChild.text : "";

        var bt = 0;
    }
    else if (document.implementation && document.implementation.createDocument) {
        vwd = xmlHttp.responseXML.getElementsByTagName("vwd");
        netcheck = (vwd[0].attributes[0]) ? vwd[0].attributes[0].nodeValue : "";
        update = (vwd[0].attributes[1]) ? vwd[0].attributes[1].nodeValue : "";
        topical = (vwd[0].attributes[2]) ? vwd[0].attributes[2].nodeValue : "";
        source = (vwd[0].attributes[3]) ? vwd[0].attributes[3].nodeValue : "";

        referrer = (vwd[0].attributes[5]) ? vwd[0].attributes[5].nodeValue : "";
        clientip = (vwd[0].attributes[6]) ? vwd[0].attributes[6].nodeValue : "";

        items = (vwd[0].firstChild.nodeName == "item") ? vwd[0].childNodes.length : 0;
        noMsg = (vwd[0].firstChild.nodeName == "nomessages") ? true : false;

        errMsg = (items == 0) ? vwd[0].firstChild.textContent : "";

        var bt = 1;
    }

    for (i = 0; i < items; i++) {
        itemNodes = (bt == 0) ? vwd.childNodes[i] : vwd[0].childNodes[i];

        for (j = 0; j < itemNodes.childNodes.length; j++) {
            itemCount++;
        }
    }

    var vwdmsgHead = "";

    if (errMsg != "")
        vwdmsgHead = "In der Anwendung ist ein Fehler aufgetreten!";
    else
        vwdmsgHead = "Stand: " + update + " Uhr";

    // vwdmsgHead += "   <span style='color:white;font-weight:normal;font-size:8pt;'>Debug: " + referrer + " ~ " + clientip + "</span>";

    var vwdCol = "<table border='0' cellpadding='0' cellspacing='0'>";
    vwdCol += "<tr valign='top'>";

    // Tabellen-Zelle für Meldungen
    vwdCol += "<td width='78%' style='border-right: 10px solid white;'>";

    if (noMsg) {
        vwdCol += "<p class='vwd_alert'>Zur Zeit liegen keine Meldungen über Verkehrsstörungen vor!</p>";
    }
    else if (errMsg != "") {
        vwdCol += "<p class='vwd_alert'>Wir sind bem&uuml;ht, die St&ouml;rung schnellstm&ouml;glich zu beheben. Bitte haben Sie Geduld.</p>";
    }

    if (topical == "false") {
        vwdCol += "<p class='vwd_alert'>";
        vwdCol += "ACHTUNG!<br/><br/>";
        vwdCol += "Seit der letzten Aktualisierung der Verkehrsmeldungen sind mehr als 2 Stunden vergangen.<br/><br/>";
        vwdCol += "Wir sind bem&uuml;ht, die St&ouml;rung schnellstm&ouml;glich zu beheben. Bitte haben Sie Geduld.</p>";
    }

    for (i = 0; i < items; i++) {
        itemNodes = (bt == 0) ? vwd.childNodes[i] : vwd[0].childNodes[i];

        itemGroup = itemNodes.attributes[0].nodeValue;

        if (filter == "Alle Meldungen") {
            vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-bottom: 4px;'>";
            vwdCol += "<tr class='vwd_item'><td colspan='3'>";
            vwdCol += itemGroup;
            vwdCol += "</td>";
            vwdCol += "<td align='right'>";
            vwdCol += "<img src='" + imgPath + "Tvminus.gif' border='0' onclick='toggleItem(this)' id='vwd_i_" + itemGroup + "' state='1' alt='Meldungsgruppe ein-/ausblenden' style='cursor: pointer' />";
            vwdCol += "</td></tr>";
            vwdCol += "</table>";

            vwdCol += "<div id='vwd_m_" + itemGroup + "'>";

            for (j = 0; j < itemNodes.childNodes.length; j++) {
                message = itemNodes.childNodes[j];

                msgDate = (bt == 0) ? message.attributes[0].text : message.attributes[0].textContent;
                msgTime = (bt == 0) ? message.attributes[1].text : message.attributes[1].textContent;
                msgHead = (bt == 0) ? message.attributes[2].text : message.attributes[2].textContent;

                msgText = (bt == 0) ? message.childNodes[0].text : message.childNodes[0].textContent;
                msgJam = (bt == 0) ? message.childNodes[1].text : message.childNodes[1].textContent;
                msgDiv = (bt == 0) ? message.childNodes[2].text : message.childNodes[2].textContent;
                msgAcc = (bt == 0) ? message.childNodes[3].text : message.childNodes[3].textContent;
                msgRw = (bt == 0) ? message.childNodes[4].text : message.childNodes[4].textContent;

                vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-top: 4px;'>";
                vwdCol += "<tr>";
                vwdCol += "<td valign='top' width='56%' style='border-right: 1px solid silver'>";

                var reg1 = /^[ABLK]\s/g;
                var reg2 = /^Land- und Stadtkreise|Regierungsbezirke|Bereichsmeldungen|Dauermeldungen/g;

                if (msgHead != "" && reg1.test(itemGroup)) {
                    vwdCol += "<strong>" + msgHead + "</strong><p/>";
                    vwdCol += msgText.substring(msgHead.length + 1);
                }
                else if (msgHead != "" && reg2.test(itemGroup)) {
                    vwdCol += "<strong>" + msgHead + "</strong><p/>";
                    vwdCol += msgText;
                }
                else {
                    vwdCol += msgText;
                }

                vwdCol += "<div class='vwd_datetime'>(" + msgDate + ", " + msgTime + " Uhr)</div>";
                vwdCol += "</td>";

                vwdCol += "<td width='10%' align='center' style='border-right: 1px solid silver'>";

                if (msgJam != "") {
                    msgJam = msgJam.split('|');

                    vwdCol += "<img src='" + signPath + "124.gif' align='top' hspace='4' alt='" + msgJam[1] + "' title='" + msgJam[1] + "'>";
                    vwdCol += "<br/>";
                    vwdCol += "<strong>" + msgJam[0] + "</strong>";
                    vwdCol += "<br/>";
                }
                else if (msgDiv == "Keine Umleitung") {
                    vwdCol += "<img src='" + signPath + "459.gif' align='top' hspace='4'>";
                    vwdCol += "<br/>";
                }
                else if (msgDiv == "Umleitung" || msgDiv == "umgeleitet") {
                    vwdCol += "<img src='" + signPath + "457.gif' align='top' hspace='4'>";
                    vwdCol += "<br/>";
                }
                else {
                    vwdCol += "&nbsp;";
                }

                vwdCol += "</td>";

                vwdCol += "<td width='10%' align='center' style='border-right: 1px solid silver'>";

                if (msgAcc != "") {
                    if (msgAcc.toLowerCase().indexOf("unfall") != -1 || msgAcc.toLowerCase().indexOf("unfälle") != -1)
                        vwdCol += "<img src='" + signPath + "Unfall.gif' align='top' hspace='4' alt='Unfall' title='Unfall'>";
                    else
                        vwdCol += "<img src='" + signPath + "Bergung.jpg' align='top' hspace='4' alt='Bergungsarbeiten' title='Bergungsarbeiten'>";

                    vwdCol += "<br/>";
                }
                else if (msgRw != "") {
                    vwdCol += "<img src='" + signPath + "123.gif' align='top' hspace='4' alt='" + msgRw + "' title='" + msgRw + "'>";
                    vwdCol += "<br/>";
                }
                else {
                    vwdCol += "&nbsp;";
                }

                vwdCol += "</td>";


                vwdCol += "<td align='left'>";

                var ts = 0;
                var sn = 0;
                var wfText = "";

                if (itemGroup.indexOf("Öffentlichkeitsfahndung") != -1) {
                    vwdCol += "<img src='" + signPath + "polizeistern.gif' align='absmiddle' hspace='4' alt='" + itemGroup + "' title='" + itemGroup + "'>";
                }
                else if (itemGroup.indexOf("Zeugenaufruf") != -1 || itemGroup.indexOf("Hinweis") != -1) {
                    vwdCol += "<img src='" + signPath + "polizeistern.gif' align='absmiddle' hspace='4' alt='" + itemGroup + "' title='" + itemGroup + "'>";
                }
                else if (itemGroup == "Störung beseitigt") {
                    //vwdCol += "<img src='" + signPath + "282.gif' align='absmiddle' hspace='4' alt='" + itemGroup + "' title='" + itemGroup + "'>";
                }
                else {
                    while (ts < trSigns.length) {
                        var wfChk = 0;
                        var nfChk = 0;

                        var trSign = trSigns[ts];

                        while (trSigns[ts] != "~") {
                            var trWord = trSigns[ts];
                            var wordFound = msgText.search(new RegExp(trWord, "i"));

                            if (wordFound != -1) {
                                wfChk = 1;
                                var isWord = trWord;
                            }

                            ts++;
                        }

                        while (trSigns[ts] != "?") {
                            var trNoise = trSigns[ts];
                            var noiseFound = msgText.search(new RegExp(trNoise, "i"));

                            if (noiseFound != -1) nfChk = 1;

                            ts++;
                        }

                        if (wfChk == 1 && nfChk != 1) {
                            sn++;
                            vwdCol += "<img src='" + signPath + trSign + "' align='absmiddle' hspace='4' alt='" + isWord + "' title='" + isWord + "'>";

                            if (sn > 2) break;
                        }

                        ts++;
                    }
                }

                vwdCol += "</td>";
                vwdCol += "</tr>";

                vwdCol += "<tr><td colspan='4'><hr style='height: 1px; color: #d0d0d0'></td></tr>";
                vwdCol += "</table>";
            }

            vwdCol += "</div>";
        }
        else {
            if (filter == itemGroup) {
                vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-bottom: 4px;'>";
                vwdCol += "<tr class='vwd_item'><td colspan='3'>";
                vwdCol += itemGroup;
                vwdCol += "</td>";
                vwdCol += "<td align='right'>";
                vwdCol += "<img src='" + imgPath + "Tvminus.gif' border='0' onclick='toggleItem(this)' id='vwd_i_" + itemGroup + "' state='1' alt='Meldungsgruppe ein-/ausblenden' style='cursor: pointer' />";
                vwdCol += "</td></tr>";
                vwdCol += "</table>";

                vwdCol += "<div id='vwd_m_" + itemGroup + "'>";

                for (j = 0; j < itemNodes.childNodes.length; j++) {
                    message = itemNodes.childNodes[j];

                    msgDate = (bt == 0) ? message.attributes[0].text : message.attributes[0].textContent;
                    msgTime = (bt == 0) ? message.attributes[1].text : message.attributes[1].textContent;
                    msgDir = (bt == 0) ? message.attributes[2].text : message.attributes[2].textContent;

                    msgText = (bt == 0) ? message.childNodes[0].text : message.childNodes[0].textContent;
                    msgJam = (bt == 0) ? message.childNodes[1].text : message.childNodes[1].textContent;
                    msgDiv = (bt == 0) ? message.childNodes[2].text : message.childNodes[2].textContent;
                    msgAcc = (bt == 0) ? message.childNodes[3].text : message.childNodes[3].textContent;
                    msgRw = (bt == 0) ? message.childNodes[4].text : message.childNodes[4].textContent;

                    vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-top: 4px;'>";
                    vwdCol += "<tr>";
                    vwdCol += "<td valign='top' width='56%' style='border-right: 1px solid silver'>";

                    if (msgDir != "" && itemGroup != "Störung beseitigt") {
                        vwdCol += "<strong>" + msgDir + "</strong><p/>";
                        vwdCol += msgText.substring(msgDir.length + 1);
                    }
                    else {
                        vwdCol += msgText;
                    }

                    vwdCol += "<div class='vwd_datetime'>(" + msgDate + ", " + msgTime + " Uhr)</div>";
                    vwdCol += "</td>";

                    vwdCol += "<td width='10%' align='center' style='border-right: 1px solid silver'>";

                    if (msgJam != "") {
                        msgJam = msgJam.split('|');

                        vwdCol += "<img src='" + signPath + "124.gif' align='top' hspace='4' alt='" + msgJam[1] + "' title='" + msgJam[1] + "'>";
                        vwdCol += "<br/>";
                        vwdCol += "<strong>" + msgJam[0] + "</strong>";
                        vwdCol += "<br/>";
                    }
                    else if (msgDiv == "Keine Umleitung") {
                        vwdCol += "<img src='" + signPath + "459.gif' align='top' hspace='4'>";
                        vwdCol += "<br/>";
                    }
                    else if (msgDiv == "Umleitung" || msgDiv == "umgeleitet") {
                        vwdCol += "<img src='" + signPath + "457.gif' align='top' hspace='4'>";
                        vwdCol += "<br/>";
                    }
                    else {
                        vwdCol += "&nbsp;";
                    }

                    vwdCol += "</td>";

                    vwdCol += "<td width='10%' align='center' style='border-right: 1px solid silver'>";

                    if (msgAcc != "") {
                        if (msgAcc.toLowerCase().indexOf("unfall") != -1)
                            vwdCol += "<img src='" + signPath + "Unfall.gif' align='top' hspace='4' alt='Unfall' title='Unfall'>";
                        else
                            vwdCol += "<img src='" + signPath + "Bergung.jpg' align='top' hspace='4' alt='Bergungsarbeiten' title='Bergungsarbeiten'>";

                        vwdCol += "<br/>";
                    }
                    else if (msgRw != "") {
                        vwdCol += "<img src='" + signPath + "123.gif' align='top' hspace='4'>";
                        vwdCol += "<br/>";
                    }
                    else {
                        vwdCol += "&nbsp;";
                    }

                    vwdCol += "</td>";

                    vwdCol += "<td align='left'>";

                    var ts = 0;
                    var sn = 0;
                    var wfText = "";

                    if (itemGroup == "Öffentlichkeitsfahndung" || itemGroup == "Zeugenaufruf" || itemGroup == "Hinweis") {
                        vwdCol += "<img src='" + signPath + "polizeistern.gif' align='absmiddle' hspace='4' alt='" + itemGroup + "' title='" + itemGroup + "'>";
                    }
                    else if (itemGroup == "Störung beseitigt") {
                        //vwdCol += "<img src='" + signPath + "282.gif' align='absmiddle' hspace='4' alt='" + itemGroup + "' title='" + itemGroup + "'>";
                    }
                    else {
                        while (ts < trSigns.length) {
                            var wfChk = 0;
                            var nfChk = 0;

                            var trSign = trSigns[ts];

                            while (trSigns[ts] != "~") {
                                var trWord = trSigns[ts];
                                var wordFound = msgText.search(new RegExp(trWord, "i"));

                                if (wordFound != -1) {
                                    wfChk = 1;
                                    var isWord = trWord;
                                }

                                ts++;
                            }

                            while (trSigns[ts] != "?") {
                                var trNoise = trSigns[ts];
                                var noiseFound = msgText.search(new RegExp(trNoise, "i"));

                                if (noiseFound != -1) nfChk = 1;

                                ts++;
                            }

                            if (wfChk == 1 && nfChk != 1) {
                                sn++;
                                vwdCol += "<img src='" + signPath + trSign + "' align='absmiddle' hspace='4' alt='" + isWord + "' title='" + isWord + "'>";

                                if (sn > 2) break;
                            }

                            ts++;
                        }
                    }

                    vwdCol += "</td></tr>";

                    vwdCol += "<tr><td colspan='4'><hr style='height: 1px; color: #d0d0d0'></td></tr>";
                    vwdCol += "</table>";
                }
            }
        }
    }

    if (filter == "map") {
        vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-bottom: 4px;'>";
        vwdCol += "<tr class='vwd_item'><td colspan='3'>";
        vwdCol += "Autobahn-Karte";
        vwdCol += "</td>";
        vwdCol += "<td align='right'>";
        vwdCol += "<img src='" + imgPath + "blank.gif' border='0' width='15' height='20' alt='' />";
        vwdCol += "</td></tr>";
        vwdCol += "</table>";

        vwdCol += "<table border='0' width='100%' cellspacing='0' cellpadding='2' style='margin-top: 4px;'>";
        vwdCol += "<tr><td valign='top'>";
        vwdCol += "<img src='" + imgPath + "babkarte.gif' border='0'>";
        vwdCol += "</td>";
        vwdCol += "</tr>";
        vwdCol += "</table>";
    }

    vwdCol += "</td>";

    // Tabellen-Zelle für Navigation
    vwdCol += "<td class='vwd_navi'>";

    if (params.indexOf("region=germany") != -1) {
        vwdCol += "<strong>&Uuml;bersicht (Deutschland)</strong>";
    }
    else {
        vwdCol += "<strong>&Uuml;bersicht (BW)</strong>";
    }

    vwdCol += "<br/>";
    vwdCol += "<br style='line-height: 125%;'>";

    vwdCol += "<label onClick='Ajax(\"Alle Meldungen\")' onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";

    if (filter == "Alle Meldungen")
        vwdCol += "<img src='" + imgPath + "hr_arrow_inactive_hh.gif' align='absmiddle' style='margin-right: 4px;'>";
    else
        vwdCol += "<img src='" + imgPath + "IMNUNK.png' align='absmiddle' style='margin-right: 4px;'>";

    vwdCol += "Alle Meldungen (" + itemCount + ")";
    vwdCol += "</label>";
    vwdCol += "</br>";

    for (i = 0; i < items; i++) {
        itemGroup = (bt == 0) ? vwd.childNodes[i].attributes[0].nodeValue : vwd[0].childNodes[i].attributes[0].nodeValue;
        itemCount = (bt == 0) ? vwd.childNodes[i].childNodes.length : vwd[0].childNodes[i].childNodes.length;

        vwdCol += "<br style='line-height: 125%;'>";

        vwdCol += "<label onClick='Ajax(\"" + itemGroup + "\")' onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";

        if (filter == itemGroup) {
            vwdCol += "<img src='" + imgPath + "hr_arrow_inactive_hh.gif' align='absmiddle' style='margin-right: 4px;'>";
        }
        else {
            if (itemGroup == "Störung beseitigt") {
                vwdCol += "<img src='" + imgPath + "IMNON.png' align='absmiddle' style='margin-right: 4px;'>";
            }
            else if (itemCount <= 1) {
                vwdCol += "<img src='" + imgPath + "IMNON.png' align='absmiddle' style='margin-right: 4px;'>";
            }
            else if (itemCount <= 2) {
                vwdCol += "<img src='" + imgPath + "IMNIDLE.png' align='absmiddle' style='margin-right: 4px;'>";
            }
            else if (itemCount <= 3) {
                vwdCol += "<img src='" + imgPath + "IMNAWAY.png' align='absmiddle' style='margin-right: 4px;'>";
            }
            else if (itemCount <= 4) {
                vwdCol += "<img src='" + imgPath + "imnidlebusy.png' align='absmiddle' style='margin-right: 4px;'>";
            }
            else {
                vwdCol += "<img src='" + imgPath + "IMNBUSY.png' align='absmiddle' style='margin-right: 4px;'>";
            }
        }

        vwdCol += itemGroup + " (" + itemCount + ")";

        vwdCol += "</label>";
        vwdCol += "</br>";
    }

    if (params.indexOf("region=") != -1)
        showMap = false;

    if (showMap) {
        vwdCol += "<br style='line-height: 125%;'>";

        vwdCol += "<label onClick='Ajax(\"map\")' onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";

        if (filter == "map") {
            vwdCol += "<img src='" + imgPath + "hr_arrow_inactive_hh.gif' align='absmiddle' style='margin-right: 4px;'>";
            vwdCol += "<strong>";
        }
        else {
            vwdCol += "<img src='" + imgPath + "IMNUNK.png' align='absmiddle' style='margin-right: 4px;'>";
        }

        vwdCol += "Autobahn-Karte";

        if (filter == "map") vwdCol += "</strong>";

        vwdCol += "</label>";
        vwdCol += "</br>";
    }

    vwdCol += "<p/>";

    switch (netcheck) {
        case "Intranet":
            var svzUrl = "http://viz.sbv.bwl.de/index.php?option=com_content&view=article&id=126&Itemid=139";
            var bisUrl = "http://isis-app.sbv.bwl.de:8080/bis/";
            var rssFeeds = false;
            break;
        case "Internet":
            var svzUrl = "http://www.svz-bw.de/index.php?option=com_content&view=article&id=124&Itemid=136";
            var bisUrl = "http://baustellen.strassen.baden-wuerttemberg.de/bis_internet/";
            var rssFeeds = true;
            break;
        default:
            break;
    }

    if (params.indexOf("region=") == -1) {
        vwdCol += "<hr style='height: 1px; color: silver; text-align: left;'>";

        vwdCol += "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        vwdCol += "<tr>";
        vwdCol += "<td>";
        vwdCol += "<b style='line-height: 200%'>Straßenverkehrszentrale</b>";
        vwdCol += "</td>";
        vwdCol += "</tr>";
        vwdCol += "<tr valign='top'>";
        vwdCol += "<td>";
        vwdCol += "<label onClick='extWindow(\"" + svzUrl + "\", \"SVZ\")' onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";
        vwdCol += "Verkehrskameras";
        vwdCol += "</label>";
        vwdCol += "</td>";
        vwdCol += "</tr>";
        vwdCol += "</table>";
    }

    if (params.indexOf("region=") == -1) {
        vwdCol += "<hr style='height: 1px; color: silver; text-align: left;'>";

        vwdCol += "<table border='0' width='100%' cellpadding='0' cellspacing='0'>";
        vwdCol += "<tr>";
        vwdCol += "<td>";
        vwdCol += "<b style='line-height: 200%'>Baustellen-Infoservice</b>";
        vwdCol += "</td>";
        vwdCol += "</tr>";
        vwdCol += "<tr valign='top'>";
        vwdCol += "<td>";
        vwdCol += "<label onClick='extWindow(\"" + bisUrl + "\", \"BIS\")' onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";
        vwdCol += "Hier geht's zum Straßenbaustellen-Informationsdienst der Stra&szlig;enbauverwaltung Baden-W&uuml;rttemberg.";
        vwdCol += "</label>";
        vwdCol += "</td>";
        vwdCol += "</tr>";
        vwdCol += "</table>";
    }

    if (rssFeeds) {
        vwdCol += "<p/>";
        vwdCol += "<hr style='height: 1px; color: silver; text-align: left;'>";
        vwdCol += "<b>RSS-Infoservice</b><p/>";
        vwdCol += "<label onMouseover='labelStyle(this.style,\"underline\")' onMouseout='labelStyle(this.style,\"none\")'>";
        vwdCol += "<a href='" + vwdRssUrl + "' title='Verkehrsmeldungen der Polizei Baden-W&uuml;rttemberg als RSS-Newsfeed.' target='_blank'>";
        vwdCol += "<img src='" + imgPath + "rss2.0-news.png' align='absmiddle' style='margin-right: 4px; border: 0px;'>";
        vwdCol += "</a>";
        vwdCol += "</label>";
    }

    if (errMsg == "") {
        vwdCol += "<p/>";
        vwdCol += "<hr style='height: 1px; color: silver; text-align: left;'>";
        vwdCol += "<strong>Quelle</strong>:&nbsp;" + source;
        vwdCol += "<p><img src='" + imgPath + "TicPoweredByGewi.gif'></p>";
        vwdCol += "<p>&nbsp;</p>";
    }

    vwdCol += "</td>";

    vwdCol += "</tr>";
    vwdCol += "</table>";

    $("vwd_updater").innerHTML = vwdmsgHead;
    $("vwd_ticker").innerHTML = vwdCol;

    $("vwd_imgprog").style.display = "none";
    $("vwd_timer").style.display = "inline";

    timerStart = updateTimer;
    countdown();

    $("copyright").innerHTML = cpr.join(" - ");
}

function toggleItem(obj) {
    itemId = obj.id.substr(6);

    if (obj.getAttribute("state") == "1") {
        Effect.SlideUp("vwd_m_" + itemId,
            {
                duration: 0.5,
                afterFinish: function() {
                    obj.src = imgPath + "Tvplus.gif";
                    obj.setAttribute("state", "0");
                }
            }
        );
    }
    else {
        Effect.SlideDown("vwd_m_" + itemId,
            {
                duration: 0.5,
                afterFinish: function() {
                    obj.src = imgPath + "Tvminus.gif";
                    obj.setAttribute("state", "1");
                }
            }
        );
    }
}

function labelStyle(style, check) {
    style.textDecoration = check;
    style.cursor = "pointer";
}

function extWindow(url, desc) {
    web_width = 1024;
    web_height = 768;

    screen_width = screen.availWidth - 10;
    screen_height = screen.availHeight - 40;
    x_val = screen_width * 0.5 - web_width * 0.5;
    y_val = screen_height * 0.5 - web_height * 0.5;

    popupWin = window.open(url, desc, "left=" + x_val + ",top=" + y_val + ",width=" + web_width + ",height=" + web_height + ",resizable=yes,menubar=no,toolbar=no,scrollbars=yes,dependent=yes");
}

function countdown() {
    if (timerStart > 0) {
        timerStart--;
    }

    var s = timerStart;
    var h = Math.floor(s / 3600);
    var m = Math.floor((s - (h * 3600)) / 60);

    s = (s - (h * 3600)) % 60;

    if (s < updateTimer / 3) {
        $("vwd_timer").innerHTML = "Aktualisierung der Seite in " + s + " Sekunden";
    }
    else {
        $("vwd_timer").innerHTML = "";
    }

    countdownTimer = window.setTimeout("countdown()", 1000)
}

