/**
 * Image Fader
 * 
 * This Javascript file starts the slideshow with a fade
 * effect for every imagewrap element (one or more images)
 * in a given container.    
 *  
 * @author Nicolas Sell
 * @date 10-12-2009
 *     
 */   

 // When the document is ready and loaded
 $(document).ready(function() {

//class="thickbox" zu allen Bildern unterhalb vom Menüpunkt staunen hinzugefügt
   
  $('#maske_staunen_bilder_links .csc-textpic-imagewrap').each(function(index){
     var image = $('img', this);
     
     $(this).html('<a href="' + $(image).attr("src") + '" class="thickbox" title="' + $(image).attr("title") + '">'+$(this).html()+'</a>');
     $('#maske_staunen_bilder_links .csc-textpic-imagewrap a').addClass("thickbox");
     $('.thickbox:last-child').attr('rel', 'galerie');
  });
  
  // Wait before effect starts
  var waitBeforeFadeIn = 500;

  $(this).wait(waitBeforeFadeIn, function() {
    // Calling the effect
    fadeTheImage();      
  });    
 });
 
 
 function fadeTheImage() {
  var fadeInTime = 1500;
  var fadeInTimeOut = 1500;
  var fadeInEffect = 'fade';
  var fadeInSpeed = 1500;
   
  // FadeIn because the imagewraps are visibility: hidden    
  $('#maske_sehen_bottom_links .csc-textpic-imagewrap').fadeIn(fadeInTime, function() {
    //After FadeIn, starting the slideshow       
    $('#maske_sehen_bottom_links .csc-textpic-imagewrap').cycle({fx: fadeInEffect, timeout: fadeInTimeOut, speed: fadeInSpeed});
  }); 
  $('#maske_staunen_bottom_links .csc-textpic-imagewrap').fadeIn(fadeInTime, function() {
    //After FadeIn, starting the slideshow       
    $('#maske_staunen_bottom_links .csc-textpic-imagewrap').cycle({fx: fadeInEffect, timeout: fadeInTimeOut, speed: fadeInSpeed});
  }); 
  $('#maske_staunen_bottom_rechts .csc-textpic-imagewrap').fadeIn(fadeInTime, function() {
    //After FadeIn, starting the slideshow       
    $('#maske_staunen_bottom_rechts .csc-textpic-imagewrap').cycle({fx: fadeInEffect, timeout: fadeInTimeOut, speed: fadeInSpeed});
  });  
 }
 
  
