﻿function neuesFenster(url, width, height) {
    w = window.open(url, "nw", "width=" + width + ",height=" + height + ",scrollbars=yes,resizable=yes");
    w.focus();
}

function newsTeaser() {
    $(document).ready(function() {
        // Erstmal alle zuklappen
        var url = location.href;
        elId = "j" + url.replace(/.*#[aA-zZ]_|[^0-9].*/g, "");
        //alert(typeof elId);
        if (elId != "")
            elId = document.getElementById(elId);
        if (elId != null) {
            $("div.block.meldungen").not(elId).find("div.newsinhalt:visible").fadeTo("fast", 0).slideUp("fast", function() {
                window.scrollTo(0, elId.offsetTop);
            });
        }
        else {
            $("div.block.meldungen").not(".meldungen:first").find("div.newsinhalt:visible").fadeTo("fast", 0).slideUp("fast");
        }
        // an alle nötigen Elemente die Funktion anhängen
        $("div.block.meldungen h2,div.block.meldungen h3").click(function() {
            var el = $(this).parent().find("div.newsinhalt:visible");
            if (el.size() > 0) {
                $(this).parent().toggleClass("meldungaktiv");
                $(el).fadeTo("normal", 0).slideUp("normal");
            }
            else {
                el = $(this).parent().find("div.newsinhalt:hidden")
                $(this).parent().toggleClass("meldungaktiv");
                $(el).slideDown("normal").fadeTo("normal", 1);
            }
        });
    });

}
function smartEditCheck()
{
    var isEdit = false;
    var m = top.location.href.toString().match(/.*\/(.+?)\./);
    if (m && m.length > 1)
    {
        if (m[1] == "SmartEdit")
        {
            isEdit = true;
        }
    }
    return isEdit;
}

// Funktion Slider
$(document).ready(function ()
{
    if (smartEditCheck())
    {
        $(".slide-item").css("display", "block");
        $(".slide-item img[src*='icon_reddot.gif']").css({"width": "auto", "height":"auto"});
    }
    else
    {
        $('.slide').each(function ()
        {
            var cycleObj = $(this);

            cycleObj.cycle({
                fx: 'slideY',
                height: '230px',
                speed: '1500',
                timeout: '6000',
                pause: '1'
            });

            var root = cycleObj.parent();
            var controls = root.find(".controls");

            //Mouseover + Mouseleaver Slide-Item
            root.find(".slide-item, .controls a").mouseover(function (event)
            {
                controls.css({ "display": "block" });
                controls.find("a").css({ "display": "inline" });
            }).mouseleave(function (event)
            {
                controls.css({ "display": "none" });
            });

            //mouseover+mouseleave  next + prev
            controls.find('.next, .prev').mouseover(function (event)
            {
                cycleObj.cycle('pause');
            }).mouseleave(function (event)
            {
                cycleObj.cycle('resume');
            }).click(function ()
            {
                var cssClass = $(this).attr("class");
                if (cssClass == "next")
                {
                    cycleObj.cycle('next');
                }
                else if (cssClass == "prev")
                {
                    cycleObj.cycle('prev');
                }
                else
                {
                    alert("geklickter Link hat kein next bzw. prev");
                }
            });

        });
    }
});
