$(document).ready(function(){
	/* Navigation */
	$('li.twActive').parents('li').addClass('twActive');
	
	/* Infoboxen */
	var maxW = null;
	var maxH = null;
	$('div.logo_slider a div.img img').each(function(){
		var w = $(this).width(); var h = $(this).height();
		if(maxW < w){maxW = w;}
		if(maxH < h){maxH = h;}
	});
	$('div.logo_slider a div.img').css({
		'width': maxW + 'px',
		'height': maxH + 'px'
	}).children('img').each(function(){
		var w = $(this).width(); var h = $(this).height();
		if(w < maxW){$(this).css('margin-left', (maxW-w)/2+'px');}
		if(h < maxH){$(this).css('margin-top', (maxH-h)/2+'px');}
	});	
	var buttons = '<span id="prev">&nbsp;</span><span id="next">&nbsp;</span>'
	$('div.logo_slider').parent().append(buttons);
	$('div.logo_slider').cycle({
		fx: 'scrollLeft',
		next: 'span#next',
		prev: 'span#prev',
		pause: 1,
		speed: 1500,
		random: 1,
		timeout: 6000
	});
	
	$('ul.foerderer').each(function(i){
		var del = 1100 - ((1 + i) * 170);
		$(this).cycle({
			fx: 'scrollLeft',
			pause: 1,
			speed: 1500,
			random: 1,
			timeout: 6000,
			delay: del
		}).css({
			'width': '100%',
			'display': 'block'
		});
	}).children('li').css({
		'display': 'block',
		'width': '100%',
		'background': '#F6F6F6'
	});
	
	/* to-the-top-button */
	$('<li></li>').addClass('to-the-top-button')
	.html('<a href="#pageTop" title="Klicken Sie hier, um zum Seitenanfang zu gelangen">zum Seitenanfang</a>')
	.appendTo('div.footer_inner ul.tpTopMenu').click(function(){
		$.scrollToElement( $('#pageTop') );
		return false;
	});
	
	/* IE-Debug */
	$('ul.tpTopMenu li:last-child').addClass('last-child');
	$('ul.tpTopMenu li:first-child').addClass('first-child');
	if($.browser.msie) {
		v = $.browser.version.split('.'); var nv = v[0]; for(var x=1; x<v.length; x++) { nv += '-'+v[x]; }
		var cls = 'msie_'+nv; var cls2 = 'msie_'+v[0];
		$('div#wrapper').addClass('msie').addClass(cls).addClass(cls2);
	}
	
	/* IE6-Hinweis */
	if($.browser.msie && $.browser.version == '6.0') {
		$('<div></div>').addClass('ie6-dialog').attr('title', 'Internet Explorer 6')
		.html('<p>Lieber Besucher,</p><p>Sie verwenden einen veralteten Browser, f&uuml;r den diese Website nicht optimiert wurde. Einige Element werde fehlerhaft oder garnicht angezeigt. Bitte installieren Sie einen aktuelleren Browser, um dieses Problem zu beheben.</p><p>Im Folgenden finden Sie eine Auflistung kostenloser, empfehlenswerter Webbrowser. <ul style="list-style: disc inside;"><li><a href="http://www.mozilla-europe.org/de/firefox/">Firefox 3.x</a></li><li><a href="http://www.google.de/chrome">Google Chrome</a></li><li><a href="http://www.opera.com/browser/">Opera 10.x</a></li></ul></p>')
		.appendTo('body').dialog({
			modal: true
		});
	}
});