$(document).ready(function()
{
  function unmaskMail(mailLink){$.ajax({type:"POST",url:"_ajax.unmaskMail.php",data:{code:mailLink.attr("rel")},dataType:"json",error:function(XMLHttpRequest, textStatus, errorThrown){alert(textStatus + "\n" + errorThrown);},success:function(data){if(data.error){alert(data.error);}else{mailLink.attr("href", data.href);mailLink.html(data.title);mailLink.removeAttr("rel");mailLink.removeAttr("target");}}});}
  //$("a[class='email']").each(function(){var mailLink = $(this);unmaskMail(mailLink);});
  $("a[class='email']").click(function(){var mailLink = $(this); if (mailLink.attr("rel")){unmaskMail(mailLink);return false;} });
});

$(document).ready(function()
{

  /*
   * Startseite: Image-Roll
   */

  var img_list = $("#col3_image_roll div");
  var img_list_navi = $("<ul>");

  for (var i=0; i<img_list.length; i++)
  {
    if (i > 0)
      img_list_navi.append("<li><a>" + (i + 1) + "</a></li>");
    else
      img_list_navi.append("<li><a class=\"current\">" + (i + 1) + "</a></li>");
  }

  $(img_list_navi.selector + "li:first a").addClass("current");
  img_list_navi.appendTo("#col3_image_roll");

  $(img_list.selector + ":gt(0)").hide();

  $("li a", "#col3_image_roll").click(function()
  {
    var el_index = $("li a", "#col3_image_roll").index(this);

    if ($(this).hasClass("current")) // Ist das Element schon aktiv
      return false;

    $("div:visible", "#col3_image_roll").fadeOut("slow");
    $("div:eq("+el_index+")", "#col3_image_roll").fadeIn("slow");

    $("li a.current", "#col3_image_roll").toggleClass("current");
    $(this).toggleClass("current");

    window.clearInterval(teaserSwitch);
    teaserSwitch = window.setInterval("switch_teaser()", 7500);

    return false;
  });
});
function switch_teaser()
{
  var current_link = $("li a.current", "#col3_image_roll");
  var current_index = $("li a", "#col3_image_roll").index(current_link);

  var el_amount = $("div", "#col3_image_roll").length;

  if (current_index == (el_amount - 1))
    next_index = 0;
  else
    next_index = current_index + 1;

  $("li a:eq("+next_index+")", "#col3_image_roll ul").click();
}
var teaserSwitch = window.setInterval("switch_teaser()", 7500);
