// JavaScript Document

/**
 * Das RPO-Objekt definieren, falls es noch nicht existiert (was hier normal sein sollte).
 * Hierein koennen wir die ganzen Funktionen reinpacken, wo sie gegen Ueberschreiben
 * durch Ad-Server etc. geschuetzt sind.
 */
if (typeof RPO == "undefined") {
    var RPO = new Object();
}

/**
 * Auf dem Mac sind die benutzten Fonts einen Tick groesser als unter Windows. Wir koennen
 * im Stylesheet spezielle Mac-Regeln einbauen, die die Fonts auf etwa 98% skalieren. Dafuer
 * setzt das Javascript hier abhaengig von der Plattform eine Klasse "mac" an das Element HTML.
 * Dieses Snippet wird _nicht_ mittels onload ausgefuehrt, da erstens das HTML-Element schon
 * geladen ist, und man zweitens, wenn es "onload" ausgefuehrt wird, ein Flackern sieht.
 */
if (navigator.platform.indexOf('Mac') > -1) {
    $('html').addClass('mac');
}

/* Anzeigen */
function OAS_RICH() {}

function Go(x,t)
{
    if (x == "none") {
        return;
    } else {
        if (typeof(t) == 'undefined') {
            location.href = x;
        } else {
            var newwin = window.open(x,t);
            if (newin) newwin.focus();
        }
    }
}

function owin(datei,name,width,height)
{
    var sw = screen.width;
    var sh = screen.height;
    if (width>sw-50) { width = sw-50; }
    if (height>sh-100) { height = sh-100; }
    var w = window.open(datei,name,'width='+width+',height='+height+',scrollbars=yes,directories=no,'+
                        'resizable=yes,toolbar=no,location=no,status=no,menubar=no');
    if (w) { w.focus(); }
    return w;
}

function owinfull(datei,name,width,height)
{
    var sw = screen.width;
    var sh = screen.height;
    if (width>sw-50) { width = sw-50; }
    if (height>sh-100) { height = sh-100; }
    var w = window.open(datei,name,'width='+width+',height='+height+',scrollbars=yes,directories=yes,'+
                        'resizable=yes,toolbar=yes,location=yes,status=yes,menubar=yes');
    if(w) { w.focus(); }
    return w;
}

function doopener(path)
{
    if (top.window.opener && !top.window.opener.closed) {
        top.window.opener.location=path;
        top.window.close();
        // top.window.opener.focus();
        return false;
    }
    return true;
}

function doremote(path)
{
    if (top.window.opener && !top.window.opener.closed) {
        top.window.opener.location=path;
        return false;
    }
    return true;
}

/**
 * das "onload" kann aus dem <body> raus!
 */
RPO.displayTime = function(elementId)
{
    if ($("#"+elementId).length == 0)
        return;

    var now = new Date();
    var h = now.getHours();
    var m = now.getMinutes();
    if (m<10) { m = "0" + m; }
    var s = now.getSeconds();
    if (s<10) { s = "0"+s; }
    var D = now.getDate();
    var M = now.getMonth()+1;
    var Y = now.getFullYear();
    var output = D+"."+M+"."+Y+" "+h+":"+m+":"+s+" Uhr ";

    $("#"+elementId).text(output);
    window.setTimeout(function() { RPO.displayTime(elementId); } ,1000);
}

/**
 * Base64-Kodierung und -Dekodierung.
 */
RPO.keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + //all caps
             "abcdefghijklmnopqrstuvwxyz" + //all lowercase
             "0123456789+/=";               //all numbers plus +

RPO.encode64 = function(inp)
{
    var chr1,chr2,chr3,enc3,enc4,i=0,out="";
    while(i<inp.length){
        chr1=inp.charCodeAt(i++);if(chr1>127) chr1=88;
        chr2=inp.charCodeAt(i++);if(chr2>127) chr2=88;
        chr3=inp.charCodeAt(i++);if(chr3>127) chr3=88;
        if(isNaN(chr3)) {enc4=64;chr3=0;} else enc4=chr3&63
        if(isNaN(chr2)) {enc3=64;chr2=0;} else enc3=((chr2<<2)|(chr3>>6))&63
        out+=RPO.keyStr.charAt((chr1>>2)&63)+
             RPO.keyStr.charAt(((chr1<<4)|(chr2>>4))&63)+
             RPO.keyStr.charAt(enc3)+
             RPO.keyStr.charAt(enc4);
    }
    return encodeURIComponent(out);
}

RPO.decode64 = function(inp)
{
    inp = inp.replace(/<.*?>/g,"");
    inp = inp.replace(/\n|\r| |\t/g,""); inp=inp.replace(/=/g,"");
    var out = ""; //This is the output
    var chr1, chr2, chr3 = ""; //These are the 3 decoded bytes
    var enc1, enc2, enc3, enc4 = ""; //These are the 4 bytes to be decoded
    var i = 0; //Position counter

    inp = inp.replace(/[^A-Za-z0-9\+\/\=]/g, "");

    do { //Heres the decode loop.

        //Grab 4 bytes of encoded content.
        enc1 = RPO.keyStr.indexOf(inp.charAt(i++));
        enc2 = RPO.keyStr.indexOf(inp.charAt(i++));
        enc3 = RPO.keyStr.indexOf(inp.charAt(i++));
        enc4 = RPO.keyStr.indexOf(inp.charAt(i++));

        chr1 = (enc1 << 2) | (enc2 >> 4);
        chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
        chr3 = ((enc3 & 3) << 6) | enc4;

        //Start to output decoded content
        out = out + String.fromCharCode(chr1);

        if (enc3 != 64) {
          out = out + String.fromCharCode(chr2);
        }
        if (enc4 != 64) {
          out = out + String.fromCharCode(chr3);
        }

        //now clean out the variables used
        chr1 = chr2 = chr3 = "";
        enc1 = enc2 = enc3 = enc4 = "";

    } while (i < inp.length); //finish off the loop

    return out;
}

function whichBrowser()
{
    var browser = navigator.appName;
    var version = navigator.appVersion.substring(0, 1);
    var agent = navigator.userAgent;
    if ((browser == "Microsoft Internet Explorer") && (version >= 4)) { return 'ie'; }
    // Firefox und Netscape
    if ((browser == "Netscape") && (version >= 4 && version < 5)) { return 'ns'; }
    // nur Netscape
    if ((browser == "Netscape") && (agent.search(/Netscape/)) > 0) { return 'ns7'; }
    return '';
}

function setHomePage(siteURL)
{
    var browser = whichBrowser();
    if (browser == 'ie') {
        document.body.style.behavior = "url(#default#homepage)";
        document.body.setHomePage(siteURL);
    } else {
        document.location.href = '/info/startseite.php';
    }
}

function addToFavorites(siteURL, description)
{
    var browser = whichBrowser();
    if (browser == 'ie') {
        window.external.AddFavorite(siteURL, description);
    } else if (browser == 'ns') {
        alert("Drücken Sie Strg+D zum Bookmarken dieser Seite!");
    } else {
        alert("Die Seite kann nicht automatisch den Favoriten hinzugefügt werden!");
    }
}

/**
 * Eilmeldungs-Code.
 */
RPO.eilmeldungFlag = false;
RPO.eiltext = '';
RPO.eiltimeout = 30000;

/**
 * Ajax-Worker, der regelmaessig nachschaut, ob es eine Eilmeldung gibt.
 */
RPO.eilmeldung = function() {
    if ($("#eilmeldung").length == 0 || $("#mainarea").length == 0)
        return;
    $.get("/alive/eilmeldung.html",
        { id: (new Date()).getTime() },
        function (data) {
            RPO.showEilmeldung(data);
        }
    );
    if (RPO.eiltimeout <= 90000) {
        RPO.eiltimeout += 1000;
    }
    if (RPO.eiltimeout <= 90000 || RPO.eilmeldungFlag) {
        window.setTimeout(function() { RPO.eilmeldung(); }, RPO.eiltimeout);
    }
};

/**
 * Callback vom Ajax-Worker mit dem Inhalt von /alive/eilmeldung.html
 * Wenn dieses Objekt Inhalt hat, wird es eingeblendet und vom Scroller
 * angezeigt.
 */
RPO.showEilmeldung = function(data) {
    if (!data || data == '') {
        return;
    }
    var result = eval('(' + data + ')');
    // Wenn die Meldung sich nicht geaendert hat, dann ist nichts zu tun
    if (result.meldung == RPO.eiltext) {
        return;
    }

    if (result.meldung != '') {
        // Eilmeldungstext vorhanden ...

        // Meldungstext speichern
        RPO.eiltext = result.meldung;

        var eilmeldung = '';
        if (result.link != '') {
            eilmeldung = '<a href="' + result.link + '" target="_top">' + result.meldung + '</a>';
        } else {
            eilmeldung = result.meldung;
        }

        if (!RPO.eilmeldungFlag) {
            if ($("#produktmarke").length) {
                $("#mainarea").css("top","160px");
                $("#eilmeldung").css("top","100px");
            } else {
                $("#mainarea,#toparea").animate(
                    { top: "+=60px" }, "slow"
                );
            }
            $("#eilmeldung").css( { height: "60px", display: "block" });
        }

        // Eilmeldung ist sichtbar
        RPO.eilmeldungFlag = true;

        $("#scrolling_container_eilmeldung").html('<div class="eilmeldung">' + eilmeldung + '</div>');
        RPO.eilmeldungScroller("scrolling_container_eilmeldung");

    } else {

        RPO.eiltext = '';
        // Eilmeldungstext ist leer ...
        if (RPO.eilmeldungFlag) {
            $("#eilmeldung").hide();
            $("#scrolling_container_eilmeldung").empty();
            $("#mainarea,#toparea").animate(
                { top: "-=60px" }, "fast"
            );
        }
      RPO.eilmeldungFlag = false;
    }
}

/**
 * Dieser Scroller ist fuer die Eilmeldung zustaendig.
 * containerId: ID des Containers, der den Text enthaelt.
 */
RPO.eilmeldungScroller = function(containerId) {
    var $innerDiv = $("#"+containerId+" div");
    $innerDiv.
        css( { whiteSpace: "nowrap", position: "relative" } ).
        wrapInner( "<b style=\"padding-right:1em\"></b>" ).
        append( $innerDiv.html() + $innerDiv.html() );
    var amount = $("#"+containerId+" b:first").outerWidth();
    $innerDiv.width(amount*3);
    var speed = amount * 15;

    var scrollIt = function() {
        $innerDiv.animate(
            { "left": "-=" + amount + "px" },
            speed,
            "linear",
            function () {
                $innerDiv.css("left","0");
                scrollIt();
            }
        );
    };
    scrollIt();
};

/**
 * Dieser Scroller ist fuer z.B. den Liveticker-Kasten
 * auf der Sportseite zustaendig.
 * containerId: ID des Containers, der die zu scrollenden DIVs enthaelt
 * className: Klassenname der zu scrollenden DIVs.
 */
RPO.textScroller = function (containerId, className) {
    var $first = $("#"+containerId+" ."+className+":first");
    var $container = $("#"+containerId);
    $container.animate(
        { "scrollTop": "+=" + $first.outerHeight() + "px" },
        "slow",
        function () {
            $first.appendTo($container);
            window.setTimeout(function() { RPO.textScroller(containerId, className); }, 2000 )
            $container.scrollTop(0);
        }
    );
};

/**
 * Dieses Element rotiert eine Liste von DIVs in einem Container. Die DIVs werden
 * nacheinander aus- und eingeblendet.
 * containerID: ID des Containers, der die zu rotierenden DIVs enthaelt.
 * className: Klassenname der zu rotierenden DIVs.
 * numVisible: wieviele DIVs sind gleichzeitig sichtbar.
 * delay: in wieviel Millisekunden erfolgt die naechste Rotation.
 */
RPO.MultiTeaserRotation = function (containerId, className, numVisible, delay) {
    var from = 0;
    var timeout;
    var animstop = false;

    // Der Selektor fuer die <div>'s, die rotiert werden sollen. Das
    // sind alle <div>'s innerhalb #containerId mit
    // class="className"
    var selektor = "#"+containerId+" ."+className;

    // Anzahl der zu rotierenden Elemente; auf ein Vielfaches von
    // numVisible begrenzen, sonst wird's haesslich.
    var numDivs = $(selektor).length;
    if (numDivs == 0)
        return;
    numDivs -= numDivs % numVisible;
    if (numDivs == numVisible)
        return;

    // Zeit zwischen zwei Durchlaeufen in Millisekunden; delay ist
    // ein optionaler Parameter, default 3000.
    var theDelay = delay || 3000;

    // Funktion fuer die Rotation; es werden immer 4 <div>'s
    // ausgeblendet und dann die naechsten 4 eingeblendet.
    // Derweil registriert sich die Funktion schon mal fuer den
    // naechsten Aufruf.
    var doRotation = function() {
        if (!animstop) {
            window.clearTimeout(timeout);
            from %= numDivs;
            var sliceInFrom = (from+numVisible)%numDivs;
            var sliceInTo = (from+2*numVisible)%numDivs;
            $(selektor).slice(from, from+numVisible).css('display','none');
            // ( function() {
                if ( sliceInTo > sliceInFrom ) {
                    $(selektor).slice(sliceInFrom, sliceInTo).css('display','block'); //.customFadeIn("fast");
                } else {
                    $(selektor).slice(sliceInFrom).css('display','block'); //.customFadeIn("fast");
                }
            //});
            from = from+numVisible;
        }
        timeout = window.setTimeout(function() { doRotation(); }, theDelay);
    }
    // Rotation mit Verzoegerung starten.
    timeout = window.setTimeout(function() { doRotation(); }, theDelay);
    $("#"+containerId).hover(
        function (event) {
            animstop = true;
        },
        function (event) {
          animstop = false;
        }
    );
}

/**
 * Das Modul auf den Regio-Stadt-Seiten, bei dem mehrere Tabs mit Städten untereinander
 * stehen und der Content für die Tabs jeweils per Ajax geholt wird.
 */
RPO.klickmodulChangeContent = function(sElementTo,sParentElement,sUrl,sContentDiv,mid)
{
    // Inhalt der ContentBox vor der ersten Änderung sichern
    // Benutzt man this.variable, verhält die Variable sich wie eine in C
    // oder PHP als "static" deklarierte Variable
    if (!this.saveFirst) {
        this.saveFirst = $("#"+sContentDiv).html();
    }
    if (mid && mid.length) {
        mid='_'+mid;
    } else {
        mid = '';
    }
    document.getElementById("klickmodul_link"+mid).href=sUrl.replace(/\/regional/g,"")+"/indexlist.html";
    sUrl="/public/extern/module/cross_teaser"+sUrl;

    $("#"+sParentElement+" div").removeClass("sel");
    $("#"+sElementTo).addClass("sel");

    // link ohne "/nachrichten" am ende -> ersten box-inhalt wiederherstellen
    if (!sUrl.match(/\/nachrichten$/)) {
        $("#"+sContentDiv).html(this.saveFirst);
        $("#div_klickmodul_link"+mid).css("display","none");
    } else {
        $("#div_klickmodul_link"+mid).css("display","block");
        $.get(sUrl, function (data) {
            $("#"+sContentDiv).html(RPO.decode64(data));
        });
        RPO.reloadIVW();
    }
}

/*
 * Diese Funktion sollte noch weiter "modularisiert" werden, damit man sie
 * unabhängig von den Bildershows benutzen kann. In dieser Form ist
 * RPO.Hitpages abhängig von RPO.slide.
 * Was auf alle Fälle noch gemacht werden sollte:
 * - Verlinkung konfigurieren.
 * - Startwert für die Numerierung.
 */
RPO.Hitpages = function (centerOn, numPics, selector, width) {
    var text = "";
    var theClass;
    var width = width || 4;
    var from  = centerOn - width;
    var to    = centerOn + width;

    if (RPO.slide.indexPage == 1 ) {
       numPics++; //Indexseite dazu
    }
    if (from < 0) {
        to -= from;
        from = 0;
    }
    if (from > 0 && numPics > 9) {
        text = '<a class="hpl nlm" href="#" onclick="RPO.slide.load(0);return false">1</a>';
    }
    if (from > 1 && numPics > 9) {
        text += '<span class="dots">...</span>';
    }
    if (to >= numPics-1) {
        from -= to-numPics+1;
        to = numPics-1;
        if (from < 0) from = 0;
    }
    for (var i=from; i<=to; i++) {
        theClass = "hpl";
        if (i == from && i != 1) {
            theClass = "hpl nlm";
        }
        if (i == centerOn) {
            text += '<a class="'+theClass+'" href="#"><span class="ausgewaehlt">'+(i+1)+'</span></a>';
        } else {
            text += '<a class="'+theClass+'" href="#" onclick="RPO.slide.load('+i+');return false">'+(i+1)+'</a>';
        }
    }
    if (to < numPics-2) {
        text += '<span class="dots">...</span>';
    }
    if (to < numPics-1) {
        theClass = "hpl nlm";
        if (to == numPics-2) theClass = "hpl";
        text += '<a class="'+theClass+'" href="#" onclick="RPO.slide.load('+(numPics-1)+');return false">'+numPics+'</a>';
    }

    var previous = centerOn - 1;
    if (previous < 0) previous = numPics - 1;
    var next = centerOn + 1;
    if (next == numPics) next = 0;
    text = '<div class="right"><a href="#" class="link" onclick="RPO.slide.load('+next+');return false"><b>weiter</b></a></div>'
         + '<div class="left"><a href="#" class="zurueck linkleft" onclick="RPO.slide.load('+previous+');return false"><b>zur&uuml;ck</b></a></div>'
         + text;

    $(selector).html(text);
}

/**
 * onclick-Handler, um zu einem neuen Bildershow-Bild zu wechseln.
 */
RPO.slide = {
    numPics:   1,
    indexPage: 1,
    centerImg: 1,
    refback: '',
    ivwInline: 0,
    clicked:   0,
    load: function (n) {
        this.clicked++;
        if (n == this.numPics + this.indexPage) {
            n = 0;
        } else if (n == this.numPics ) {
            var url = window.location.hostname+window.location.pathname;
            var url_search = window.location.search;
            if ( url_search.search(/skip=/) != -1 ) {
                url_search = url_search.replace( /skip=(\d+)/g , "skip="+(this.numPics) );
            } else if ( url_search.substr(0,1) == '?' ) {
                url_search = url_search + "&skip="+(this.numPics);
            } else {
                url_search = url_search + "?skip="+(this.numPics);
            }
            if (this.refback && url_search.search(/refback=/) == -1) {
                if ( url_search.search(/\?/) != -1 ) {
                   url_search += "&refback="+this.refback;
                } else {
                   url_search += "?refback="+this.refback;
                }
            }
            window.location.href = url_search;
        } else if (n > this.numPics) {  //???
            return;
        }

        if ( $("#klick_skip")[0] ) { //gilt nur für Klick
            $("#klick_skip")[0].value = n;
        }

        var div = $("#slide_"+n);
        var img = $("#slide_img_"+n);
        if (div.length) {
            if (img.length) {
                if (img.attr('src') != img.attr('slide:src')) {
                    img.attr('src', img.attr('slide:src'));
                }
            }
            RPO.Hitpages(n, this.numPics, "div.hitpages");
            $("div.slidecontainer:visible").customFadeOut('fast',function() {
                $("#slide_"+n).customFadeIn('fast');
                // Das Bild vertikal zentriert im Container platzieren.
                // Muss hier passieren, vorher ist die img.height() nicht definiert.
                if (img.length && RPO.slide.centerImg == 1) {
                  //img.css("padding-top",0);
                  var height = img.height();
                  if (height > 100) { //Bild nicht komplett geladen
                    img.css("padding-top", ((325-height) / 2)+"px");
                  } else {
                    img.css("padding-top",0);
                  }
                }
            });
            // IVW-Pixel, Google-Analytics und Werbung neu laden.

            var pixel = document.getElementById('ivwpix');
            if (pixel !== null) {
                var dpath = null;
                if (this.ivwInline == 0) {
                    var reg = /.*\/CP\/[^;]+;(.*?)\/[^/]+\/[0-9]+\?r=/;
                    if ((result = reg.exec(pixel.src)) !== null) {
                        dpath = result[1];
                        dpath += "/"+$("#slide_"+n).attr("slide:id");
                    }
                }
                if (this.ivwInline == 0 || this.clicked > 1 ) {
                    RPO.reloadIVW(null,dpath);
                }
            }
            if (document.getElementById('toprightad')) {
                document.getElementById('toprightad').contentWindow.location.reload();
            }
            if (document.getElementById('middlead')) {
                document.getElementById('middlead').contentWindow.location.reload();
            }
        }
    }
};

/**
 * http://blog.bmn.name/2008/03/jquery-fadeinfadeout-ie-cleartype-glitch/
 * While using the jQuery  javascript library today at work, I noticed a
 * glitch under IE7. When fading a html node with the .fadeIn() and .fadeOut()
 * functions in jQuery, IE drops the windows Cleartype rendering; which results
 * in very ugly text.
 */
(function($) {
    $.fn.customFadeIn = function(speed, callback) {
        $(this).fadeIn(speed, function() {
            if(jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if(callback != undefined)
                callback();
        });
    };
    $.fn.customFadeOut = function(speed, callback) {
        $(this).fadeOut(speed, function() {
            if(jQuery.browser.msie)
                $(this).get(0).style.removeAttribute('filter');
            if(callback != undefined)
                callback();
        });
    };
})(jQuery);

/**
 * switch tab in "reitermodul" box
 */
function switch_tab(base,num)
{
    var el;
    for (var i=1; ; i++) {
        if (! (el = document.getElementById(base+'_'+i)) )
            return;
        if (i == num) {
            el.style.display = '';
            document.getElementById(base+'_reiter_'+i).className='aktiv';
        } else {
            el.style.display = 'none';
            document.getElementById(base+'_reiter_'+i).className='';
        }
    }
}

/**
 * Reload des IVW-Pixels; wir braeuchten so etwas in den Bildershows
 * noch fuer das Neuladen der Werbung.
 */
RPO.reloadIVW = function (sktg,path,referer,path_search,path_replace) {
    var pixel = document.getElementById('ivwpix');
    if (pixel === null) {
        return;
    }
    var pixelsrc = pixel.src;
    if (pixelsrc == null) {
        return;
    }
    if (!sktg || !path || !referer ) {
        var reg = /.*\/CP\/([^;]+);(.*)\/[0-9]+\?r=(.*)&.*/;
        if ((result = reg.exec(pixelsrc)) !== null) {
            if (!sktg) { sktg = result[1]; }
            if (!path) { path = result[2]; }
            if (!referer) { referer = result[3] || ""; }
        }
    }
    if (path_search && path_replace) {
        path=path.replace(path_search , path_replace);
    }
    var ivwrand = Math.floor(Math.random()*1000000);
    if (sktg && path) {
        var newsrc = 'http://rponl.ivwbox.de/cgi-bin/ivw/CP/'+sktg+';'+path+'/'+ivwrand+'?r='+referer+'&amp;d='+ivwrand;
        pixel.src = newsrc;
    }

    var trackpath = document.location.hostname+document.location.pathname;
    trackpath = trackpath.replace(/\/+$/,'');
    //pageTracker._trackPageview( trackpath+path.substr( path.lastIndexOf("/") ) );
    _gaq.push(['_trackPageview']);
}

// ehemals member.js
RPO.setUserName = function () {
    var userid = 0;
    var login_name = "";
    var e, cookie, tmp;
    var reg, result;
    if (document.cookie) {
        reg = /RPOINFID=([^;]*)/;
        if ((result = reg.exec(document.cookie)) !== null) {
            cookie = result[1];
            if (cookie !== undefined) {
                tmp = cookie.split("-");
                if (tmp.length > 3) {
                    userid = parseInt(tmp[0]);
                    login_name = unescape(unescape(unescape(tmp[2])));
                }
            }
        }
    }
    if (userid > 0) {
        if ( (e = document.getElementById('login_name')) ) {
            e.innerHTML = '<a href="/services/personal/" title="mein RP ONLINE">'+login_name+'</a>';
        }
        if ( (e = document.getElementById('guest')) ) {
            e.style.display = 'none';
        }
        if ( (e = document.getElementById('user')) ) {
            e.style.display = 'block';
        }
    }
}

// ehemals reddot.js
RPO.reddot = function() {
    // unnoetige Calls auf den Server unterdruecken.
    if (document.cookie && document.cookie.indexOf('kuh=')>-1 && document.cookie.indexOf('RPOINFID=')>=-1 && typeof kuh == "object") {
        kuh.allowed = 0;
        $.get("/public/extern/reddot.php",
              { object_id: kuh.oid, version_id: kuh.vid },
              function(content) {
                  $("#editlink").html(content);
                  kuh.allowed = 1;
              }
        );
    }
}

jQuery(document).ready(function() {
    RPO.setUserName();
    RPO.displayTime("headdate");
    RPO.reddot();
    window.setTimeout(function() { RPO.eilmeldung() }, 10000);
});



function bmDo(was,oid) {
  var sburl=encodeURIComponent(location.href);
  var sbtitle=encodeURIComponent( document.title.replace(/\| RP ONLINE/g,'') );
  var sbbody=encodeURIComponent(document.getElementsByTagName("meta")['description'].content);
  switch(was) {
    case 'delicious':
      window.open('http://del.icio.us/post?url='+sburl+'&title='+sbtitle);
      break;
    case 'wong':
      window.open('http://www.mister-wong.de/?action=addurl&bm_url='+sburl+'&bm_description='+sbtitle);
      break;
    case 'yigg':
      window.open('http://yigg.de/neu?exturl='+sburl+'&exttitle='+sbtitle+'&extdesc='+sbbody);
      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='+sbbody+'&tags=');
      break;
    case 'blinkList':
      window.open('http://www.blinklist.com/?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 'digg':
      window.open('http://digg.com/submit?phase=2&url='+sburl+'&title='+sbtitle+'&bodytext='+sbbody);
      break;
    case 'furl':
      window.open('http://www.furl.net/storeIt.jsp?u='+sburl+'&t='+sbtitle);
      break;
    case 'taggle':
      window.open('http://taggle.de/addLinkDetails?mAddress='+sburl+'&title='+sbtitle+'&submitted=Weiter');
      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 'shortnews':
      window.open('http://www.shortnews.de/submitsource.cfm?source='+sburl);
      break;
    case 'twitter':
      window.open('http://twitter.com/home?status=RP%20ONLINE%3A%20'+sbtitle+'%20'+encodeURIComponent('http://'+location.hostname)+'/'+oid);
      break;
    case 'newsider':
      window.open('http://www.newsider.de/submit/?url='+sburl+'&title='+sbtitle);
      break;
    case 'facebook':
      window.open('http://de.facebook.com/sharer.php?u='+sburl+'&t='+sbtitle);
      break;
    case 'wikio':
      window.open('http://www.wikio.de/vote?url='+sburl);
      break;
    case 'studivz':
      window.open('http://www.studivz.net/Suggest/Selection/?u='+sburl+'&desc='+sbbody+'&prov=www.rp-online.de');
      break;

  }
}
