
function checkAuswahl(uName) {
    
    eval('locAnzahl = document.' + uName + 'form.' + uName + '.length');
    for(i=0; i < locAnzahl; i++) {
        eval('locSelect = document.' + uName + 'form.' + uName + '.options[i].selected');
        if(locSelect == true) {
            eval('locValue = document.' + uName + 'form.' + uName + '.options[i].value');
            if (locValue != "") {
                locTarget = locValue.split("|");
                if(locTarget.length > 1)
                {
                 if(locTarget[0] != "")
                 {
                  Fenster1 = window.open(locTarget[0], "Seite");
                 }
                }
                else
                {
                 location.href = locValue;
                }
            }
        }
    }
}
function openPopup(uHREF, uName, uWidth, uHeight, uScrollbars, uResizable) {
    
    
    locParams =
        "width="      + uWidth                     + "," +
        "height="     + uHeight                    + "," +
        "scrollbars=" + ((uScrollbars)?"yes":"no") + "," +
        "resizable="  + ((uResizable)?"yes":"no")  + "," +
        "caption=no," +
        "menubar=no," +
        "toolbar=no," +
        "status=yes," +
        "location=no";
    locWindow = window.open(uHREF, uName, locParams);
    //locWindow.focus();
    
}
function openDetailPopUp(uId, uImage, uText) {
    
    openPopup("/web/cms/static/js/91.jsp?image="+ uImage + "&text=" + uText, "detailpopup", 330, 380, false, false);
}
function openDetailPopUpWithPath(uId, uImage, uText, uPath) {
    
    openPopup("/web/cms/static/js/91.jsp?image="+ uImage + "&text=" + uText + "&menuepath=" + escape(uPath), "detailpopup", 330, 380, false, false);
}
function openPIP(uEventNr)
{
    
    openPopup("/web/cms/de/modules/pip/de.premiere.modules.tvguide.pip.standard.jsp?eventNr=" + uEventNr, "tvpremieren", 475, 350, false, false);
}
 
function OpenPopUp_KontoauszugEbene3(strLink, strEntryNo, uName, uWidth, uHeight, uScrollbars, uResizable) 
{ 
    
    
    openPopup(strLink+"?entryNo="+strEntryNo, uName, uWidth, uHeight, uScrollbars, uResizable);
}

function Blotter() {
    this.blotterTab = [];
    this.blotterRegister = [];
    this.startTab = "";
    this.startRegister = "";
    this.setStartTab = function(tab, register) {
        this.startTab = tab;
        this.startRegister = register;
    }
    this.showStartTab = function(tab, register) {
        if (this.closeAllTabs()) {
            this.setStartTab(tab, register);
            document.getElementById(this.startTab).className = "active";
            document.getElementById(this.startRegister).style.display = "block";
        }
    }
    this.addTab = function(tab, register) {
        this.blotterTab.push(tab);
        this.blotterRegister.push(register);
    }
    this.showTab = function(tab, register) {
        if (this.closeAllTabs()) {
            this.closeAllTabs()
            document.getElementById(tab).className = "active";
            document.getElementById(register).style.display = "block";
        }
    }
    this.closeAllTabs = function() {
        try {
            var blotterRegisterCount = this.blotterRegister.length;
            for (var i = 0; i < blotterRegisterCount; i++) {
                document.getElementById(this.blotterRegister[i]).className = "";
            }
            var blotterTabCount = this.blotterTab.length;
            for (var i = 0; i < blotterTabCount; i++) {
                document.getElementById(this.blotterTab[i]).style.display = "none";;
            }
        } catch(ex) {
            return false;
        }
        return true;
        
    }
    this.scollIntoView = function (tab) {
        document.getElementById(this.startTab).scrollIntoView();
    }
}
        
function switchBlotterTab(blotterId, tab) {
    eval("var blotterArray = blotter" + blotterId + "TabNamen['" + tab + "']");
    if (blotterArray != undefined) {
        eval("blotter" + blotterId + ".showStartTab('" + blotterArray[1] + "', '" + blotterArray[0] + "')");
        eval("blotter" + blotterId + ".scollIntoView('" + blotterArray[1] + "')");
    }
    
} 

function singleSubmit(formName,formField){
 if(document.forms[formName].elements[formField].value == "0"){
  document.forms[formName].elements[formField].value = "1";
  return true;
 } else {
  return false;
 }
}
function singleSubmitDisable(form, flagName, submitButtonName) {
 if (form.elements[flagName].value == "0") {
  form.elements[flagName].value = "1";
  form.elements[submitButtonName].disabled = true;
  return true;
 } else {
  return false;
 }
}
 
//Setzen der ordahl für adTags
ord=Math.random()*100000000000;
function startMerklistenRequest(request, sessionId) {
    $.ajax({
        type: "POST",
        url: "/web/watchlist.servlet;jsessionid=" + sessionId,
        cache: false,
        dataType: "xml",
        processData: false,
        contentType:"text/xml",
        success: function(data, textStatus) {
            fillMerkliste(data);
        },
        complete: function(data, textStatus) {
            //alert(data.responseText);
        },    
        data: encodeURIComponent(request)
    });
}

function fillMerkliste(data) {
    code = $(data).find("code").length > 0 ? $(data).find("code").text()  : "20001"; 
    if(code == "0") {
        $("#merklisteInhalt").html("");
        $("#merklisteFehler").hide();
        $("#merklisteKeinEintrag").hide();
        var merklistenInhalt = "<h2>Ihre vorgemerkten Programmhighlights:</h2>";
         
        $(data).find("watchlist").each(function(merkIndex) {
            if(merkIndex < 5) {
                var ausstrahlungId = $(this).attr("ausstrahlungId");
                var broadcastDate = $(this).attr("broadcastDate");
                var broadcastTime = $(this).attr("broadcastTime");
                var senderLayerUrl = $(this).attr("senderLayerUrl");
                var siEventtitel = $(this).attr("siEventtitel");
                var stationName = $(this).attr("stationName");
                var stationUrl = $(this).attr("stationUrl");
                var watchlistId = $(this).attr("watchlistId");
                var deleteAction = "setDeleteParam('"+watchlistId+"','delete','merkliste.boundary.addMemoryEntrysForm');";
                var detailSeite = "/web/cms/de/modules/pip/de.premiere.modules.tvguide.pip.jsp?ausstrahlungsID=" + ausstrahlungId;
                merklistenInhalt += "\n<!-- START Merklisten-Eintrag -->\n";
                merklistenInhalt += "<div class=\"merkliste_eintrag";
                merklistenInhalt += "\">\n";
                    merklistenInhalt += "<h3><a href=\"" + detailSeite + "&TB_iframe=true&height=570&width=600\" class=\"thickbox\">" + siEventtitel + "</a></h3>\n";
                    merklistenInhalt +=  broadcastDate + ", " + broadcastTime + " Uhr<br />\n";
                    if (stationUrl != "") {
                        merklistenInhalt += "<a href=\"" + stationUrl + "\">" + stationName + "</a>\n";
                    }
                    else {
                        merklistenInhalt += stationName;
                    }
                    merklistenInhalt += "<br />\n";
                    merklistenInhalt += "<input type=\"checkbox\" id=\"merk_chekbox" + merkIndex + "\" name=\"selectedEventEntrys\" value=\"" + watchlistId + "\" style=\"display:none;\" />\n";
                    merklistenInhalt += "<input type=\"hidden\" name=\"hdnTellFriends\" value=\"0\" />\n";
                    merklistenInhalt += "<a class=\"merkliste_delete\" title=\"Merklisteneintrag l&ouml;schen\" href=\"#\" onclick=\"" + deleteAction + "\"><span>Merklisteneintrag löschen</span></a>\n";
                    merklistenInhalt += "<a class=\"merkliste_recommend\" title=\"Weitersagen\" href=\"#\" onclick=\"javascript:submitForm('1','" + merkIndex + "')\"><span>Weitersagen</span></a>\n";
                    merklistenInhalt += "<a class=\"merkliste_alert\" title=\"Erinnern\" href=\"#\" onclick=\"javascript:submitForm('0','" + merkIndex + "')\"><span>Erinnern</span></a>\n";
                merklistenInhalt += "</div>\n";
            }
       });
        merklistenInhalt += "<div class=\"clearer\"></div><a href=\"/web/cms/de/kundencenter-meinsky-merkliste.jsp\" class=\"weiter\">Vollständige Merkliste</a>";
        $("#merklisteInhalt").append(merklistenInhalt);
        tb_init('#merklisteInhalt a.thickbox');
        alert("Die Sendung wurde in die Merkliste eingetragen.");
    }
    else if (code == "2") {
        alert("Der Ausstrahlungszeitpunkt dieser Sendung ist bereits verstrichen. Die Sendung wurde nicht in die Merkliste eingetragen.");
    }
    else if (code == "3") {
        alert("Die Sendung befindet sich bereits in der Merkliste.");
    }    
    else if ((code*1) > 10000) {
        alert("Bei der Verarbeitung der Merkliste ist ein Fehler aufgetreten: Fehlercode " + code);
    }    
}

function openLayer(url, width, height) {
    thisUrl = url.indexOf("?") == -1 ? url+"?TB_iframe=true&width="+width+"&height="+height : url+"&TB_iframe=true&width="+width+"&height="+height;
    tb_show(null,thisUrl, false);
}
function openFlashLayer(lw, lh, lf, fw, fh, f, d, a, oId, closeEvent) {
    var flashLayerOffset = $(f).parent().offset();
    var scrollTopIe6 = 0;
    switch(a) {
        case "LU":
            var top = flashLayerOffset.top+scrollTopIe6;
            var left = (flashLayerOffset.left-lw+fw);
            break;
        case "LO":
            var top = flashLayerOffset.top+fh-lh+scrollTopIe6;
            var left = (flashLayerOffset.left-lw+fw);
            break;
        case "RU":
            var top = flashLayerOffset.top+scrollTopIe6; 
            var left = flashLayerOffset.left;
            break;
        case "RO":
            var top = flashLayerOffset.top+fh-lh+scrollTopIe6;
            var left = flashLayerOffset.left;
            break;
    }
    if ( ($("#flashLayer embed").length && $("#flashLayer embed").attr("src") != lf) || ($("#flashLayer object").length) ) {
        var so = new SWFObject(lf, oId, lw, lh, "6", "");
        so.addParam("wmode", "transparent");
        so.addParam("quality", "high");
        so.addParam("allowFullScreen", "false");
        so.addParam("allowScriptAccess","sameDomain");
        so.write("flashLayer");
    }
    switch (closeEvent) {
        case "mouseenter":
            closeEvent = "mouseleave";
            break;
        case "mouseup":
            closeEvent = "mouseup mouseleave";
            break;
    }
    $("#flashLayer").css({width: lw, height:lh, top: top, left:left }).show().unbind("mouseleave").unbind("mouseup").bind(closeEvent, function() { 
        flashLayerTimeout = window.setTimeout("$('#flashLayer').hide()",d);
    }).unbind("mouseenter").bind("mouseenter", function() {
        if (flashLayerTimeout) {
            window.clearTimeout(flashLayerTimeout);
        }
    });
    
}
/*$(window).resize(function() {
  $("body").css("background-position", ($("#areaBody").offset().left - 98) + "px 0");
});       
*/
$(document).ready(function() {
    if(typeof document.body.style.maxHeight === "undefined")
        $(".SubNav li, #quickdone li, #quickdone2 li").each(function() { 
        
            that = $(this);
            $(that).bind("mouseenter", function() {
                $(this).addClass("sfhover");
            });
            $(that).bind("mouseleave", function() {
                $(this).removeClass("sfhover");
            });
        });    
    $("#tvGuideCalendarToggle").bind("mouseenter", function(event) {
        $("#tvGuideZeitDropdown").hide(); 
        $("#tvGuideCalendar").show().bind("mouseleave", function(event) {
            $("#tvGuideCalendar").hide();
            $("#tvGuideZeitDropdown").show();
        });
    });
    $("#tvGuideFilterToggle").bind("mouseenter", function(event) {
    $("#tvGuideZeitDropdown").hide();
        $("#tvGuideFilter").show().bind("mouseleave", function(event) {
            $("#tvGuideFilter").hide();
            $("#tvGuideZeitDropdown").show();
            
        });
    });
// Einblenden des Kundelogins und einem Layer und Ausblenden durch Klick außerhalb des Logins

    var loginHtml = $("#rightLogin").html();
    $("#rightLogin").remove();
    $("#helpLogin").append("<div id='rightLogin' style='display:none;'>" + loginHtml + "</div>");
    if ($("span#KNRToolTip").length > 0 ) {
        $("span#KNRToolTip").tooltip({
            track: true,
            delay: 0,
            showURL: false,
            showBody: "|"
        });
    }
    if ($("span#PINToolTip").length > 0 ) {
        $("span#PINToolTip").tooltip({
            track: true,
            delay: 0,
            showURL: false,
            showBody: "|"
        });
    }
    if ($("span#REGToolTip").length > 0 ) {
        $("span#REGToolTip").tooltip({
            track: true,
            delay: 0,
            showURL: false,
            showBody: "|"
        });
    }
    $("a.merkliste").bind("mouseenter",function() {
        if($("#merklisteInhalt .merkliste_eintrag").length > 1) {
            $("#tvGuideZeitDropdown").hide();
        }
        $("#areaHeader").css("z-index", "102");
        $("#but_merkliste").show();
        $("#but_merkliste").bind("mouseleave",function() {
            $("#tvGuideZeitDropdown").show();
            $("#but_merkliste").hide();
            $("#areaHeader").css("z-index", "100");
        });
    });
    $("body").bind("click", function() {$("#rightLogin").hide();});
    $("#rightLogin input[name='login'], #rightLogin input[name='password']").bind("click", function(e) {e.stopPropagation()});
    $(".kundenlogin a").bind("mouseenter",function() {
        $("#rightLogin").show();
    });    
    if (typeof(mySelectedFilter) != "undefined") {
        $("#tvGuideFilter a").each(function() {
            if ($(this).html() == mySelectedFilter || $(this).text() == mySelectedFilter) {
                $(this).css({color: "#fff", backgroundColor:"#c2c2c2", fontWeight: "bold"});
                $("#tvGuideFilterToggle span").html(mySelectedFilter);
            }
        });
    }

    if ($("#flashLayer").length == 0) {
        $("body").append('<div id="flashLayer" style="position:absolute;top:-2000px; left:0; display:none;z-index:10000;"></div>');
    }
    /*$(function() {
        $(window).trigger("resize");
    });*/
});
$(function() {
    $(".loginButton .loginbtn").bind("click", function() {
        s.linkTrackVars='prop50,eVar50';
        s.prop50 = s.eVar50 = $(".loginKundennummer .txtKundennummer").val();
        s.tl(this,'o','Login');
    });
    $("#loginContentId input[type='image']").bind("click", function() {
        s.linkTrackVars='prop50,eVar50';
        s.prop50 = s.eVar50 = $("#loginContentId input[name='login']").val();
        s.tl(this,'o','Login');
    });
});
(function($) {
    var methods = {
        init : function( options ) { 
            return this.each(function() {
                var self = $(this);
                if (!$.isArray(options.data)) return;
                if (options.data.length == 0) return;
                options.lastIndex = options.data.length-1
                self.data('settings', options);
                var imageHolder = self.find(".newOnSkyImageHolder");
                self.find(".newOnSkyImage:eq("+options.startIndex+")").css({"z-index":100}).css({top:8,left:options.leftPos1,width: 295,height: 175,opacity: 1});
                if (options.lastIndex > 1) {
                    self.find(".newOnSkyImage:eq("+options.lastIndex+")").css({"z-index":50}).css({top:42,left: 0,width:220,height: 118,opacity: 0.5});
                }
                if (options.lastIndex > 2) {
                    $(imageHolder).find("img:gt(1)").css("opacity", 0).end().find("img:eq("+options.lastIndex+")").css("opacity", 0.5);
                }
                self.find('.newOnSkyNavigationText a').attr("href",options.data[options.startIndex].url).html(options.data[options.startIndex].title);
                Cufon.replace("#"+self.attr("id") + " .newOnSkyNavigationText a");        
                self.find('.newOnSkyNavigationImageNext').click(function() {
                    if (options.inAnimation) return false;
                    options.inAnimation = true;
                    methods.rotate(1, self);                                    
                    options.currentIndex == options.lastIndex ? options.currentIndex = 0 : options.currentIndex++;
                    self.find(".newOnSkyNavigationText a").fadeIn(options.animationSpeed / 2, function() {options.inAnimation = false;});
                    return false;
                });                 
                self.find('.newOnSkyNavigationImagePrev').click(function() {
                    if (options.inAnimation) return false;
                    options.inAnimation = true;
                    methods.rotate(-1, self);                                
                    options.currentIndex == 0 ? options.currentIndex = options.lastIndex : options.currentIndex--;
                    self.find(".newOnSkyNavigationText a").fadeIn(options.animationSpeed / 2 , function() {options.inAnimation = false;});
                    return false;
                });
                       
                //this.rotate();
                if (options.data.length == 1) {
                    self.find(".newOnSkyNavigation a").css({"cursor": "default", "opacity": 0.5});
                    self.find('.newOnSkyNavigationImagePrev').unbind("click").click(function() { return false;});
                    self.find('.newOnSkyNavigationImageNext').unbind("click").click(function() { return false;});
                }                                
                self.show();
            });
            
        },
        rotate : function(dir, obj) {
            var self = obj;
            var settings = self.data('settings');
            if (dir == 1) {
                var prev = (settings.currentIndex - 1) < 0 ? settings.lastIndex : settings.currentIndex - 1
                var next = (settings.currentIndex + 1) > settings.lastIndex ? 0 : (settings.currentIndex + 1);
                var cur = settings.currentIndex;
                var nextShow = (next + 1 > settings.lastIndex) ? 0 : next+1;
                self.find(".newOnSkyNavigationText a").fadeOut(parseInt(settings.animationSpeed / 2), function() { 
                    self.find(".newOnSkyNavigationText a").attr("href", settings.data[next].url).html(settings.data[next].title);
                    Cufon.replace(self.find(".newOnSkyNavigationText a"));
                });
                self.find(".newOnSkyImage:eq("+next+")").css({"z-index":100}).animate({top:8,left:settings.leftPos1,width: 295,height: 175,opacity: 1 }, settings.animationSpeed);
                self.find(".newOnSkyImage:eq("+cur+")").css({"z-index":50}).animate({top:42,left: 0,width:220,height: 118,opacity: 0.5    }, settings.animationSpeed);
                if (settings.lastIndex > 2){
                    self.find(".newOnSkyImage:eq("+prev+")").css({"z-index":50}).animate({top:42,left:settings.leftPos2,width:220,height: 118,opacity: 0    }, settings.animationSpeed);
                    self.find(".newOnSkyImage:eq("+nextShow+")").css({"z-index":50, opacity: 0, display:"block"}).animate({opacity: 0.5}, settings.animationSpeed);                                
                }
                else {
                    self.find(".newOnSkyImage:eq("+prev+")").css({"z-index":50}).animate({top:42,left:settings.leftPos2,width:220,height: 118,opacity: 0.5    }, settings.animationSpeed);
                }
            }
            else {
                var next = (settings.currentIndex - 1) < 0 ? settings.lastIndex : settings.currentIndex - 1
                var prev = (settings.currentIndex + 1) > settings.lastIndex ? 0 : (settings.currentIndex + 1);
                var cur = settings.currentIndex;
                var nextShow = (next - 1 ) <  0 ? settings.lastIndex : next - 1;
                self.find(".newOnSkyNavigationText a").fadeOut(parseInt(settings.animationSpeed / 2), function() { 
                    self.find(".newOnSkyNavigationText a").attr("href", settings.data[next].url).html(settings.data[next].title);
                    Cufon.replace(self.find(".newOnSkyNavigationText a"));
                });
                self.find(".newOnSkyImage:eq("+next+")").css({"z-index":100}).animate({top:8,left:settings.leftPos1,width: 295,height: 175,opacity: 1 }, settings.animationSpeed);
                self.find(".newOnSkyImage:eq("+cur+")").css({"z-index":50}).animate({top:42,left:settings.leftPos2,width:220,height: 118,opacity: 0.5    }, settings.animationSpeed);
                if (settings.lastIndex > 2){
                    self.find(".newOnSkyImage:eq("+prev+")").css({"z-index":50}).animate({opacity: 0}, settings.animationSpeed);
                    self.find(".newOnSkyImage:eq("+nextShow+")").css({top:42,left: 0,width:220,height: 118,"z-index":50, opacity: 0, display:"block"}).animate({opacity: 0.5}, settings.animationSpeed);                                
                }
                else {
                    self.find(".newOnSkyImage:eq("+prev+")").css({"z-index":50}).animate({top:42,left: 0,width:220,height: 118,opacity: 0.5    }, settings.animationSpeed);
                }
                
                                    
            }
            self.find(".newOnSkyNavigationText a").fadeIn(settings.animationSpeed);
        }
    };
    $.fn.newOnSky = function( method ) {
        // Method calling logic
        if ( methods[method] ) {
          return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === 'object' || ! method ) {
          return methods.init.apply( this, arguments );
        } else {
          $.error( 'Method ' +  method + ' does not exist on jQuery.newOnSky' );
        }    
      
    };
})(jQuery);
function generateSocialMediaTrackingUrl(stamm) {
    // we need to change https to http if needed
    // and we need to add this parameter to the url: alllnk=socialmedia
    SM_TRACKING_PARAM = "alllnk=socialmedia";
    pageUrl = location.href;
    if (stamm) {
        pageUrl = pageUrl.replace(location.search, "");
    }
    
    // replace https with http
    pageUrl = pageUrl.replace("https","http");
    
    indexOfQuestionMark = pageUrl.indexOf("?");
    if(indexOfQuestionMark > 0) {
        lastChar = pageUrl.substring(pageUrl.length-2,pageUrl.length-1);
        if(lastChar == "&") {
            pageUrl = pageUrl + SM_TRACKING_PARAM;
        } else {
            pageUrl = pageUrl + "&" + SM_TRACKING_PARAM;
        }
    } else {
        pageUrl = pageUrl + "?" + SM_TRACKING_PARAM;
    }
    
    return pageUrl;
}
function getPathFromUrl(url, stamm) {
    if (stamm) {
        url = url.replace(location.search, "");
    }
    httpKey = "://";
    indexOfHttpKey = url.indexOf(httpKey, 0);
    if(indexOfHttpKey > -1) {
        indexOfHostSlash = url.indexOf("/", indexOfHttpKey + httpKey.length);
        if(indexOfHostSlash > -1) {
            path = url.substring(indexOfHostSlash, url.length);
            return path;
        }
    }
    return -1;
}
function openSocialLayer(text, layer_height) {
    tb_show("", "#TB_inline?height="+ layer_height +"&width=360&inlineId=social-add-layer-tb", "");
    $("#TB_window").css({"border": "1px solid #ccc", "z-index":"301"});
    $("#TB_overlay").css({"z-index":"300", "background-color": "transparent"});
    $("#TB_ajaxWindowTitle").html("<b>"+text+"</b>");
    $("#TB_closeWindowButton").click(function(){
        tb_remove();
    });
    return false;
}

$(document).ready(function() {
   $("#btnSubmitFrmSearch").click(function() {
     if($("#search .searchfield").val() == "Wonach suchen Sie?" || $("#search .searchfield").val() == "") {
        $("#search .searchfield").val("");
        $("#search .searchfield").focus();
        return false;
     }
  });
});

// newTopNews script
(function(window) {
    var topNews = {};
    
    topNews.init = function(id) {
        if ($.browser.msie) {
            if ($.browser.version == 6) {
                $(id + " .newTopNewsText .videoLink img").load(function() {
                    if ($(this).closest(".newTopNewsText").is (":visible")) {
                        $(this).pngFix();
                    } else {
                        $(this).closest(".newTopNewsText").show();
                        $(this).pngFix();
                        $(this).closest(".newTopNewsText").hide();
                    }
                    
                    
                    $(id + " .newTopNewsThumb span.thumbImgOverlay").css("position", "absolute");
                });
                
            }
            $(id + " .newTopNewsTextBG").css({
                background: "none",
                filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/web/cms/static/img/admin/11-07_sportmodul_textfeld_ededed.png', sizingMethod='scale');"
            });
        }    
        // Scale category background to fit
        $(id + " .categoryBG").each(function() { 
            $(this).height( $(this).next().height() > 18 ? 30 : 18);  
            $(this).next().height($(this).height());
            if ( $(this).next().height() > 18 ) {
                //$(this).next().css({bottom:"6px"});
            }
        });
        // Center Playbutton-Image
        $(id + " .newTopNewsText .videoLink").each(function() {
            var parent = $(this).parent();
            $(this).css({"margin-top": parent.height() / 2 - 22, "margin-bottom": parent.height() / 2 - 21});
        });
        $(id + " .newTopNewsText.textPosBottom").each(function() {
            var height = $(this).outerHeight();
            $(this).css("top", (267 - height - 16));
                
        });        
        // Scale text background to fit
        $(id + " .newTopNewsTextBG").css({
            height: $(id + " .newTopNewsText:visible").outerHeight(true),
            width: $(id + " .newTopNewsText:visible").outerWidth(true),
            top: $(id + " .newTopNewsText:visible").css("top"),
            left: $(id + " .newTopNewsText:visible").css("left"),
            right: $(id + " .newTopNewsText:visible").css("right")            
        });
        // Bind click event to images
        $(id + " .newTopNewsThumb .thumbImgDiv").click(function() {
            window.clearInterval(topNews.interval);
            // rotate thumbs
            topNews.rotate(id, $(id + " .newTopNewsThumb .thumbImgDiv").index(this));
            return false;
        });    
        $(id + " .newTopNewsHeader:not(:first)").hide();
        $(id + " .newTopNewsText:not(:first)").hide();
        $(id + " .newTopNewsText:first").show();
        $(id + " .newTopNewsBigImageDiv:not(:first)").hide();       
         $(id + " .newTopNewsThumb:last").css({"margin-right" : 0});      
    };
    topNews.rotate = function(id, active) {
        var elements = $(id + " .newTopNewsThumb .thumbImgDiv");
        var index = (active === undefined) ? elements.index($(".active")) == -1 ? 0 : elements.index($(".active")) : active-1;
        if(++index == elements.length) index = 0;
        elements.removeClass("active").eq(index).addClass("active");
        $(id + " .newTopNewsHeader").hide().eq(index).show();
        $(id + " .newTopNewsText").hide().eq(index).show();
        try {
            $(id + " .newTopNewsSlider-h:visible").css("left", elements.eq(index).closest(".newTopNewsThumb").position().left);
            $(id + " .newTopNewsSlider-v:visible").css("top", elements.eq(index).closest(".newTopNewsThumb").position().top);
        } catch (e) {}
        $(id + " .newTopNewsBigImageDiv").hide().eq(index).show();
        if ( $(id + " .newTopNewsText").is(":visible") )  {
            $(id + " .newTopNewsTextBG").css({
                height: $(id + " .newTopNewsText:visible").outerHeight(true),
                width: $(id + " .newTopNewsText:visible").outerWidth(true),                
                top: $(id + " .newTopNewsText:visible").css("top"),
                left: $(id + " .newTopNewsText:visible").css("left"),
                right: $(id + " .newTopNewsText:visible").css("right")
            }).show();
    
        } else {
            $(id + " .newTopNewsTextBG").hide();
        }
        $(".newTopNewsSkyHdLogo").css("zoom","1");
    };
    this.topNews = topNews;
})(this);
 
 
jQuery(function() {
    jQuery(".thumbImgOverlay").pngFix();
    $(".divSizeButtons .floatLeft").bind("click",function(){
        $(".txtArticle").css({"font-size":"13px", "line-height": "15px"});
        $(".pActive,.mInactive").hide();
        $(".pInactive,.mActive").show();
    });
    $(".divSizeButtons .floatRight").bind("click",function(){
        $(".txtArticle").css({"font-size":"11px", "line-height": "1.2em"});
        $(".pInactive,.mActive").hide();
        $(".pActive,.mInactive").show();
    });
});
jQuery(window).load(function() {
    if ($.browser.msie && $.browser.version == 6) {
        jQuery("#topLogo").pngFix();
        jQuery(".bcPlayButtonOverlayTopTeaser").pngFix();
        jQuery("span.bcPlayButtonOverlayTopTeaser").css("position", "absolute");
        jQuery(".imgTxtMore").pngFix();
    }
});
//  SSN Pagination
function ssnUpdateField(sTag, sValue)
{
    var pElem = $(sTag);
    
    if (pElem.length != 0)
        pElem.text(sValue);
}
function ssnUpdateResultInfo(nPage)
{
    // count news on previous pages (we do not start at pos. 0 but at 1)
    var nStart = (nPage - 1) * g_nssnItemsPerPage + 1;
    
    // count news on current pages
    var nCur = $("#ssnArchive .ssnArchivePage" + nPage).length - 1;
    
    ssnUpdateField("#ssnPaginationTop .ssnPaginationFrom", nStart);
    ssnUpdateField("#ssnPaginationBottom .ssnPaginationFrom", nStart);
    ssnUpdateField("#ssnPaginationTop .ssnPaginationTo", nStart + nCur);
    ssnUpdateField("#ssnPaginationBottom .ssnPaginationTo", nStart + nCur);

}
function ssnGetCurrentPage()
{
    var pCur = $("#ssnPaginationTop .ssnCur");
    return (pCur.length == 0) ? -1 : parseInt(pCur.text());
}
function ssnClassRemove(sElemTag, sClass)
{
    var pElem = $(sElemTag);
    
    if (pElem.length != 0)
        pElem.removeClass(sClass);
}
function ssnClassAdd(sElemTag, sClass)
{
    var pElem = $(sElemTag);
    
    if (pElem.length != 0)
        pElem.addClass(sClass);
}
function ssnHideCurrentPage()
{
    var nPage = ssnGetCurrentPage();
    if (nPage == -1)
        return false;
    ssnClassRemove("#ssnPaginationTop .ssnCur", "ssnCur");
    ssnClassRemove("#ssnPaginationBottom .ssnCur", "ssnCur");
    ssnClassAdd("#ssnArchive .ssnArchivePage" + nPage, "ssnHide");
}
function ssnShowPage(nPage)
{
    ssnHideCurrentPage();
    
    ssnClassAdd("#ssnPaginationTop .ssnPaginationPage" + nPage, "ssnCur");
    ssnClassAdd("#ssnPaginationBottom .ssnPaginationPage" + nPage, "ssnCur");
    ssnClassRemove("#ssnArchive .ssnArchivePage" + nPage, "ssnHide");
                  
    ssnUpdateResultInfo(nPage);
}
function ssnTurnPage(nPages)
{
    var nCur = ssnGetCurrentPage();
    var nSetPage = 1;
    
    if (nCur == -1)
        return false;
    
    if (nPages > 0)
        nSetPage = (nCur + nPages <= g_nssnPages) ? nCur+nPages : nCur;
    else if (nPages < 0) // value is negative: therefore "add" ))
        nSetPage = (nCur + nPages > 0) ? nCur+nPages : nCur;
    
    ssnShowPage(nSetPage);
}
function isApple() {
    if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1) | (navigator.userAgent.indexOf('iPod') != -1)) {  
        return true
    } else {
        return false;
    }
}
 
(function($) {
    $.fn.newsDynamic = function (parameter) {
        // Private Variablen
        /* Parameter für die News Rasterliste
        *    xml -> Pfad zur XML-Datei die über AJAX geladen werden soll.
        *    teaserLayout -> Array mit den Teaser-Layouts. Pro Eintrag wird ein Teaser mit dem korrespondierenden Template erstellt.
        */
        var that = this;
        var debug  = false;
        var params = {
            xmlpath: "",
            xml: null,
            /* Teaser Layouts
            *    0 -> 3 Spalten halbhoch / 1 Spalte bild    
            *    1 -> 1 Spalte / halbes Bild -> Vertical
            *    2 -> 2 Spalten / 1 Spalte Bild
            *    3 -> 3 Spalten / 2 Spalten Bild
            */
            teaserLayout : [],
            mode: "overview",
            pathToMediathek : "/web/cms/de/sport-mediathek.jsp?bcpid=586521887001&bclid=30700836001&bctid=",
            pathToLayer: "javascript:openLayer('/web/cms/de/hl_video_layer.jsp?videoId={id}','601','400');",
            tickerHeadline : "",
            linkToMore: "http://www.sky.de"
        }
        jQuery.extend(params, parameter);
        var category = "";
        /* Templates
            Templatevariable       Bezeichner           XML-Knoten
            {headline}             -> Überschrift        -> <title>
            {link}                -> Link                -> <link>
            {image0}            -> Bild                -> <im:block type="image-145x85">
            {image1}            -> Bild                -> <im:block type="image-145x85">
            {image2}            -> Bild                -> <im:block type="image-145x175">
            {image3}            -> Bild                -> <im:block type="image-295x175">
            {image-alt}         -> Title/ Alt-Text     -> <title>
            {text-headline}        -> Text-Überschrift    -> <headline> innerhalb des entsprechenden Blocks
            {text}                -> Langer Teasertext-> <im:block type="teasertext-long"><paragraph>
            {textshort}            -> Kurzer Teasertext -> <im:block type="teasertext-short"><paragraph>
            
        */            
        var templates = { 
            0 : '<div class="teasImgTxt width3 imgTxtRatio12 imgSize1 halfHeight85">\n' +
                ' <h2 class="bordertab">{headline}</h2><div><a href="{link}"><img class="teaserBild" src="{image0}" alt="{image-alt}" title="{image-alt}"></a></div>\n' +
                ' <div class="teasTxtBox">\n' +
                '  <h3><a href="{link}">{text-headline}</a></h3>\n' + 
                '  <p class="securetag"><a href="{link}">{text}<img class="imgTxtMore" src="/web/cms/static/img/admin/sky_11-10_klickpfeil_schwarz_6x6.png" /></a></p>\n' +
                '  <ul class="teasLinklist">\n' +
                '  </ul>\n' + 
                ' </div>\n' +
                '</div>\n',
            1 : '<div class="teasImgTxtVertical width1">\n' +
                ' <h2 class="bordertab">{headline}</h2><div><a href="{link}"><img class="teaserBild" src="{image1}" alt="{image-alt}" title="{image-alt}"></a></div>\n' +
                ' <div class="teasTxtBox">\n' +
                '  <h3><a href="{link}">{text-headline}</a></h3>\n' + 
                '  <p class="securetag"><a href="{link}">{textshort}<img class="imgTxtMore" src="/web/cms/static/img/admin/sky_11-10_klickpfeil_schwarz_6x6.png" /></a></p>\n' +
                '  <ul class="teasLinklist">\n' +
                '  </ul>\n' + 
                ' </div>\n' +
                '</div>\n',
            2 : '<div class="teasImgTxt width2 imgSize1 imgTxtRatio11">\n' +
                ' <h2 class="bordertab">{headline}</h2><div><a href="{link}"><img class="teaserBild" src="{image2}" alt="{image-alt}" title="{image-alt}"></a></div>\n' +
                ' <div class="teasTxtBox">\n' +
                '  <h3><a href="{link}">{text-headline}</a></h3>\n' + 
                '  <p class="securetag"><a href="{link}">{text}<img class="imgTxtMore" src="/web/cms/static/img/admin/sky_11-10_klickpfeil_schwarz_6x6.png" /></a></p>\n' +
                '  <ul class="teasLinklist">\n' +
                '  </ul>\n' + 
                ' </div>\n' +
                '</div>\n',
            3 : '<div class="teasImgTxt width3 imgTxtRatio21 imgSize2">\n' +
                ' <h2 class="bordertab">{headline}</h2><div><a href="{link}"><img class="teaserBild" src="{image3}" alt="{image-alt}" title="{image-alt}"></a></div>\n' +
                ' <div class="teasTxtBox">\n' +
                '  <h3><a href="{link}">{text-headline}</a></h3>\n' + 
                '  <p class="securetag"><a href="{link}">{text}<img class="imgTxtMore" src="/web/cms/static/img/admin/sky_11-10_klickpfeil_schwarz_6x6.png" /></a></p>\n' +
                '  <ul class="teasLinklist">\n' +
                '  </ul>\n' + 
                ' </div>\n' +
                '</div>\n',
            "detail": '<div style="height: auto; position:relative;" class="teasImg width3 imgSize3">\n' + 
                ' <h2 class="bordertab">{aio-headline}</h2>\n' + 
                ' <a href="{video-link}"><img src="{image}" alt="{image-alt}" title="{image-alt}" class="teaserBild" /><img class="playBtnDetail" style="display:none;" src="/web/cms/static/img/admin/videobutton_230x172.png"  alt="" /></a></div>\n' +
                '<div class="optrubrik"><span class="rubrikDate">{rubrik-date}</span><strong class="rubrikTitle">{rubrik-title}</strong></div>\n' + 
                '<div class="legacyContentContainer floatLeft width3"><h2>{headline}</h2><p>{text}</p>'+ 
                '<div class="clearer"></div><div class="tv_links"><div class="tv_left"></div><div class="clearer"></div></div></div>',
            "oldDetail": '<div class="newsWrapper">\n' + 
                '<div class="top"><p class="kategorie floatLeft"><b>{ODcategory}</b></p><p class="datum floatRight">{ODrubrik-date}</p></div>\n' + 
                '<div class="clearer"></div>\n' +
                '<div class="optheadline"><h2>{ODheadline}</h2></div>\n'  +
                '<div class="clearer"></div>\n' +
                '<div class="news"><img alt="{ODimage-alt}" src="{ODimage}"></div>\n' + 
                '<p><b>{ODshortteaser}</b></p>\n' +
                '<p>{ODtext}</p>\n'+        
                '<div class="clearer"></div>\n' +
                '</div>',
            "single" : '<div class="teasImgTxt width2 imgSize1 imgTxtRatio11">\n' +
                ' <h2 class="bordertab">{headline}</h2><div><a href="{link}"><img class="teaserBild" src="{image2}" alt="{image-alt}" title="{image-alt}"></a></div>\n' +
                ' <div class="teasTxtBox">\n' +
                '  <h3><a href="{link}">{text-headline}</a></h3>\n' + 
                '  <p class="securetag"><a href="{link}">{textshort}<img class="imgTxtMore" src="/web/cms/static/img/admin/sky_11-10_klickpfeil_schwarz_6x6.png" /></a></p>\n' +
                '  <ul class="teasLinklist">\n' +
                '  </ul>\n' + 
                ' </div>\n' +
                '</div>\n',
            "ticker" : '<div class="skyTopNews width3"><div class="imgTrans"><a href="{link}"><img alt="{image-alt}" src="{image4}"></a></div>\n' + 
                ' <div class="txtTrans"><p><strong>{aio-headline}</strong></p><h2 class="black"><a href="{link}">{text-headline}</a></h2>\n' + 
                ' <p><a href="{link}">{textshort}</a></p>\n'+
                '</div></div><div class="clearer"></div><div class="teasTicker450 width3"><h2 class="newstab">'+params.tickerHeadline+'</h2><div class="ticker"><div class="clearer"></div></div><a target="_self" href="'+params.linkToMore+'" class="mehr">Mehr News</a><div class="clearer"></div></div>',
            "tickerEntry" : '<div class="newsticker"><div class="tickertext"><a href="{link}"><span class="zeit">{rubrik-date}</span><span class="rubrik">{rubrik-title}</span><span class="head">{text-headline}</span></a></div>\n' +
                '<div class="clearer"></div></div>',
            "newsliste" : '<div id="newsfeed"><div class="teasNewsList width3" id="newsliste"><h2 class="newstab">'+params.tickerHeadline+'</h2><div class="pager">\n'+
                '<div class="mrgLe5 floatLeft"></div><div class="floatRight pagerPag newsPagination" id="Pagination"></div><div class="clearer"></div>\n' + 
                '</div><div class="newslistCont"></div><div class="clearer"></div><div class="pager"><div class="floatRight pagerPag newsPagination" id="Pagination2"></div><div class="clearer"></div>' +
                '</div></div></div>',
                        
            
            "newslisteEntry": '<div style="display: block;" class="newsliste"><div class="mrgBott"><span class="datum">{rubrik-date}</span><span class="zeit">{rubrik-time}</span><span class="rubrik">{rubrik-title}</span><div class="clearer"></div></div><div class="clearer"></div><div><h3><a href="{link}">{text-headline}</a></h3><p><a href="{link}">{textshort}</a></p><div class="clearer"></div></div></div>'
            
            
            
        }
        
        var templateReplaceND = {
            "{headline}" : 'title',
            "{aio-headline}" : 'im\\:block[type="all-in-one"] headline',
            "{link}" : 'link',
            "{image}"  : 'im\\:block[type="image-445x175"] image',
            "{image0}" : 'im\\:block[type="image-145x85"] image',
            "{image1}" : 'im\\:block[type="image-145x85"] image',
            "{image2}" : 'im\\:block[type="image-145x175"] image',
            "{image3}" : 'im\\:block[type="image-295x175"] image',
            "{image-alt}" : 'title',
            "{text-headline}" : 'title',
            "{text}" : 'im\\:block[type="image"],im\\:block[type="teasertext-long"],im\\:block[type="infobox"] paragraph',
            "{textshort}" :    'im\\:block[type="teasertext-short"] paragraph',
            "{rubrik-date}" : 'pubDate <datetime>',
            "{rubrik-title}" : 'category >',
            "{video-link}" : 'im\\:block[type^="video-"] video'
            
        }
        var templateReplaceOverview = {
            "{headline}" : 'title',
            "{aio-headline}" : 'im\\:block[type="all-in-one"] headline',
            "{link}" : 'link',
            "{image}"  : 'im\\:block[type="image-445x175"] image',
            "{image0}" : 'im\\:block[type="image-145x85"] image',
            "{image1}" : 'im\\:block[type="image-145x85"] image',
            "{image2}" : 'im\\:block[type="image-145x175"] image',
            "{image3}" : 'im\\:block[type="image-295x175"] image',
            "{image4}" : 'im\\:block[type="image-445x284"] image',
            "{image-alt}" : 'title',
            "{text-headline}" : 'title',
            "{text}" : 'im\\:block[type="teasertext-long"] paragraph',
            "{textshort}" :    'im\\:block[type="teasertext-short"] paragraph',
            "{rubrik-date}" : 'pubDate <date>',
            "{rubrik-time}" : 'pubDate <time>',
            "{rubrik-title}" : 'category >'
        }                
        var templateReplaceTickerEntry = {
            "{link}" : 'link',
            "{text-headline}" : 'title',
            "{textshort}" :    'im\\:block[type="teasertext-short"] paragraph',
            "{rubrik-date}" : 'pubDate <dateortime>',
            "{rubrik-title}" : 'category >'
        }                    
        var templateReplaceOD = {
            "{ODheadline}" : 'title',
            "{ODimage-alt}" : 'title',
            "{ODlink}" : 'link',
            "{ODtext}" : 'description',
            "{ODlanguage}" : 'language',
            "{ODimage}" : 'img enclosure',
            "{ODlongtitle}" : 'im\\:long_title',
            "{ODshorttitle}" : 'im\\:short_title',
            "{ODshortteaser}" : 'im\\:short_teaser',
            "{ODcategory}" : 'im\\:category im\\:cat_node',
            "{ODtextshort}" :    'im\\:block[type="teasertext-short"] paragraph',
            "{ODrubrik-date}" : 'pubDate <datetime>'
        }
        
        /* Private Methoden */
        _getXML = function() {
            jQuery.ajax({
                url : params.xmlpath,
                type: "GET",
                encoding:"UTF-8",
                async: false,
                dataType: ((location.protocol == "file:") ? ((jQuery.browser.msie) ? "text": "xml") : "xml"),
                success: _success,
                error: _error,
                complete: _complete
            });
            
        }
        /* Log - Funktion
        *    Es wird in die Console geloggt, sofern diese vorhanden ist. Ansonsten erfolgt die Ausgabe über 'alert'
        */
        _log = function(log) {
            if (debug)
                (typeof window.console == "undefined") ? alert(log) : console.log(log);
        }
        /* Success-Funktion des AJAX-Requests 
        *
        */
        _success = function(data, status) {
            _log("Ajax Request: " + status);
            var xml;
            if (typeof data == "string") {
                xml = new ActiveXObject("Microsoft.XMLDOM");
                xml.async = false;
                xml.loadXML(data);
            } else {
                xml = data;
            }                
            params.xml = xml;
            _log(params.xml);
        }
        _error = function(data, error) {
            _log("Ajax Request: " + error);
        }
        _complete = function(data, status) {
            _log("Ajax Request: " + status);
            _render(params.xml);                
        }
        _render = function(xml) {
            var items = $(xml).find('item');
            category = $(xml).find('category').text();        
            switch (params.mode) {
                case "overview":
                    for( i = 0; i < params.teaserLayout.length; i++) {
                        if (typeof items[i] != "undefined") {
                            _log(jQuery(items[i]));
                            _renderTemplate(params.teaserLayout[i], jQuery(items[i]));
                        }
                    }
                    break;
                case "ticker": 
                    _log(jQuery(items));
                    for( i = 0; i < items.length; i++) {
                        if (i == 0) {
                            _renderTemplate("ticker", jQuery(items[0]));                        
                        } else {
                            _renderTemplate("tickerEntry", jQuery(items[i]), ".teasTicker450 .ticker");
                        }
                    }                            
                    break;
                case "newsliste": 
                    for( i = 0; i < items.length; i++) {
                        if (i == 0) {
                            _renderTemplate("newsliste", jQuery(items[0]));                        
                        } else {
                            _renderTemplate("newslisteEntry", jQuery(items[i]), "#newsliste .newslistCont");
                        }
                    }                            
                    break;                            
                case "oldDetail":
                    _log(jQuery(items[0]));
                    _renderTemplate("oldDetail", jQuery(items[0]));                    
                    break;
                case "single": 
                    _renderTemplate("single", jQuery(items[0]));                                        
                    break;
                default: 
                    _log(jQuery(items[0]));
                    _renderTemplate("detail", jQuery(items[0]));                    
                    break;
            
            }
        }
        _renderTemplate = function(id, item, selector) {    
            var jetzt = new Date();
            var Tag = jetzt.getMonth();
            _log(params.mode);
            var template = templates[id];
            var templateReplace = {}
            switch  (id) {
                case "oldDetail": 
                    templateReplace = templateReplaceOD;
                    break;
                case "detail":
                    templateReplace = templateReplaceND;
                    break;
                case "tickerEntry":
                    templateReplace = templateReplaceTickerEntry;
                    break;                            
                default:
                    templateReplace = templateReplaceOverview;
                    break;
            }
            for (tmpCode in templateReplace) {
                var regex = new RegExp(tmpCode, "g");
                tmpTagArray = templateReplace[tmpCode].split(",");
                    tmpCodeArray = templateReplace[tmpCode].split(" ");
                    if (tmpCodeArray.length == 1) {
                        template = template.replace(regex, jQuery(templateReplace[tmpCode], item).text());
                    } 
                    else {
                        switch (tmpCodeArray[1]) {
                            case "video": 
                                switch($(tmpCodeArray[0],item).attr("type")) {
                                    case "video-layerplayer":
                                        template = template.replace(regex, params.pathToLayer.replace("{id}", jQuery(tmpCodeArray[0], item).find("video").attr("id")));
                                    break;
                                    case "video-mediathek":
                                        template = template.replace(regex, params.pathToMediathek + jQuery(tmpCodeArray[0], item).find("video").attr("id"));
                                    break;
                                
                                }
                            break;
                            case "enclosure":
                                template = template.replace(regex, jQuery("enclosure", item).attr("url"));
                            break;
                            case "im\\:cat_node":
                                var category = "";
                                jQuery(tmpCodeArray[0], item).find(tmpCodeArray[1]).each(function() {
                                    if (category == "")    {
                                        category = $(this).text();
                                    } else    {
                                        category += " " + $(this).text();
                                    }
                                });
                                template = template.replace(regex, category);
                            break;
                            case "image":
                                template = template.replace(regex, jQuery(tmpCodeArray[0], item).find("image").attr("src"));
                            break;
                            case "paragraph":
                                var para = "";
                                jQuery(tmpCodeArray[0], item).each(function() {
                                    switch($(this).attr("type")) {
                                        case "infobox":
                                            para += '<div class="newsDetailInfobox"><b>'+ jQuery(this).find("headline").text() +'</b><br />' + jQuery(this).find("paragraph").text() + '</div>';
                                            break;
                                        case "image":
                                            para += '<img class="'+((jQuery(this).attr("align") == "right") ? "imageAlignRight" : "imageAlignLeft")+'" src="'+ jQuery(this).find("image").attr("src") +'" />';
                                            break;    
                                        default: 
                                            para += ((typeof id == "number") ? "": "<p>") + jQuery(this).find("paragraph").text() + ((typeof id == "number") ? "": "</p>");
                                            break;
                                    }
                                })
                                template = template.replace(regex,para);
                            break;                            
                            case ">":
                                template = template.replace(regex, jQuery(params.xml).find(tmpCodeArray[0]).text());
                            break;    
                            case "<datetime>":
                                var date = new Date(jQuery(tmpCodeArray[0], item).text());
                                var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                                var month = (date.getMonth()+1) < 10 ? "0" + (date.getMonth()+1) : (date.getMonth()+1);
                                var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                                template = template.replace(regex, day + "." + month + "." + date.getFullYear() + " " + hours + ":" + minutes + " Uhr");                            
                                break;
                            case "<dateortime>":
                                var useTime = false;
                                var now = new Date();
                                var date = new Date(jQuery(tmpCodeArray[0], item).text());
                                if (date.getDate() == now.getDate() && date.getMonth() == now.getMonth() && date.getFullYear() == now.getFullYear()) {
                                    useTime = true;
                                }
                                var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                                var month = (date.getMonth()+1) < 10 ? "0" + (date.getMonth()+1) : (date.getMonth()+1);
                                var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                                if (useTime) {
                                    template = template.replace(regex, hours + ":" + minutes);                            
                                } 
                                else {
                                    template = template.replace(regex, day + "." + month + "."); // + date.getFullYear() + " " + hours + ":" + minutes + " Uhr");                            
                                }
                                break;                                        
                            case "<date>":
                                var date = new Date(jQuery(tmpCodeArray[0], item).text());
                                var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                                var month = (date.getMonth()+1) < 10 ? "0" + (date.getMonth()+1) : (date.getMonth()+1);
                                template = template.replace(regex, day + "." + month + ".");// + date.getFullYear());                            
                                break;        
                            case "<time>":
                                var date = new Date(jQuery(tmpCodeArray[0], item).text());
                                var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
                                var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
                                template = template.replace(regex, hours + ":" + minutes + " Uhr");                            
                                break;                                            
                            default:
                                template = template.replace(regex, jQuery(tmpCodeArray[0], item).find(tmpCodeArray[1]).text());
                            break;
                        }
                    }
                
            }
            if (template.indexOf('<a href="{video-link}">') != -1) {
                
                template = template.replace('<a href="{video-link}">', '').replace('" class="teaserBild" /></a>', '" class="teaserBild" />');
            } else {
                template = template.replace('playBtnDetail" style="display:none;"', 'playBtnDetail"');
            }                                
            _log(template);
            htmlTemplate = $(template);
            jQuery("im\\:related_link", item).each(function(index) { 
                
                jQuery(".teasLinklist", htmlTemplate).append('<li><a href="' + $(this).find('im\\:related_link_url', item).text() + '">' + $(this).find('im\\:related_link_title', item).text() + '</a></li>');
                jQuery(".tv_left", htmlTemplate).append('<a class="mehr" href="'+$(this).find('im\\:related_link_url', item).text()+'">'+$(this).find('im\\:related_link_title', item).text()+'</a><br />');
            });
        
            _parseHTML(htmlTemplate, selector);
            
        
        }
        _parseHTML = function(html, selector) {
            if (selector)
                jQuery(selector).append(html);
            else
                jQuery(that).append(html);
        }
        // Überprüfen ob die Werte aus RedDot richtig befüllt worden sind.
        if (typeof jQuery == "undefined") { alert("Kein JQuery vorhanden!"); return false;}
        if(!params.xmlpath) { alert("Keine XML-Datei hinterlegt!"); return false; }
        if(params.mode == "overview" && params.teaserLayout.length == 0) { alert("Kein Layout ausgewählt!"); return false; }
        _getXML();
        if (params.mode == "newsliste") {
            initPagination();
        }
            
        return this;
    }
})(jQuery);
