$(document).ready(function() {
	
	//$('.overview_item:nth-child(2n)').after('<br style="clear:both;" />') ;
	var i = 0 ;
	$('.empty_page').children().each(function() {
		
		if(!$(this).hasClass('overview_item')) {
			$(this).before('<br style="clear:both;" />') ;
			$(this).after('<br style="clear:both;" />') ;
			i = 0 ;
		} 
		else {
			i++;
			if(i == 2) {
				$(this).after('<br style="clear:both;" />') ;
				i = 0 ;
 			}
		}
		
	}) ;
	
	
	//alert('hier') ;
	$(window).resize(function() {
		
		//alert($(window).height()) ;
		//alert($('body').height()+100) ;
		if($('#wrapper').height()+100 >= $(window).height())
		{
			$('#footer').css('position', 'relative') ;
		}
		else
		{
			$('#footer').css('position', 'absolute') ;
		}
	
	}) ;
	
	$(window).trigger('resize') ;
	
	
	

	
	$('#slide_container').cycle({fx: 'fade', timeout: 5000, before: function(current, next) {
		
		var title = $(this).attr('title') ;
		var link = $(this).attr('href') ;
		
		$('#slide_info h1').html(title) ;
		$('#slide_info a').attr('href', link) ;
		
		/*if(first == false)
		{
			$('#slide_info').animate({opacity: 0}) ;
		}
		
		$('#slide_info').queue(function() {
			
			
			
			$('#slide_info h1').html(title) ;
			$('#slide_info a').attr('href', link) ;
			
			
			$('#slide_info').stop(true).animate({opacity: 1}) ;
				
		}) ;
		
		first = false ;*/
		
	}}) ;


	

	
	$('#arrow_left').click(function() {
		$('#slide_container').cycle('prev') ;
	}) ;
	
	$('#arrow_right').click(function() {
		$('#slide_container').cycle('next') ;
	}) ;
	
	//slide_timeout = setTimeout(slideNext(), 2000) ;
	
	
	
	
	/**
	 * DETAIL SEITE
	 */

	/*$('#lightbox_img a').lightBox({
		imageBtnPrev: 'img/lightbox_arrow_left.png',
		imageBtnNext: 'img/lightbox_arrow_right.png',
		imageLoading: 'img/spinner.gif',
		imageBtnClose: 'img/closebox.png'
	});

	lightbox_opened = false ;	
			
	$('#featured_image').click(function() {
		$('#lightbox_img a img:first').trigger('click') ;
		//alert('open');
	}) ;
		
	$('#lightbox_link').click(function() {
		$('#lightbox_img a img:first').trigger('click') ;
		return false ;
	}) ;*/
	
	
	lightbox.create() ;
	
	$('#lightbox_link').click(function() {
		lightbox.open() ;
		
		return false ;
	}) ;
	
	$('#largecol').children('img').click(function() {
			
		var target = parseInt($(this).attr('id').replace(/_big/g, '').slice(6)) ;
			
		lightbox.open(target) ;
			
	}) ;
	
	
	
	
	
	
}) ;




slideNext = function() {
		if(current_slide >= 2)
		{
			current_slide = -1 ;
		}
		
		current_slide = current_slide + 1 ;
		//alert(current_slide) ;
		
		prev = $('.slide_img')
		$('#slideshow').prepend(
			$('<div>').addClass('slide_img').css({zIndex: 500, backgroundImage: 'url('+featured[current_slide]+')'})
		) ;
		
		//slide_timeout = setTimeout(slideNext(), 500) ;
		prev.fadeOut(500, function() {
			//alert('done') ;
			//clearTimeout(slide_timeout) ;
			slide_timeout = setTimeout(slideNext(), 2000) ;
			prev.remove();
		}) ;

} ;


















