//function arround script for compatibility-reasons with other scripts using $-sign
jQuery(function($) {
	
	var heightList;
	var animtationTime = 300;
	var isCurrentlyAnimating = false;
	var currentlyActive = 0;
	
	$(document).ready(function(){
    
    var seitenleiste = $("#seitenleiste").find(".seitenleiste:has(div.seitenleiste_inner_content)"); 		
    //problem mit anderen title-boxen in der news box
		var numberOfBoxes = seitenleiste.size();
    
		heightList = new Array(numberOfBoxes);
		//seitenleiste_content �ndern in text, vorsicht mit anderen text_boxen in newsbox
		
    seitenleiste.find(".text").each(function(i){
			heightList[i]= this.offsetHeight;
		});
		
		seitenleiste.find(".text").css({height:0, display: "none"});
		seitenleiste.eq(currentlyActive).find(".text").css({height:heightList[0], display: "block"});  
		
		seitenleiste.find(".title").mouseover(function(event){
			var idx = seitenleiste.find(".title").index(this);

			if (!isCurrentlyAnimating && idx!=currentlyActive){
				isCurrentlyAnimating = true;
				seitenleiste.eq(currentlyActive).find(".seitenleiste_inner_content").css({display: "none"});
				seitenleiste.eq(currentlyActive).find(".text").animate({height: 0},animtationTime);
				currentlyActive = idx;
				
				seitenleiste.eq(currentlyActive).find(".seitenleiste_inner_content").css({display: "block"});
				seitenleiste.eq(idx).find(".text").animate({height: heightList[idx]},animtationTime);		
			}
			window.setTimeout(function(){
				isCurrentlyAnimating=false;
			}, animtationTime+100);
		});

	});
});
