
$(document).ready(function(){
	// init news slider
	$(".accessible_news_slider").accessNews({
		speed : "normal",
		slideBy : 5
	});
	// init news toggle
	$('.news-teaser.toggle .news-list-container').hide();
	$('.news-teaser.toggle .news-list-container').css('height', 175);
	// init news visible at once
	$('.news-teaser.visible .nav').show();

	$('.news-teaser.toggle h2').hover(
		function () {
			if ($(this).siblings('.news-list-container').css('display') == 'none') {
				if (!$(this).children('.hint').size()) {
					$(this).append('<div class="hint">Klicken f&uuml;r Details</div>');
				}
				$(this).children('.hint').slideToggle();
			}
		}, 
		function () {
			$(this).children('.hint').slideToggle();
		}
	);
	
	cObjArray = new Array();
	$('.news-teaser.toggle h2').click(function(){
		$('.news-list-container:visible').slideUp('slow'); // hide all visible
		$(this).children('.hint').remove();
		// set slider back to default settings
		$('.news-teaser.toggle .nav').hide(); // hide all slider nav
		$('.news-teaser.toggle .nav .back').hide();
		$('.news-teaser.toggle .nav.more-than-x .next').css('display', 'inline');
		// display news
		container = $(this).siblings('.news-list-container');
		container.css('left', '0');
		if (container.css('display') == 'none') {
			container.siblings('.nav').toggle();
			container.children('.news-list-item').hide();
			container.slideToggle('slow');
			container.children('.news-list-item').each(function (i) {
				cObjArray[i] = $(this);
				cObjArray['time_' + i] = 0.5 + i/4;
				setTimeout(
					function(){
						cObjArray[i].fadeIn();
					},
					cObjArray['time_' + i] * 1000
				);
			});
		}
		return false;
	});
});

$(window).load(function() {
	$(".news-teaser, .upper").liquidCanvas("[border{color:#000;width:2} fill{color:#fff}] => roundedRect{radius:16}");
});