var gnEbMinZIndex = 0;
var hbx_pagename = "";
var hbx_seg_val = "";
var mac = window.navigator.platform == "MacPPC" && navigator.appName == "Netscape" && navigator.appVersion.substring(0, 1) == "4";
var mac_ie = window.navigator.platform == "MacPPC" && navigator.userAgent.match(/MSIE/i);
var safari = window.navigator.platform == "MacPPC" && navigator.userAgent.match(/Safari/i);
var ie = navigator.userAgent.match(/MSIE\s5.*/i);
var ie4 = navigator.userAgent.match(/MSIE\s4.*/i);
var ie5 = navigator.appVersion.match(/MSIE.+5\.0/i);
var ie6 = navigator.userAgent.match(/MSIE\s6.*/i);
var ie7 = navigator.userAgent.match(/MSIE\s7.*/i);
var op = navigator.userAgent.indexOf('Opera') != -1;
var ns4 = navigator.appName == "Netscape" && navigator.appVersion.substring(0, 1) == "4";
var moz = navigator.appName == "Netscape" && navigator.appVersion.substring(0, 1) > "4";
var ns6 = navigator.userAgent.match(/Netscape6/i);
var konq = navigator.userAgent.match(/Konqueror/i);
var fustyUserAgent = mac_ie || ns4 || ns6 || mac || ie4;
var msie = ie || ie5 || ie6;
if (mac_ie) document.writeln('<link rel="stylesheet" href="/css/GEO/ie_mac.css" type="text/css" media="screen" />');
fullsize = 0;
LeaderBoard = 0;
promo = 0;
halfpage = 0;
contentad = 0;
skyscraper = 0;
textteaser = 0;
textcontent = 0;
popup = 0;
var no_col_adj = 0;
ad_refresh_counter = 1;
ad_date = new Date();
ad_timestamp = ad_date.getTime();
var usesActiveX = false;
var swf7 = false;
var swf8 = false;
var swf9 = false;
var swf10 = false;
if (navigator.plugins.length != 0) {
    for (i = 0; i < navigator.plugins.length; i++) {
        var plugDescr = navigator.plugins[i].description.toLowerCase();
        if ((plugDescr.indexOf('flash') != -1) && (plugDescr.indexOf('7.') != -1)) {
            swf7 = true;
        } else if ((plugDescr.indexOf('flash') != -1) && (plugDescr.indexOf('8.') != -1)) {
            swf8 = true;
        } else if ((plugDescr.indexOf('flash') != -1) && (plugDescr.indexOf('9.') != -1)) {
            swf9 = true;
        } else if ((plugDescr.indexOf('flash') != -1) && (plugDescr.indexOf('10.') != -1)) {
            swf10 = true;
        }
    }
} else {
    usesActiveX = true;
}

function resizeLayout() {
    document.getElementById("magNav").style.padding = "0 0 3px 60px";
    document.getElementById("rubrikenAd").style.width = "991px";
    document.getElementById("mainHeader").style.width = "991px";
    if (ie5) document.getElementById("mainNav").style.width = "991px";
    else document.getElementById("mainNav").style.width = "992px";
    document.getElementById("seperatorHalfpage").style.display = "block";
    document.getElementById("topNavHalfpage").style.display = "block";
    document.getElementById("mainContent").style.width = "993px";
    document.getElementById("right").style.width = "336px";
    if (document.getElementById("issueBoxLarge")) document.getElementById("issueBoxLarge").style.display = "block";
    if (ie5) document.getElementById("footer").style.width = "992px";
    else document.getElementById("footer").style.width = "991px";
    if (document.getElementById("floater")) document.getElementById("floater").style.display = "none";
    document.getElementById("gujSites").style.width = "991px";
    document.getElementById("promoAd").style.display = "inline";
    document.getElementById("promoAd").style.visibility = "visible";
    document.getElementById("promoAd").style.width = "336px";
    document.getElementById("promoAd").style.margin = "0 0 10px 0";
    if (document.getElementById('issueBox')) document.getElementById('issueBox').style.display = "none";
}

function submitQuery(formular, query, service) {
    if (!service) var service = document.forms[formular].service.options[document.forms[formular].service.options.selectedIndex].value;
    if (!query) var query = document.forms[formular].elements["q"].value;
    switch (service) {
    case "geo":
        document.headerSearchForm.action = "/GEO/info/suche/?service=geo&q=" + query;
        document.headerSearchForm.submit();
        break;
    case "geolino":
        document.headerSearchForm.action = "/GEOlino/service/suche/?service=geolino&serviceid=GEOlino&q=" + query;
        document.headerSearchForm.submit();
        break;
    case "georc":
        blank_window("http://www.geo-reisecommunity.de/suche?suche=" + query, "rc");
        break;
    case "presse":
        break;
    case "register":
        var jetzt = new Date();
        var reg_bis_day = jetzt.getDate();
        var reg_bis_month = jetzt.getMonth();
        var reg_bis_year = jetzt.getFullYear();
        reg_bis_month = reg_bis_month + 1;
        if (reg_bis_day < 10) reg_bis_day = "0" + reg_bis_day;
        if (reg_bis_month < 10) reg_bis_month = "0" + reg_bis_month;
        reg_bis = reg_bis_day + "." + reg_bis_month + "." + reg_bis_year;
        document.headerSearchForm.action = "/GEO/info/suche/heftregister.html?q=" + query + "&is_search=1&reg_von=01.01.1976&reg_bis=" + reg_bis + "&sortRev=0";
        document.headerSearchForm.submit();
        break;
    case "forum":
        blank_window("/GEO/static/forum/dosearch.php?Words=" + query + "&Cat=1,2,3&Forum=All_Forums&Match=And&Old=allposts&Limit=25", "forum");
        break;
    case "shop":
        var popup = window.open("/search/webshop.html?q=" + query, "shop", "width=637,height=650,scrollbars=yes,resizable=yes,menubar=no,locationbar=no");
        popup.focus();
        break;
    case "stern":
        var popup = window.open("http://www.stern.de/search/index.html?q=" + query + "&stern=1&guj=1", "stern");
        popup.focus();
        break;
    case "wissen":
        var popup = window.open("http://www.wissen.de/wde/generator/wissen/services/suche/index.html?query=" + query, "wissen");
        popup.focus();
        break;
    }
}

function openWindow(page, breite, hoehe, name) {
    var popup = window.open(page, name, "width=" + breite + ",height=" + hoehe + ",scrollbars=no,resizable=yes,menubar=no,locationbar=no");
    popup.focus();
}

function openScrollWindow(page, breite, hoehe, name) {
    var popup = window.open(page, name, "width=" + breite + ",height=" + hoehe + ",scrollbars=yes,resizable=yes,menubar=no,locationbar=no");
    popup.focus();
}

function blank_window(page, target) {
    var popup = window.open(page, target);
    popup.focus();
}

function open_leserreise(page) {
    popup = window.open(page, "leserreise", "width=660,height=730,scrollbars=yes,resizable=yes,menubar=no,locationbar=no,toolbar=no,left=0,top=0");
    popup.focus();
}

function sendArticle(headline) {
    var url = window.location.href;
    var link = url.replace(/\?.*/, "");
    window.location.href = 'mailto:?subject=GEO.de Linktipp: ' + headline + '&body=%0A' + link;
}

function getElementsByClassName(class_name) {
    var all_obj, ret_obj = new Array(),
        j = 0,
        teststr;
    if (document.all) all_obj = document.all;
    else if (document.getElementsByTagName && !document.all) all_obj = document.getElementsByTagName("*");
    for (i = 0; i < all_obj.length; i++) {
        if (all_obj[i].className.indexOf(class_name) != -1) {
            teststr = "," + all_obj[i].className.split(" ").join(",") + ",";
            if (teststr.indexOf("," + class_name + ",") != -1) {
                ret_obj[j] = all_obj[i];
                j++;
            }
        }
    }
    return ret_obj;
}

function transformTeaserLayout() {
    var teaserElement = getElementsByClassName("teaserM").length - 1;
    var teaserWidth = 573;
    var teaserMargin = "0 18px 18px 18px";
    if (msie) teaserMargin = "0 0 10px 9px";
    if (ie7) teaserMargin = "18px";
    document.getElementsByName("teaserImg")[teaserElement].style.display = "none";
    getElementsByClassName("teaserM")[teaserElement].style.width = teaserWidth + "px";
    getElementsByClassName("teaserM")[teaserElement].style.padding = "10px";
    getElementsByClassName("teaserM")[teaserElement].style.margin = teaserMargin;
    getElementsByClassName("teaserM")[teaserElement].style.border = "1px solid #" + catColorDark;
}

function reportComment(warn_comment, comment_nr, pv, comments_pv) {
    var report_box = document.getElementById("report" + comment_nr);
    var report_button = document.getElementById("button" + comment_nr);
    var comment_box = document.getElementById("commentBox" + comment_nr);
    if (report_box) {
        comment_box.removeChild(report_box);
        report_button.style.display = "block";
    } else {
        report_button.style.display = "none";
        comment_content = comment_box.innerHTML;
        report_content = '<div class="reportBox" id="report' + comment_nr + '"><form name="notify_form' + comment_nr + '" id="notify_form' + comment_nr + '" action="#comments" method="post"><input type="hidden" name="comment_id" value="' + comment_nr + '" /><input type="hidden" name="com" value="notify" /><input type="hidden" name="p" value="' + pv + '" /><input type="hidden" name="pageview" value="' + comments_pv + '" /><strong>Beitrag mit bedenklichem Inhalt melden</strong><div class="close" title="Box schließen" onclick="reportComment(\'' + warn_comment + '\',\'' + comment_nr + '\',\'' + pv + '\');">[x]</div><br class="clearFloat" /><br />Grund der Meldung (mindestens 10 Zeichen): <p id="errorMessage' + comment_nr + '" style="color:red"></p><input type="text" style="margin-left: 0px;width:350px; font-size:10px;" name="reportReason" maxlength="50" value="" onfocus="if (this.value == \'Eingabe von mindestens 10 Zeichen\') this.value=\'\'" /><br /><br /><img src="/images/GEO/kommentar/beitrag_melden.gif" width="92" height="19" onclick="checkReportComment(0, ' + comment_nr + ', 0, 0)" alt="Beitrag melden!" title="Beitrag melden!"/> </form></div>';
        comment_box.innerHTML = comment_content + report_content;
    }
}

function checkReportComment(warn_comment, comment_nr, pv, comments_pv) {
    textlaenge = document.getElementById("notify_form" + comment_nr).reportReason.value
    textlaenge = textlaenge.length;
    if (textlaenge < 10) document.getElementById("errorMessage" + comment_nr).innerHTML = "Bitte geben Sie mindestens 10 Zeichen ein!";
    else document.getElementById("notify_form" + comment_nr).submit();
}

function count_textarea(text) {
    if (text.length >= 1000) {
        document.getElementById("form-error-msg_comment_text").innerHTML = "<strong style=\"color:red\">Sie haben die maximale Textlänge von 1000 Zeichen erreicht!<strong>";
        document.getElementById("form-comment-text-counter").innerHTML = "";
        document.getElementById("mitteilung").value = document.getElementById("mitteilung").value.substring(0, 1000);
    }
    else {
        document.getElementById("form-comment-text-counter").innerHTML = "Noch " + (1000 - text.length) + " Zeichen frei";
        document.getElementById("form-error-msg_comment_text").innerHTML = "";
    }
}

function flashInteractionTracking(application, action, clicktarget, refresh_freq) {
    if (!refresh_freq) refresh_freq = 2;
    var IVW = "http://geo.ivwbox.de/cgi-bin/ivw/CP/" + agof_id + ";" + ivw_id + ",," + application + ",";
    if (typeof urchinTracker == "function") {
        urchinTracker(application + "-" + action + "=" + clicktarget);
    }
    _gaq.push(['_trackPageview', "/" + application + "/" + action + "/" + clicktarget]);
    _gaq.push(['_trackEvent', application, action, clicktarget]);
    if ((typeof s != "undefined") && (s != null)) {
        savehier = s.hier1;
        saveprop7 = s.prop7;
        if (application.match(/schiebepuzzle/)) {
            application = application.replace(/_\d{4,5}/g, "");
        }
        s.prop7 = "interaktion-spiele";
        s.hier1 = s.hier1 + "," + application;
        s.referrer = window.location.protocol + "//" + document.location.host + document.location.pathname;
        void(s.t());
        s.prop7 = saveprop7;
        s.hier1 = savehier;
    }
    if (!document.getElementById("pixel_container")) {
        var pc = document.createElement('div');
        pc.setAttribute('id', 'pixel_container');
        $('body').append(pc);
    }
    document.getElementById("pixel_container").innerHTML = "<img src='" + IVW + "?r=noref&d=" + (Math.random() * 100000) + "' width='1' height='1' alt='' \/><br \/>";
}

function videoTracking(player, lineup, video, videoKeywords) {
    var p1 = deleteUmlaute(player);
    var p2 = deleteUmlaute(lineup);
    var p3 = deleteUmlaute(video);
    var p3 = deleteUmlaute(video);
    if (videoKeywords) {
        p4 = deleteUmlaute(videoKeywords);
    }
    ivw_string = 'http://geo.ivwbox.de/cgi-bin/ivw/CP/' + agof_id + ';' + ivw_id + ',,Brightcove_' + p1 + ':' + p2 + ':' + p3 + ',?p=' + (Math.random() * 100000);
    if (typeof _hbPageView == "function") {
        _hbPageView(hbx_para_1, hbx_para_2);
    }
    if (!document.getElementById("pixel_container")) {
        var pc = document.createElement('div');
        pc.setAttribute('id', 'pixel_container');
        $('body').append(pc);
    }
    document.getElementById("pixel_container").innerHTML = "<img src='" + ivw_string + "?r=noref&d=" + (Math.random() * 100000) + "' width='1' height='1' alt='' \/><br \/>";
}

function setCookie(name, string, expires) {
    var date = new Date();
    killtime = date.getTime() + expires;
    document.cookie = name + "=" + string + "; expires=" + killtime;
}

function doRequest(url) {
    http_request = false;
    error = false;
    if (window.XMLHttpRequest) {
        http_request = new XMLHttpRequest();
        if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/xml');
        }
    } else if (window.ActiveXObject) {
        try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!http_request) {
        alert('Ende: ( Kann keine XMLHTTP-Instanz erzeugen');
        return false;
    }
    if (!error) {
        http_request.onreadystatechange = processAdResponse;
        http_request.open('GET', url, true);
        http_request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded charset:ISO-8859-1');
        http_request.send(null);
    }
}

function processAdResponse() {
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {
            var xmlDoc = http_request.responseXML;
            var bannerCode = xmlDoc.getElementsByTagName("banner")[0].childNodes[0].nodeValue;
            var bannerType = xmlDoc.getElementsByTagName("banner")[0].getAttribute("type");
            var skyCode = xmlDoc.getElementsByTagName("sky")[0].childNodes[0].nodeValue;
            if (bannerType == "leaderboard") {
                $("#rubrikenAd").css("height", "90px");
                $("#floater").css("top", "128px");
            } else if (bannerType == "fullsize") {
                $("#rubrikenAd").css("height", "60px");
                $("#floater").css("top", "98px");
            } else {
                $("#rubrikenAd").css("display", "none");
                $("#floater").css("top", "23px");
            }
            if (bannerCode != "" && $("#rubrikenAd")) {
                document.getElementById("rubrikenAd").innerHTML = "";
                $("#rubrikenAd").html(bannerCode);
            }
            if (skyCode != "" && $("#floater")) {
                document.getElementById("floater").innerHTML = "";
                $("#floater").html(skyCode);
            }
        }
    }
}

function writeMediaCode(extension, source, width, height, id, display) {
    if (extension == "mpeg" || extension == "avi") extension = "mpg";
    if (extension == "swf") extension = "flv";
    if (extension != "flv") height = parseInt(height) + 15;
    switch (extension) {
    case "flv":
        document.writeln('<object id="' + id + '" type="application/x-shockwave-flash" data="' + source + '" width="' + width + '" height="' + height + '">');
        document.writeln('<param name="movie" value="' + source + '" \/>');
        document.writeln('<param name="wmode" value="transparent" \/>');
        document.writeln('Für die Darstellung des Inhalts ist der Flash Player von Adobe erforderlich, den Sie unter folgender Adresse kostenlos herunterladen können:<br /> <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=German" target="_blank">» Adobe Flash Player Download-Center</a><br \/><br \/>');
        document.writeln('<\/object>');
        break;
    case "swf":
        document.writeln('<object id="' + id + '" type="application/x-shockwave-flash" data="' + source + '" width="' + width + '" height="' + height + '">');
        document.writeln('<param name="movie" value="' + source + '" \/>');
        document.writeln('<param name="wmode" value="transparent" \/>');
        document.writeln('Für die Darstellung des Inhalts ist der Flash Player von Adobe erforderlich, den Sie unter folgender Adresse kostenlos herunterladen können:<br /> <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=German" target="_blank">» Adobe Flash Player Download-Center</a><br \/><br \/>');
        document.writeln('<\/object>');
        break;
    case "wmv":
        height = parseInt(height) + 44;
        document.writeln('<object id="' + id + '" classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95" type="application/x-oleobject" standby="Der Microsoft Windows Media Player wird geladen..." width="' + width + '" height="' + height + '">');
        document.writeln('<param name="fileName" value="' + source + '" />');
        document.writeln('<param name="autostart" value="1" />');
        document.writeln('<param name="AnimationatStart" value="0" />');
        document.writeln('<param name="TransparentatStart" value="0" />');
        document.writeln('<param name="ShowControls" value="1" />');
        document.writeln('<param name="ShowPositionControls" value="0" />');
        document.writeln('<param name="ShowStatusBar" value="0" />');
        document.writeln('<embed id="' + id + '2" type="application/x-mplayer2" showcontrols="1" showpositioncontrols="0" animationatstart="0" transparentatstart="0" showstatusbar="0" src="' + source + '" width="' + width + '" height="' + height + '"></embed>');
        document.writeln('<\/object>');
        break;
    case "mpg":
        document.writeln('<object id="' + id + '" type="video/mpeg" data="' + source + '" autostart="true" width="' + width + '" height="' + height + '" style="display:' + display + '">');
        document.writeln('<param name="type" value="video/mpeg" />');
        document.writeln('<param name="src" value="' + source + '" />');
        document.writeln('<param name="controls" value="ImageWindow" />');
        document.writeln('<param name="autostart" value="true" />');
        document.writeln('Für die Darstellung des Videos ist der Quicktime-Player von Apple erforderlich, den Sie unter folgender Adresse herunterladen können:<br /> <a href="http://www.apple.com/de/quicktime/download/" target="_blank">» http://www.apple.com/de/quicktime/download/</a>');
        document.writeln('<\/object>');
        break;
    case "mov":
        document.writeln('<object id="' + id + '" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" data="' + source + '" autostart="true" width="' + width + '" height="' + height + '" style="display:' + display + '">');
        document.writeln('<param name="controller" value="true" />');
        document.writeln('<param name="kioskmode" value="true" />');
        document.writeln('<param name="src" value="' + source + '" />');
        document.writeln('<param name="autostart" value="true" />');
        document.writeln('<object type="video/quicktime" data="' + source + '" autostart="true" width="' + width + '" height="' + height + '" class="mov">');
        document.writeln('<param name="controller" value="true" />');
        document.writeln('<param name="kioskmode" value="true" />');
        document.writeln('<param name="src" value="' + source + '" />');
        document.writeln('<param name="autostart" value="true" />');
        document.writeln('Für die Darstellung des Videos ist der Quicktime-Player von Apple erforderlich, den Sie unter folgender Adresse herunterladen können:<br /> <a href="http://www.apple.com/de/quicktime/download/" target="_blank">» http://www.apple.com/de/quicktime/download/</a>');
        document.writeln('</object>');
        document.writeln('</object>');
        break;
    case "rm":
        document.writeln('<object id="' + id + '" type="audio/x-pn-realaudio-plugin" data="' + source + '" autostart="true" width="' + width + '" height="' + height + '" style="display:' + display + '">');
        document.writeln('<param name="type" value="audio/x-pn-realaudio-plugin" />');
        document.writeln('<param name="src" value="' + source + '" />');
        document.writeln('<param name="controls" value="ImageWindow" />');
        document.writeln('<param name="autostart" value="true" />');
        document.writeln('Für die Darstellung des Videos ist der RealPlayer erforderlich, den Sie unter folgender Adresse herunterladen können:<br /> <a href="http://de.real.com/player/" target="_blank">» http://de.real.com/player/</a>');
        document.writeln('<\/object>');
        break;
    case "mp3":
        var real_source = source.replace(/\/_components\/GEO\/article\/audio_player\/geo_audioplayer\.swf\?audio_file=/i, "");
        real_source = real_source.replace(/\&rubrik.*$/i, "");
        document.writeln('<object id="' + id + '" type="application/x-shockwave-flash" data="' + source + '" width="' + width + '" height="' + height + '">');
        document.writeln('<param name="movie" value="' + source + '" \/>');
        document.writeln('Zum Abspielen der Audio-Datei ist der Flash Player von Macromedia erforderlich, den Sie unter folgender Adresse herunterladen können: <a href="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash&Lang=German" target="_blank">» Macromedia Flash Player Download-Center</a><br \/><br \/>');
        document.writeln('Alternativ können Sie auch folgende Datei aufrufen:<br /> <a href="' + real_source + '">» Audio starten</a>');
        document.writeln('<\/object>');
        break;
    }
}

function switchMedia(p, id) {
    nof_media = 10;
    for (var i = 0; i <= nof_media; i++) {
        if (document.getElementById("mediaObj" + p + i)) {
            if (i != id) document.getElementById("mediaObj" + p + i).style.display = "none";
            if (i == id) document.getElementById("mediaObj" + p + i).style.display = "block";
        }
    }
}

function checkCompatibility(alertID) {
    hideContainer = alertID;
    if (safari && !swf9) {
        document.writeln('<div id="errorbox">');
        document.writeln('<strong>Hinweis:</strong> Für eine optimale Darstellung des Videos ist der Adobe Flash Player ab Version 9 erforderlich, den Sie unter folgender Adresse kostenlos herunterladen können:<br />');
        document.writeln('<a href="http://www.adobe.com/de/products/flashplayer/" target="_blank">» http://www.adobe.com/de/products/flashplayer/</a><br />');
        document.writeln('<a href="javascript:document.getElementById(\'errorbox\').style.display=\'none\'" style="font-size:82%; color:#666; display:block; float: right">Hinweis schließen [x]</a><br class="clearFloat" />');
        document.writeln('</div>');
    }
    if (swf9) {
        document.getElementById(hideContainer).style.display = "none";
    }
}

function doAdStuff() {
    if (LeaderBoard == 1 || fullsize == 1) {
        var rubrikenAdContainer = document.getElementById("rubrikenAd");
        if (fullsize) document.getElementById("rubrikenAd").style.height = "60px";
    } else {
        var topborder = "border-top";
        document.getElementById("rubrikenAd").style.display = "none";
        document.getElementById("mainHeader").style.topborder = "none";
    }
    if (contentad && document.getElementById("contentAd")) {
        document.getElementById("contentAd").style.display = "block";
    }
    if (!fustyUserAgent && (promo || halfpage) && document.getElementById("promoAd")) {
        var promoAdContainer = document.getElementById("promoAd");
        if (halfpage) {
            resizeLayout();
            var anz_element = document.createElement("div");
            var anz_wording = document.createTextNode("Anzeige");
            anz_element.setAttribute("style", "text-align:left;");
            anz_element.appendChild(anz_wording);
        } else {
            document.getElementById("promoAd").style.display = "block";
            document.getElementById("promoAd").style.visibility = "visible";
        }
    }
    if (document.getElementById("floater")) {
        if (LeaderBoard) {
            document.getElementById("floater").style.top = '128px';
        }
        else if (fullsize) document.getElementById("floater").style.top = "98px";
        else document.getElementById("floater").style.top = "23px";
    }
    if ((textcontent || textteaser) && document.getElementById("textAd")) document.getElementById("textAd").style.display = "block";
}

function doAdStuff2() {
    if (LeaderBoard == 1 || fullsize == 1) {
        var rubrikenAdContainer = document.getElementById("rubrikenAd");
        if (fullsize) document.getElementById("rubrikenAd").style.height = "60px";
    } else {
        var topborder = "border-top";
        document.getElementById("rubrikenAd").style.display = "none";
        document.getElementById("mainHeader").style.topborder = "none";
    }
    if (contentad && document.getElementById("contentAd")) {
        document.getElementById("contentAd").style.display = "block";
    }
    if (!fustyUserAgent && (promo || halfpage) && document.getElementById("promoAd")) {
        var promoAdContainer = document.getElementById("promoAd");
        if (halfpage) {
            resizeLayout();
            var anz_element = document.createElement("div");
            var anz_wording = document.createTextNode("Anzeige");
            anz_element.setAttribute("style", "text-align:left;");
            anz_element.appendChild(anz_wording);
        } else {
            document.getElementById("promoAd").style.display = "block";
            document.getElementById("promoAd").style.visibility = "visible";
        }
    }
    if (document.getElementById("floater")) {
        if (LeaderBoard) {
            document.getElementById("floater").style.top = '128px';
        }
        else if (fullsize) document.getElementById("floater").style.top = "98px";
        else document.getElementById("floater").style.top = "23px";
    }
}

function adjustRightCol() {
    if (document.getElementById("left") && document.getElementById("right") && !no_col_adj) {
        var left = document.getElementById("left").offsetHeight;
        var right = document.getElementById("right").offsetHeight;
        if (left > right) {
            document.getElementById("right").style.height = (left - 20) + "px";
            right = document.getElementById("right").offsetHeight;
        } else {
            document.getElementById("right").style.margin = "0 0 20px 0";
        }
    }
}
var markers = new Array();
var geoMap = {
    settings: {
        title: "Geo Map",
        type: "selectMap",
        markerType: "flag",
        size: "small",
        targetContainer: "mapContainer",
        initLat: 0,
        initLng: 0,
        initZoom: 5,
        fallbackLat: '10.3',
        fallbackLng: '41.7',
        fallbackZoom: 6,
        hasControls: 'on',
        typeControl: 'on',
        overviewMap: false,
        markCenter: 'off',
        zoomControl: 'small',
        mapType: 'G_PHYSICAL_MAP',
        clickable: 'on',
        draggable: 'on',
        onClickFuncs: {
            getLocation: {
                coutryTextField: '#countryInput',
                cityTextField: '#locationInput',
                placeTextField: '#placeInput',
                lngTextField: '#lngInput',
                latTextField: '#latInput'
            }
        },
        onMove: {}
    },
    initialized: false,
    map: null,
    gCoder: null,
    gDir: null,
    init: function (initObj) {
        if (GBrowserIsCompatible()) {
            GUnload();
            $.each(geoMap.settings, function (key, val) {
                if (initObj[key]) {
                    if (key == 'onClickFuncs') {
                        geoMap.settings.onClickFuncs = $.extend(geoMap.settings.onClickFuncs, initObj[key]);
                    }
                    else {
                        geoMap.settings[key] = initObj[key];
                    }
                }
            });
            try {
                this.map = new GMap2(document.getElementById(geoMap.settings.targetContainer));
            }
            catch (e) {
                alert(e);
            }
            if (geoMap.settings.hasControls == 'on') {
                if (geoMap.settings.zoomControl == 'small') {
                    this.map.addControl(new GSmallMapControl());
                }
                else {
                    this.map.addControl(new GLargeMapControl());
                }
            }
            if (geoMap.settings.typeControl == 'on') {
                this.map.addControl(new GMapTypeControl());
            }
            if (this.settings.initLat == 0 && this.settings.initLng == 0) {
                try {
                    this.map.setCenter(new GLatLng(this.settings.fallbackLat, this.settings.fallbackLng), this.settings.fallbackZoom, G_HYBRID_MAP);
                }
                catch (e) {
                    console.warn(e);
                }
            }
            else {
                try {
                    this.map.setCenter(new GLatLng(this.settings.initLat, this.settings.initLng), this.settings.initZoom, G_HYBRID_MAP);
                }
                catch (e) {
                    console.warn(e);
                }
                if (this.settings.markCenter == 'on') {
                    this.markLatLng(this.settings.initLat, this.settings.initLng);
                }
            }
            this.initialized = true;
            if (this.settings.clickable == 'on') {
                $.each(geoMap.settings.onClickFuncs, function (func, params) {
                    GEvent.addListener(geoMap.map, "click", function (marker, point) {
                        if (!point) {
                            if (marker) {
                                point = marker.getPoint();
                            }
                            else {
                                point = new GLatLng();
                            }
                        }
                        try {
                            geoMap[func].apply("test", [marker, point, params]);
                        }
                        catch (e) {
                            console.warn(e);
                        }
                    });
                });
            }
        }
    },
    getLocation: function (marker, point, params) {
        if (!marker) {
            var lat = point.lat();
            var lng = point.lng();
            $(params.lngTextField).val(lng);
            $(params.latTextField).val(lat);
        }
    },
    setLocation: function (lat, lng, zoom) {
        var newZooom = zoom || 8;
        var point = new GLatLng(lat, lng);
        geoMap.map.setCenter(point, newZooom);
    },
    getMarkerIcon: function (index) {
        if (geoMap.settings.markerType == "flag") {
            var icon = new GIcon();
            icon.image = "http://www.geo.de/images/GEO/flag" + index + ".png";
            if (markerStyle == "-fussball" && (specialMarkers.indexOf(index) != -1)) icon.image = "http://www.geo.de/images/GEO/flag" + markerStyle + ".png";
            icon.shadow = "http://www.geo.de/images/GEO/flag_shadow.png";
            icon.iconSize = new GSize(60, 35);
            icon.shadowSize = new GSize(60, 35);
            icon.iconAnchor = new GPoint(30, 35);
            icon.infoWindowAnchor = new GPoint(25, 5);
            return icon;
        }
        else if (geoMap.settings.markerType == "smallflag") {
            var icon = new GIcon();
            icon.image = "http://www.geo.de/images/GEO/flag.png";
            icon.shadow = "http://www.geo.de/images/GEO/shadow-flag.png";
            icon.iconSize = new GSize(40, 23);
            icon.shadowSize = new GSize(40, 23);
            icon.iconAnchor = new GPoint(20, 23);
            icon.infoWindowAnchor = new GPoint(15, 3);
            return icon;
        }
        else return "";
    },
    setMarker: function (point, params, index, descriptions, bubbleContent, bubbleWidth) {
        index += 1;
        marker = new GMarker(point, geoMap.getMarkerIcon(index));
        GEvent.addListener(marker, "click", function () {
            if (bubbleWidth == 250) {
                var tempHtml = "<div style=\"width:300px\"><h3>" + descriptions[index - 1] + "</h3><small><i>" + coords_strings[index - 1] + "</i><br />" + bubbleContent[index - 1] + "</div>";
            } else {
                var tempHtml = "<div style=\"width:200px\"><h3>" + descriptions[index - 1] + "</h3><small><i>" + coords_strings[index - 1] + "</i><br />" + bubbleContent[index - 1] + "</div>";
            }
            geoMap.map.openInfoWindowHtml(point, tempHtml);
        });
        markers[index] = marker;
        geoMap.map.addOverlay(markers[index]);
    }
}

function sbOver(text) {
    if (text == '') {
        text = '...';
    } else {
        text = ' <strong>' + text + '</strong>';
    }
    document.getElementById('sbText').innerHTML = text;
}

function sbDo(was) {
    var id_parameter = gup('id');
    var clean_location = location.href.split("?");
    var sbcontent = teasertext;
    if (clean_location[0].match(/#$/)) {
        clean_location = clean_location[0].substring(0, clean_location[0].length - 1);
    } else {
        clean_location = clean_location[0];
    }
    if (id_parameter != "") {
        addIdParam = "&id=" + id_parameter;
        sburl = encodeURIComponent(clean_location + "?utm_source=social-bookmarks&utm_medium=bookmarks&utm_campaign=geo-bookmarks" + addIdParam);
    }
    else {
        sburl = encodeURIComponent(clean_location + "?utm_source=social-bookmarks&utm_medium=bookmarks&utm_campaign=geo-bookmarks");
    }
    var clean_title = document.title.split("-");
    sbtitle = "GEO.de - " + encodeURIComponent(clean_title[1]);
    switch (was) {
    case 'delicious':
        window.open('http://del.icio.us/post?url=' + sburl + '&quelle=bm&title=' + sbtitle);
        break;
    case 'wong':
        window.open('http://www.mister-wong.de/index.php?action=addurl&bm_url=' + sburl + '&bm_description=' + sbtitle);
        break;
    case 'blinkList':
        window.open('http://www.blinklist.com/index.php?Action=Blink/addblink.php&Description=&Url=' + sburl + '&Title=' + sbtitle);
        break;
    case 'yahoo':
        window.open('http://myweb2.search.yahoo.com/myresults/bookmarklet?u=' + sburl + '&t=' + sbtitle);
        break;
    case 'yigg':
        window.open('http://yigg.de/neu?exturl=' + sburl + '&exttitle=' + sbtitle);
        break;
    case 'furl':
        window.open('http://www.furl.net/storeIt.jsp?u=' + sburl + '&t=' + sbtitle);
        break;
    case 'oneview':
        window.open('http://beta.oneview.de:80/quickadd/neu/addBookmark.jsf?URL=' + sburl + '&title=' + sbtitle);
        break;
    case 'folkd':
        window.open('http://www.folkd.com/submit/page/' + sburl);
        break;
    case 'linkarena':
        window.open('http://linkarena.com/bookmarks/addlink/?url=' + sburl + '&title=' + sbtitle + '&desc=&tags=');
        break;
    case 'google':
        window.open('http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk=' + sburl + '&title=' + sbtitle);
        break;
    case 'webnews':
        window.open('http://www.webnews.de/einstellen?url=' + sburl + '&title=' + sbtitle);
        break;
    case 'technorati':
        window.open('http://technorati.com/faves?add=' + sburl);
        break;
    case 'tausendreporter':
        window.open('http://tausendreporter.stern.de/submit.php?url=' + sburl);
        break;
    case 'shortnews':
        window.open('http://www.shortnews.de/submitsource.cfm?source=' + sburl);
        break;
    case 'stumbleupon':
        window.open('http://www.stumbleupon.com/submit?url=' + sburl);
        break;
    case 'digg':
        window.open('http://digg.com/submit?phase=2&url=' + sburl);
        break;
    case 'live':
        window.open('http://favorites.live.com/quickadd.aspx?marklet=1&mkt=de-de&url=' + sburl + '&title=' + sbtitle);
        break;
    case 'facebook':
        window.open('http://www.facebook.com/share.php?u=' + sburl);
        break;
    case 'myspace':
        window.open('http://www.myspace.com/Modules/PostTo/Pages/?t=' + sbtitle + '&u=' + sburl + '&l=1&c=' + sbcontent);
        break;
    }
}

function gup(name) {
    name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
    var regexS = "[\\?&]" + name + "=([^&#]*)";
    var regex = new RegExp(regexS);
    var results = regex.exec(window.location.href);
    if (results == null) return "";
    else return results[1];
}

function getTopVideosTrailingWeek() {
	//addScriptTag("topVideos", "http://api.brightcove.com/services/library?command=find_all_videos&token=CNnmbZ-jMglpvUShxdYM16UleH57pO_wyHnfYYhQRns.&fields=id,name,thumbnailURL,playsTrailingWeek,linkURL,length, referenceId&sort_by=plays_trailing_week&page_size=10", "response");
	addScriptTag("topVideos", "http://api.brightcove.com/services/library?command=find_all_videos&token=CNnmbZ-jMglpvUShxdYM16UleH57pO_wyHnfYYhQRns.&sort_by=plays_trailing_week&page_size=10", "response_video_sidebar");
}

function response_video_sidebar(jsonData) {
	var resp = document.getElementById("videoCatapult");
	for (var i=0; i<jsonData["items"].length; i++) {
		title = jsonData["items"][i];
		if (title.linkURL != undefined)
		{
		    var titleMin = parseInt(title.length/60000);
			var titleS = title.length/1000 - titleMin*60;
			titleS = titleS.toFixed(0);
			var str = "";
			str += '<a title="' + title.name + '" href="' + title.linkURL + '">';
			str += '<img src="' + title.thumbnailURL + '" width="143" height="107" alt="" title="" style="margin-top:0px;margin-bottom:0px"/><br /><p style="text-align:right;color:#737373; padding-right:2px;line-height:16px; background-image:url(http://www.geo.de/images/GEO/video/videoplay.gif);";>'+ titleMin + ':'+ titleS +'</p>';
			//str += '<p class="displayName">' + title.name + '</p>';	
			//str += '<p class="views">viewed ' + title.playsTrailingWeek + ' times</p>';
			str += '</a>';
			resp.innerHTML += str;
		}
		 $('#videoCatapult').cycle({ 
			fx:     'fade', 
			speed:  'slow', 
			timeout: 5000000, 
			next:   '#next', 
			prev:   '#prev' ,
			after:   onAfter
		 });
 
		 $('#videoschleuder').cycle('stop');
			}
}