
function slideSwitch() {
   var active = jQuery('#slideshow IMG.active');

   if ( active.length == 0 ) active = jQuery('#slideshow IMG:last');

   var next =  active.next().length ? active.next()
   : jQuery('#slideshow IMG:first');

   active.addClass('last-active');
   next.css({
      opacity: 0.0
   })
   .addClass('active')
   .animate({
      opacity: 1.0
   }, 1000, function() {
      active.removeClass('active last-active');
   });
}

jQuery(document).ready(function(){
   /*
   if( document.readyState != "complete" ){
      if ( jQuery.browser.webkit ){
         jQuery(window).load(function() {
            jQuery('.imageWrapper').each( function(){
               wordImage = jQuery(this).children('img');
               var pic = wordImage;
               pic.removeAttr("width");
               pic.removeAttr("height");
               jQuery(this).height( pic.height() );
            });
         });
      }
      else {
         jQuery(window).load(function() {
            jQuery('.imageWrapper').each( function(){
               wordImage = jQuery(this).children('img');
               wordImage.removeAttr("width");
               wordImage.removeAttr("height");
               wordImage.css({
                  width: "",
                  height: ""
               });
               var wordImageHeight = wordImage.height();
               jQuery(this).hide();
               jQuery(this).css( 'height',  wordImageHeight );
               jQuery(this).show();

            });
         });
      }
   }
   */
   jQuery('.hideDescription').click(function( event ){
      jQuery('.description').fadeOut();
      event.preventDefault();
   });
   jQuery('.imageWrapper ').live( 'click', function(){
      descriptionObject = jQuery(this).children('.description');
      if( descriptionObject.is( ':hidden' ) ){
            
         jQuery('.description').fadeOut();
            
         descriptionWidth = descriptionObject.width();
         descriptionHeight = descriptionObject.height();
         offsetAr = jQuery(this).offset();
         if( ( offsetAr.left + descriptionWidth ) > window.screen.availWidth ){
            tooMuch = ( offsetAr.left + descriptionWidth ) - window.screen.availWidth + 100;
            jQuery( descriptionObject.css({
               'left' : -tooMuch  + 'px'
            }));
         }
         if( ( offsetAr.top + descriptionHeight ) > window.screen.availHeight ){
            tooMuch = ( offsetAr.top + descriptionHeight ) - window.screen.availHeight + 100;
            jQuery( descriptionObject.css({
               'top' : -tooMuch  + 'px'
            }));
         }

         descriptionObject.css(
         {
            position : 'absolute',
            width : descriptionWidth ,
            height : descriptionHeight
         }
         );
         descriptionObject.fadeIn( 'slow' );
      }
   });
   jQuery('.imageWrapper').hover(
      function(){
         elementId = jQuery(this).attr('rel');
         jQuery(this).children('img').attr('src', './files/word_images/image_' + elementId + '_off.png');
      },
      function(){
         elementId = jQuery(this).attr('rel');
         jQuery(this).children('img').attr('src', './files/word_images/image_' + elementId + '_on.png');
      }
      )


   jQuery(".nav img").hover(function(event){
      jQuery( ".nav img" ).each(function(){
         var id = jQuery(this).attr("id");
         if(jQuery(this).attr("class") == "current" ||   jQuery(this).attr("class") == "active"){
            jQuery(this).attr({
               src: "files/ordner/navactive" + id + ".gif"
            });
         }
         else{
            jQuery(this).attr({
               src: "files/ordner/nav" + id + ".gif"
            });
         }
      });
      var id2 = jQuery(this).attr("id");
      jQuery(this).attr({
         src: "files/ordner/navactive" + id2 + ".gif"
      });
   });

   jQuery("#content").hover(function(event){
      jQuery(".nav img").each(function(){
         var id = jQuery(this).attr("id");
         if(jQuery(this).attr("class") == "current" || jQuery(this).attr("class") == "active"){
            jQuery(this).attr({
               src: "files/ordner/navactive" + id + ".gif"
            });
         }
         else{
            jQuery(this).attr({
               src: "files/ordner/nav" + id + ".gif"
            });
         }
      });
   });

   jQuery(".nav img").hover(function(event){
      jQuery( ".nav img" ).each(function(){
         var id = jQuery(this).attr("id");
         if(jQuery(this).attr("class") == "current" || jQuery(this).attr("class") == "active"){
            jQuery(this).attr({
               src: "files/ordner/navactive" + id + ".gif"
            });
         }
         else{
            jQuery(this).attr({
               src: "files/ordner/nav" + id + ".gif"
            });
         }
      });
      var id2 = jQuery(this).attr("id");
      jQuery(this).attr({
         src: "files/ordner/navactive" + id2 + ".gif"
      });
   });

   jQuery("#navi img").hover(function(){
      clearInterval(threadId);
   });

   jQuery(function() {
      var threadID;
      threadId = setInterval( "slideSwitch()", 5000 );
   });

   noScrollable = false;

   if( parseInt( jQuery('#article_id').html() )  == 35 ){
      if( jQuery('#einblickeSlideShow').html() != null ){
         jQuery('#page_up').remove();
         jQuery('.next').remove();
         jQuery('img[alt=top]').remove();
         jQuery('#content_container').css({
            'height' : '410px',
            'width' : '100%',
            'margin' : 0,
            'margin-top' : '15px',
            'left' : 0
            
         });
         jQuery('#content').css({
            'height' : '410px',
            'margin-top' : '36px',
            'width' : '100%',
            'text-align' : 'center'
         });
         
         var divWidth = jQuery('#content_container').width();
         if( document.readyState != "complete" ){
            jQuery('#einblickeSlideShow img').each( function () {
               var pic = jQuery(this);
               jQuery(window).load(function() {
                  pic.removeAttr("width");
                  pic.removeAttr("height");
                  pic.css( 'width', "" );
                  var imgWidth = pic.width();
                  var difference = divWidth - imgWidth;
                  pic.css( {
                     'margin-left' : (difference / 2) + 'px'
                  });
               });
            });
         }
      }

      jQuery('#einblickeSlideShow').cycle({
         fx : 'fade',
         fits : false
      });
      
   }
   else {
      var noScrollable = true;
   }
   if( noScrollable ){
      jQuery(function() {
         jQuery("div.scrollable").scrollable({
            size: 1,
            hoverClass: 'hover',
            vertical: true,
            clickable: 'true',
            speed: 600,
            easing: 'linear',
            prev: '.aprev',
            next:'.anext'
         });
      });
      jQuery('.prev').hover(
         function(){
            myScrollable = jQuery("div.scrollable").data("scrollable");
            myScrollable.move(-1);
            myInterval = setInterval( "myScrollable.move(-1)", 1000 ) ;

         },
         function(){
            window.clearInterval(myInterval);

         }
         );
      jQuery('.next').hover(
         function(){
            myScrollable = jQuery("div.scrollable").data("scrollable");
            myScrollable.move(1);
            myInterval = setInterval( "myScrollable.move(1)", 1000 ) ;
         },
         function(){
            window.clearInterval(myInterval);
         }

         );
   }
/*
   jQuery('div.items').serialScroll({

      items:'div',
		prev:'#page_down',
		next:'#page_up',
		axis : 'y',
      start:0, //as we are centering it, start at the 2nd
		duration:1200,
		force:true,
		stop:true,
		lock:false,
		cycle:true, //don't pull back once you reach the end
		jump: true, //click on the images to scroll to them
      event:'click'

	});
 */
});





