jQuery.noConflict();
  
jQuery(document).ready(function($){
	
	
	/////////////////////
	// bildleiste 
	/////////////////////
	
	// vars
	var ul = '#bildleiste > ul';
	var li = '#bildleiste > ul > li';
	var no = '#bildleiste > ul > li.no';
	var act = '#bildleiste > ul > li.act';
	var big = '#bildleiste > ul > li.big';
	var a = '#bildleiste > ul > li > a';
	
	// adjust position on page load
	$(li).each(function(index) {
		if ($(this).is(big)) {
			$(ul).css('left','-' + index * 100 + 'px');
		}
	});
	
	// adjust position for animation
	function position() {
		$(li).each(function(index) {
			if ($(this).is(big)) {
				$(ul).animate({
					'left' : '-' + index * 100 + 'px'
				}, 500);
			}
		});
	}
	
	// arrows
	function arrows() {
		$('> span', a).replaceWith('');
		$(big).prev().children('a').append('<span class="left"></span>');
		$(big).next().children('a').append('<span class="right"></span>');
	}
	
	// click on small one
	$(a).click(function() {
		if (! $(this).parent(li).is(act)) {
			$(this).parent(li).addClass('big');
			$(act).removeClass('big');
			link();
			arrows();
			position();
			$(this).parent(li).switchClass('no', 'act', 500);
			$(act).switchClass('act', 'no', 500);
			return false;
		}
	});
	
	// if no act
	if (! $(act).length) {
		$(li + ':eq(2)').removeClass('no').addClass('act big');
		$(li).each(function(index) {
			if ($(this).is(big)) {
				$(ul).css('left','-' + index * 100 + 'px');
			}
		});
	}
	
	// link dl on act
	function link() {
		$('> dl', big).click(function() {
			window.location.href = $(this).prev('a').attr('href');
		});
	}
	
	arrows();
	link();
		

	/////////////////////
	// news toggle
	/////////////////////	
	
	// vars
	var item = '#c4 > .news-latest-container .news-latest-item';
	var archive = '#c4 > .news-latest-container .news-latest-gotoarchive';
	var height1 = $(item + ':eq(1)').height();
	var height2 = $(item + ':eq(2)').height();
	
	// slide toggle
	$(item + ':eq(1)').height(height1);
	$(item + ':eq(2)').height(height2);
	$(item + ':gt(0)').hide();
	$(archive).hide();
	$('.aufzu').click(function() {
		$(item + ':gt(0)').slideToggle();
		$(archive).slideToggle();
	});
	$('.aufzu').toggle(function() {
		$(this).css('background-position','center -10px');
	}, function () {
		$(this).css('background-position','center 0');
	});

});

