$(document).ready(function() {
   
    // PNGFix
    $(document).pngFix();

});




// #############################################################################

// InfiniteCaroussel Slider

$(document).ready(function () {
    $('.infiniteCarousel').infiniteCarousel();

  var autoscrolling = true;

  $('.infiniteScroll').infiniteCarousel().mouseover(function () {
    autoscrolling = false;
  }).mouseout(function () {
    autoscrolling = true;
  });

  setInterval(function () {
    if (autoscrolling) {
      $('.infiniteScroll').trigger('next');
    }
  }, 5000);

});

// #############################################################################

// History Slider

$(document).ready(function(){

  $(this).each(
    function()
    {
      $('.scroll-pane').jScrollPane(
        {
          showArrows: $(this).is('.arrow')
        }
      );
      var api = $(this).data('jsp');
      var throttleTimeout;
      $(window).bind(
        'resize',
        function()
        {
          if ($.browser.msie) {
            // IE fires multiple resize events while you are dragging the browser window which
            // causes it to crash if you try to update the scrollpane on every one. So we need
            // to throttle it to fire a maximum of once every 50 milliseconds...
            if (!throttleTimeout) {
              throttleTimeout = setTimeout(
                function()
                {
                  api.reinitialize();
                  throttleTimeout = null;
                },
                100
              );
            }
          } 
        }
      );
    }
  )
});

// #############################################################################

// Lightbox
$(document).ready(function(){
   $('.einzelbild_lightbox').lightbox();
});

// #############################################################################

// Pop-Up Fenster

$(document).ready(function(){
  $('.fenster_close').live('click', function() {
    $(this)
    $('.hidden').hide();
  });
});		

// #############################################################################

// Tabbox

$(document).ready(function(){
  var tabContainers = $('div#tabs > div');
  tabContainers.show().filter(':first').hide();

  $('div#tabs ul.tabnavi a').click(function () {
    tabContainers.hide();
    tabContainers.filter(this.hash).show();
    $('div#tabs ul.tabnavi a').removeClass('selected');
    $(this).addClass('selected');
    return false;
  }).filter(':first').click();
});

// #############################################################################

// DropDown Box anzeigen

var fadetime = 750;

function verzoegerung(){
  $("#dropdownbox").fadeIn(fadetime);
  $("#dropdownbox").removeClass('hide');
  $("#dropdownbox").addClass('visible');
  $("a.producgroups").addClass('active');  			
}

function stoper() {
  clearTimeout(timer);
}

$(document).ready(function(){

  $("a.producgroups").click(function(){
    if($("a.producgroups").hasClass('active')){
      $("#dropdownbox").removeClass('visible');
      $("#dropdownbox").addClass('hide');
      $("#dropdownbox").fadeOut(fadetime);        
      $("a.producgroups").removeClass('active');
    } else {
      $("#dropdownbox").fadeIn(fadetime); 
      $("#dropdownbox").removeClass('hide');
      $("#dropdownbox").addClass('visible');
      $("a.producgroups").addClass('active');  
    };
  });

  $("a.producgroups").mouseover(function() {
    timer = setTimeout("verzoegerung()", 500);			
  });
  
  $("a.producgroups").mouseleave(function(){
    stoper();
  });
  
  $("#dropdownbox").mouseleave(function(){
    $("#dropdownbox").fadeOut(fadetime);
    $("a.producgroups").removeClass('active');
  });

  // Start-Zustand
  $("#dropdownbox").css("display","none");
  $("#dropdownbox").addClass('hide');

});
