jQuery(document).ready(function() {
  var bodyId = $("body").attr("id");
  var section = bodyId.substr(0,3) ;
  var section2 = bodyId.substr(4,7) ;

  /*
  var topPos = $(".logo").css("top");
  if( bodyId == "hom_00"){
    $(".logo").hide();
    $(".logo").css("top", "-300px");
    $(".logo").show();
    $(".logo").animate({ top: topPos  }).fadeIn("slow");
  }
  */
  
  $("#footer .echion img").hover(
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/active/echion.gif" ); },
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/inactive/echion.gif" ); }
  ); 
    
  $("#footer .magma img").hover(
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/active/magma.gif" ); },
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/inactive/magma.gif" ); }
  ); 
    
  $("#footer .media img").hover(
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/active/media.gif" ); },
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/inactive/media.gif" ); }
  ); 
    
  $("#footer .klang img").hover(
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/active/klang.gif" ); },
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/inactive/klang.gif" ); }
  ); 
    
  $("#footer .result img").hover(
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/active/result.gif" ); },
    function(){ $(this).attr( "src", "fileadmin/websites/echion/images/mediagroup_logos/inactive/result.gif" ); }
  ); 
  
  
  
  
  $("a").each(function(index){
    if ( $(this).attr("href") == bodyId + ".php" ){
      $(this).addClass("active");
    }
  })
   
  if ( section == "hom"){ $(".nav-left a[href='index.php']").addClass("active"); }
  if ( section == "ins"){ $(".nav-left a[href='ins_00.php']").addClass("active"); }
  if ( section == "dig"){ $(".nav-left a[href='dig_00.php']").addClass("active"); }
  if ( ( section == "ueb" ) || (section == "pre") ){ $(".nav-left a[href='ueb_00.php']").addClass("active"); }
  if ( section == "ref"){ $(".nav-left a[href='ref_00.php']").addClass("active"); }
  if ( section == "kon"){ $(".nav-left a[href='kon_00.php']").addClass("active"); }
  if ( section == "imp"){ $(".nav-left a[href='imp_00.php']").addClass("active"); }
  
  if ( section == "pre"){ $(".nav-top a[href='ueb_04.php']").addClass("active"); }
  
  if ( section == "med"){ $(".bottom-box-top h2").css({"background-image": "url(fileadmin/websites/echion/images/h2-ball-active.gif)"}); }

  if ( section == "new"){ $(".news-box h2").parent().css({"background-image": "url(fileadmin/websites/echion/images/left-top-up-active.gif)"}); }
  
  if ( section != "new" ){
    $(".news-box h2").hover(
      function(){
        $(this).parent().css({"background-image": "url(fileadmin/websites/echion/images/left-top-up-active.gif)"});
      },
      function(){
        $(this).parent().css({"background-image": "url(fileadmin/websites/echion/images/left-top-up.gif)"});
      }
    );
  }   
   
    $(".network h2").hover(
      function(){
        $(this).parent().css({"background-image": "url(fileadmin/websites/echion/images/left-top-up-active.gif)"});
      },
      function(){
        $(this).parent().css({"background-image": "url(fileadmin/websites/echion/images/left-top-up.gif)"});
      }
    ); 
    
  if ( section != "med" ){  
    $(".bottom-box-top h2").hover(
      function(){
        $(this).css({"background-image": "url(fileadmin/websites/echion/images/h2-ball-active.gif)"});
      },
      function(){
        $(this).css({"background-image": "url(fileadmin/websites/echion/images/h2-ball.gif)"});
      }
    );
  }
  
  $(".jcarousel-skin-tango").parent().css("cursor", "pointer");
 
  jQuery('#carousel').jcarousel({
      vertical: false,
      scroll: 1,
      visible : 1,
      auto: 2,
      wrap:'last',
      initCallback: carousel_initCallback,
      buttonNextHTML: null,
      buttonPrevHTML: null
  });
  
  jQuery('#networkCarousel').jcarousel({
      vertical: true,
      scroll: 1,
      visible : 1,
      auto: 3,
      wrap:'last',
      buttonNextHTML: null,
      buttonPrevHTML: null
  });  
  
});


function startSlideshow(carousel){
  carousel.startAuto(2);
  carousel.next();
  $(".startSlideShow").fadeOut( 300, function(){ $(".stopSlideShow").fadeIn(300) } );
}


function stopSlideshow(carousel){
  carousel.startAuto(0);
  $(".stopSlideShow").fadeOut( 300, function(){ $(".startSlideShow").fadeIn(300) } );  
}


function carousel_initCallback(carousel)
{ 
  //$(".startSlideShow").text("Slideshow starten");
 // $(".stopSlideShow").text("Slideshow anhalten");
  $(".startSlideShow").hide();
  $(".stopSlideShow").show();

  $(".jcarousel-skin-tango").bind( 'click', function(){ startSlideshow(carousel); });

  $(".startSlideShow").click(function(){
    startSlideshow(carousel);
    return(false);
  });
  
  $(".stopSlideShow").click(function(){
    stopSlideshow(carousel);
    return(false);
   });
}


