$(document).ready(function() {
	/*
	* Debugging, kann nach Entwicklung gelöscht werden
	* muss die erste Zeile in der ready function sein!
	*/
	//$('body').append('<div id="js-debug" class="error"><p>JS</p></div>');
	
	
	/* Externe Links und PDFs in neuem Fenster öffnen */
	$("a[href$=pdf]").each(
	   function(){
	      $(this).attr('target', '_blank');
	});
	$("a[href^=http]").each(
	   function(){
		  if(this.href.indexOf(location.hostname) == -1) { 
	      $(this).attr('target', '_blank');
	    }
	});
	
	/* Tabellen Alternierung */
	$('table').each(function(){
		$(this).find('tr:odd').addClass("odd");
	});
	
	/* Demopic Styling, kann nach Entwicklung gelöscht werden */
	$('img').each(function(){
		a = $(this).attr("src");
		str = a.indexOf("dev_demopic");
		if(str != -1) {
			$(this).addClass("dev-demopic");
		};
	});
	
	$('#metanav ul li:first').before('<li><a href="">Home</a></li>');
	$('#metanav ul li:last a').css("border", "0 none");
	$('#content ul.box li:last-child').css("border", "0 none");
	$('#content ul.box li:last-child').css("padding-bottom", "0");
	
	$('.member p').hide();
	$('.member h2').click(function() {
		$('.member').removeClass("open");
		$(this).parent().addClass("open");
		$('.member p').hide('slow');
	  	$(this).parent().find("p").show('slow');
	});
	
	$('.news p').hide();
	$('.news ul').hide();
	$('.news .spacer').hide();
	$('.news h3').click(function() {
		$('.news').removeClass("open");
		$(this).parent().addClass("open");
		$('.news p').hide()
		$('.news ul').hide()
		$('.news').each(function(){
			$(this).find('p:first').show();
			$(this).find('ul.box').show();
		});
	  	$(this).parent().find("p").show();
		$(this).parent().find("ul").show();
		$(this).parent().find(".spacer").show();
	});
	$('.news').each(function(){
		$(this).find('p:first').show();
		$(this).find('ul.box').show();
	});
	
	$('.news-entry a').tooltip();
	
	$('.presse p').hide();
	$('.presse .spacer').hide();
	$('.presse ul').hide();
	$('.presse h3').click(function() {
		$('.presse').removeClass("open");
		$(this).parent().addClass("open");
		$('.presse p').hide()
	  	$(this).parent().find("p").show();
		$(this).parent().find(".spacer").show();
		$(this).parent().find("ul").show();
	});
	/*
	* Debugging, kann nach Entwicklung gelöscht werden
	* muss die letzte Zeile in der ready function sein!
	*/
	//$('#js-debug').removeClass("error");
});
