$(document).ready(function(){
	initializeDialogs();
	fixInhaltsblocks();
	hefttabelle();
	ticker();
});


function ticker(){
	try{
		var ticker_holder = $(".ticker p").get(0);
		var ticker_text = $(".ticker").get(0);
		var ticker_pos = ticker_text.parentNode.offsetWidth;
		var ticker_data = $(ticker_holder).html();
		$(ticker_text).parent().html('<marquee scrollamount="1" scrolldelay="40">' + ticker_data + '</marquee>');
		$("marquee").hover(
			function(){$(this).get(0).stop();},
			function(){$(this).get(0).start();}
		);
	}
	catch (o) {}
}

function initializeDialogs(){
	$("#dialog").dialog({
		autoOpen:false,
		modal:true
	});
}

function callThemenplan(){
	var daten = $("#parameter").serialize();
	$.post("/ajax/themenplan.inc.php",daten,function(data){
		$("#themenplan").html(data);
		hefttabelle();
	});
}

var endhoehe;

function fixInhaltsblocks(){
	if($(".inhaltsblock").size()){
		$(".inhaltsblock").each(function(){
			var hoehe = $(this).height();
			if(endhoehe){
				if(hoehe >= endhoehe){
					endhoehe = hoehe;
				}
			}
			else{
				endhoehe = hoehe;
			}
			return endhoehe;
		});
		$(".inhaltsblock").each(function(){
			$(this).height(endhoehe);
		});
	}
}

function fixZeitschriftenliste(){
	if($(".zeitschriftenliste").size()){
		$(".zeitschriftenliste").each(function(){
			var hoehe = $(this).height();
			if(endhoehe){
				if(hoehe >= endhoehe){
					endhoehe = hoehe;
				}
			}
			else{
				endhoehe = hoehe;
			}
			return endhoehe;
		});
		$(".zeitschriftenliste").each(function(){
			$(this).height(endhoehe+10);
		});
	}
}

function callThemenplan2(){
	//alert('hi');
}

function hefttabelle(){
	$("table.hefttabelle tr:nth-child(even)").addClass("even");
	$("table.hefttabelle tr:nth-child(odd)").addClass("odd");
}


