/* 
jquery functions 
*/

// container show/hide
$(function(){
		   $('a[href^="#infobox"]').click(function(e){
				var el = $(this).attr('href');
				
				// alle offenen divs schliessen ausser geklickter
				$('div[id^="infobox"]:visible').each( function(ev){
						element = $(this).attr('id');
						if('#'+element != el){
							slideToggle('#'+element,false); //up
							$('a[href="#'+element+'"]').removeClass('less').addClass('more');
							}		
				});
				
				// toggle geklickter link
				slideToggle('div'+el);
				
				// setzte link class je nach status
				if($(this).hasClass('more')) {$(this).removeClass('more').addClass('less')} else{ $(this).removeClass('less').addClass('more')};
				
				// für faden  
				/*if($('div'+el).css('display') == 'block'){
					$('div'+el).fadeOut();
				}else{
					$('div'+el).fadeIn();
				}*/
				return false;
				});
		   });

// slide jump effect temporaryfix

function slideToggle(el, bShow){
  var $el = $(el), height = $el.data("originalHeight"), visible = $el.is(":visible");
  // if the bShow isn't present, get the current visibility and reverse it
  if( arguments.length == 1 ) bShow = !visible;
  // if the current visiblilty is the same as the requested state, cancel
  if( bShow == visible ) return false;
  if( !height ){
    height = $el.show().height();
    // update the height
    $el.data("originalHeight", height);
    // if the element was hidden, hide it again
    if( !visible ) $el.hide().css({height: 0});
  }
  // expand the knowledge (instead of slideDown/Up, use custom animation which applies fix)
  if( bShow ){
    $el.show().animate({height: height}, {duration: 550});
  } else {
    $el.animate({height: 0}, {duration: 550, complete:function (){
        $el.hide();
      }
    });
  }
}