$(document).ready(function() {
   if ( $('.zusatzmenue').length ) {
    
    $('.pic_top').find("img").each ( 
      function (intIndex) { 
        $(this).attr('id','pic_top');
      }
    );
    
    initHandlingZusatzinfos(); 
    
    $('.zusatzmenue').find("a").each (
      function (index) { 
        $(this).click(
          function(pE) {
            showSelectedZusatzinfo(index,$(this));
            StopEvent(pE);
          }  
        );
      }
    );   
   } else {
    showAllZusatzinfos() 
   }
}
);



function initHandlingZusatzinfos() {
  identifyZusatzinfos();
  lastObj = '';
  initImgSrc = $('#pic_top').attr('src');
  initImgW = $('#pic_top').attr('width');
  initImgH = $('#pic_top').attr('height');
  initImgAlt = $('#pic_top').attr('alt');
}

function identifyZusatzinfos () {
  $('.pic_zusatz').each ( 
    function (intIndex) { 
      $(this).attr('id','pic_zusatz'+intIndex);
    }
  );

  $('.zusatztxt').each ( 
    function (intIndex) { 
      $(this).attr('id','zusatztxt'+intIndex);
    }
  );
}

function hideAllZusatzinfos() {
  $('.zusatztxt').each ( 
    function (intIndex) { 
      $(this).hide();
    }
  );
}

function showAllZusatzinfos() {
  $('.zusatztxt').each ( 
    function (intIndex) { 
      $(this).show();
    }
  );
}

function showSelectedZusatzinfo(id,curObj) {
  
  if (lastObj != ""){ // Handling um den zuvor aktiv gekennzeichneten Menuepunkt wieder zu deaktivieren   
    if (lastObj != curObj) {
      lastObj.parent().removeAttr('class');
    }
  }

  hideAllZusatzinfos(); // erst wieder alle Texte ausblenden
  curObj.parent().attr('class','aktiv'); // Menuepunkt als aktiv kennzeichnen
  $('#zusatztxt'+id).show(); // bevor der vom Benutzer angeklickte Text eingeblendet wird
  
   
  if ($('#pic_zusatz'+id).find("img").length) 
  {
    $('#pic_top').css('visibility','visible');
    //alert($('#pic_zusatz'+id).find("img").attr('width'));
    //alert($('#pic_zusatz'+id).find("img").attr('width'));
    $('#pic_top').attr('src',$('#pic_zusatz'+id).find("img").attr('src'));
    //$('#pic_top').attr('width',$('#pic_zusatz'+id).find("img").attr('width'));
    //$('#pic_top').attr('height',$('#pic_zusatz'+id).find("img").attr('height'));
    $('#pic_top').attr('title',$('#pic_zusatz'+id).find("img").attr('alt'));
    $('#pic_top').attr('alt',$('#pic_zusatz'+id).find("img").attr('alt'));
  } else {
    $('#pic_top').css('visibility','hidden');
    /*$('#pic_top').attr('src',initImgSrc);
    $('#pic_top').attr('width',initImgW);
    $('#pic_top').attr('height',initImgH);
    $('#pic_top').attr('title',initImgAlt);
    $('#pic_top').attr('alt',initImgAlt);*/
  }
  
  lastObj = curObj;  
}

function StopEvent(pE)
{
   if (!pE)
     if (window.event)
	     pE = window.event;
     else
	     return;
       if (pE.cancelBubble != null)
          pE.cancelBubble = true;
       if (pE.stopPropagation)
          pE.stopPropagation();
       if (pE.preventDefault)
          pE.preventDefault();
       if (window.event)
          pE.returnValue = false;
       if (pE.cancel != null)
          pE.cancel = true;
}  // StopEvent