$(document).ready(function()
{
  $("div#left_navi li > a", "#col1_content").live("click", function ()
  {
    if ($(this).parent().parent().hasClass("no_sub"))
      return true;

    $(this).parent().siblings(".current").each(function (i, elem)
    {
      $(elem).contents("ul").css("display", "block").slideUp("normal");
      $(elem).toggleClass("current");
    });
    $(this).next("ul").slideToggle("normal").parent().toggleClass("current");
    //$(this);

    return false;
  });

  var teaser_height = 0;
  $("div.index_news", "#index_teaser").each(function (i, elem)
  {
    elem_height = $(elem).outerHeight(true);
    if (teaser_height < elem_height)
      teaser_height = elem_height;

    $(elem).css("position", "absolute");
    if (i > 0)
      $(elem).css("display", "none");
    $("#news_switch").css("display", "block");
  });
  $("#index_teaser").height(teaser_height);

  $("a", "#news_switch").click(function()
  {
    var el_index = $("a", "#news_switch").index(this);

    if ($(this).hasClass("current")) // Ist das Element schon aktiv
      return false;

    $("div.index_news:visible", "#index_teaser").fadeOut("slow");
    $("div.index_news:eq("+el_index+")", "#index_teaser").fadeIn("slow", function ()
    {
      teaser_height = $(this).outerHeight(true);
      $("#index_teaser").animate({height: teaser_height});
    });

    $("#news_switch a.current").toggleClass("current");
    $(this).toggleClass("current");
/*
    var teaser_container = $("#index_teaser");
    var el_current = $("div.index_news:visible", teaser_container);
    var el_next = $("div.index_news:eq("+el_index+")", teaser_container);

    el_current.fadeOut("slow");
    teaser_container.animate({height: el_next.outerHeight(true)});
    el_next.fadeIn("slow");

    $("#news_switch a.current").toggleClass("current");
    $(this).toggleClass("current");
*/
    return false;
  });
});

function switch_news()
{
  var current_link = $("a.current", "#news_switch");
  var current_index = $("a", "#news_switch").index(current_link);
  var next_index;

  if (current_index == 2)
    next_index = 0;
  else
    next_index = current_index + 1;

  $("a:eq("+next_index+")", "#news_switch").click();
  setTimeout("switch_news()", 10000);
}
setTimeout("switch_news()", 10000);

