/* Accordionfunktion fuer Akademie spezial-Container */
$(document).ready(function(){
  
  /* Linklisten auf Artikelseiten setzen */ 
  $(".article ul li a").parent().parent().addClass("link");
    
  /* Akkordeon auf der Startseite */
  $(".accordion_headline").click(function(){
    var wrappin_el_class=$(this).parent().parent().parent().attr("class");
    if($(this).next().css("display")=="block"){slide_down=0}
    else{slide_down=1}$("."+wrappin_el_class+" .accordion_content").slideUp("fast");

  $("."+wrappin_el_class+" .accordion_headline img").attr("src","../i/icon_arrow_right.gif");
    if(0!=slide_down){$(this).next().slideDown("fast");
    $(this).children("img").attr("src","../i/icon_arrow_down.gif");
    if($(this).children("a").children("img").attr("src")!=undefined){$(this).children("a").children("img").attr("src","../i/icon_arrow_down.gif")}}});

  // GoogleMap beim Seitenladen ausblenden
  $(".hotel_map").addClass("hide");

  $(".accordion_hotel").click(function(){
    var obj = $(this).parent().parent().parent().attr("class");
    
    if($(this).parent().parent().children('.hotel_map').css("position")=="absolute"){ 
      slide_down=1; 
    }else{
      slide_down=0;
      if($(this).parent().parent().children('.hotel_map').css("display")=="block"){slide_down=0}else{slide_down=1}
    }
    
    if(1!=slide_down){
      $("."+obj+" .hotel_map").slideUp("fast");
      $("."+obj+" .hotel_detail .accordion_hotel").text("Standort");
  
      $("."+obj+" .hotel_detail .accordion_hotel").removeClass("retract");
      $("."+obj+" .hotel_detail .accordion_hotel").addClass("expand");
    }

    if(0!=slide_down){
      $(this).parent().parent().children(".hotel_map").css("display","none");
      $(this).parent().parent().children(".hotel_map").removeClass("hide");
      $(this).parent().parent().children(".hotel_map").slideDown("fast");
      $(this).text("Standort");
      $(this).removeClass("expand");
      $(this).addClass("retract");
    }
   });

  

   $(".show_map").click(function(){
    var obj = $(this).parent().parent().parent().attr("class");
    
    if($('.hotel_map').css("position")=="absolute"){ 
      slide_down=1; 
    }else{
      slide_down=0;
      if($('.hotel_map').css("display")=="block"){slide_down=0}else{slide_down=1}
    }
    
    if(1!=slide_down){
      $(".hotel_map").slideUp("fast");
      $(this).text("Standort anzeigen");
  
      $(this).removeClass("retract");
      $(this).addClass("expand");
    }
    
    if(0!=slide_down){
      $(".hotel_map").css("display","none");
      $(".hotel_map").removeClass("hide");
      $(".hotel_map").slideDown("fast");
      
      $(this).text("Standort ausblenden");
      $(this).removeClass("expand");
      $(this).addClass("retract");
    }
  });    
   
  if($(".front_stage").html() != null){  
    IntervalId = setInterval( "animate_teaser()", 6000 );
  }  
   
  //Startseiten-Buehne
  $('.front_stage').mouseover(function () {
    IntervalId = clearInterval ( IntervalId );
  })
  $('.navi_extension').mouseover(function () {
    IntervalId = clearInterval ( IntervalId );
  })
  
  // Beim Verlassen geht der Effekt weiter.
  $('.front_stage').mouseleave(function () {
    IntervalId = setInterval( "animate_teaser()", 6000 );
  }) 
  $('.navi_extension').mouseleave(function () {
    IntervalId = setInterval( "animate_teaser()", 6000 );
  })
  
  
        
  //Mouse-Over 
  $('.front_stage').hover(
    function() {
           
      /* alle Menuepunkte auf inaktiv zuruecksetzen */
      $('.front_stage').removeClass("active");
      /* alle Menuepunkte mit einem grauen Border-Bottom versehen */
      /* $('.front_stage').css('border-bottom', '1px solid #dededa'); */
      /* aktueller Menuepunkt hervorheben */
      $(this).addClass("active");
      /* Unterer Rand des darüberliegenden Menuepunkt ausblenden */
      /* $(this).prev('.front_stage').css('border-bottom', '1px solid #ffffff'); */
      
           
      $('.navi_extension.active').hide();
      $('.navi_extension.active').removeClass("active");
	  
	  // hide all
	  for (var i=1;i<6;i++) {
		$('#block'+i).hide();
		$('#block'+i).removeClass("CTactive");
	  }
	  
	  var id = $(this).attr('id');
      var nr = $(this).attr('id').substr(id.length-1, id.length);
	  
	  // show specific
      $('#navi_extension_'+nr).show();
	  $('#block'+nr).show();
      $('#navi_extension_'+nr).addClass("active");      
	  $('#block'+nr).addClass("CTactive");
    }, 
    function() {
    }
  );
      
});


function animate_teaser() {   
 
  var id = $('.navi_extension.active').attr('id');
  var nr = id.substr(id.length-1, id.length);
  /*$('.front_stage').css('border-bottom', '1px solid #dededa');*/

  /* $('.navi_extension.active').fadeOut(400); */
  $('#block'+nr).fadeOut(400); 
  $('.navi_extension.active').hide();
  $('#block'+nr).hide();
  $('.navi_extension.active').removeClass("active");
  $('#block'+nr).removeClass("CTactive");
  $('.front_stage.active').removeClass("active")
  /* var nr = id.substr(id.length-1, id.length); */
  
  if (nr < 5) {
    nr++;
  } else {
    nr = 1;
  }  
  
  /* $('#navi_extension_'+nr).fadeIn(1800); */
  $('#block'+nr).fadeIn(1800);
  $('#navi_extension_'+nr).show();
  $('#block'+nr).show();
  $('#navi_extension_'+nr).addClass("active"); 
  $('#block'+nr).addClass("CTactive");
  $('#front_stage_'+nr).addClass("active");   
  /*$('#front_stage_'+nr).prev('.front_stage').css('border-bottom', '1px solid #ffffff');*/
  
}


