function makeBanner(){
	var so = new SWFObject("http://www.nonverbla.de/bilder/newflash.swf", "newflash", "100%", "100%", "8", "#000");
	so.addParam("scale", "noscale");
	so.addParam("wmode", "transparent");
	so.addParam("allowFullscreen", "true");
	so.write("flashcontent");
}
function fullScreen(url) {
	fullscreen = window.open(url, "fullscreen", 'top=0,left=0,width='+(screen.availWidth)+', height='+(screen.availHeight-20)+', toolbar=0, location=0, directories=0, status=0, menubar=0, scrolling=0');
}

var boxes = new Array();
var loop;
var i;
var activeID = null;
var animationLoop;
var linkColors = new Array('#4abdff', '#7dff4a', '#ffde00', '#ff4ac6', '#4affdf');
var isAppleMobile = navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPhone/i);
var exactFit;

$(document).ready(function() {
	
	$('#content, #content-single').css("visibility", "visible");
	
	if(isFrontPage){
		exactFit = true;
	} else {
		exactFit = false;
	}
	setTimeout(function(){
		if(isFrontPage){
			activateFitting();
		}
		fadeInPosts();
		scrollLinks();
	}, 100);
	//postRollovers();
	postRollovers1();
	$("#content-single a:has(img)").click(function(e){
		//e.preventDefault();
		//alert($(this));
	})
})
function fadeInPosts(){
	$('#content .post').css({
		"opacity": "0",
		"visibility": "visible"
	});
	
	$("#content .post").each(function(index){
		if($(this).find('img').length > 0){
			$(this).find("img").one("load", function(){
				$(this).css({"width": "100%", "height": "auto"});
				var post = $(this).parents(".post");
				post.animate({opacity: 1, useTranslate3d:isAppleMobile}, 500 + Math.floor(Math.random() * 2000));
			}).each(function(){
				if(this.complete || (jQuery.browser.msie && parseInt(jQuery.browser.version) == 6)) {
					$(this).trigger("load");
				}
			});
		} else {
			$(this).animate({opacity: 1}, 500);
		}
	})
}
function postRollovers(){
	$('.post').mouseenter(function(){
		$(".post").css("z-index", "0");
		$(this).css("z-index", "100");
		$(this).addClass("mouseOver");
		var content = $(this).find(".post-content");
		content.css("outline", "3px solid #222");
		content.stop().animate({
			"margin-top": "-12px",
			"margin-right": "-24px",
			"margin-left": "-12px",
			"margin-bottom": "0px"
		}, 200)
	})
	$('.post').mouseleave(function(){
		$(this).removeClass("mouseOver");
		var content = $(this).find(".post-content");
		$(this).css("margin-bottom", "3px");
		content.stop().animate({
			"margin-top": "0px",
			"margin-right": "0px",
			"margin-left": "0px",
			"margin-bottom": "0px"
		}, 200, function(){
			content.css("outline", "0px none");
		})
	})
}
function postRollovers1(){
	$('#content .post-content').css({
		"opacity": "1"
	}).mouseenter(function(){
		$(this).stop().animate({
			"opacity": ".8"
		}, 1);
	}).mouseleave(function(){
		$(this).stop().animate({
			"opacity": "1"
		}, 200);
	})
}
// Loading Single Posts
function addLoadSingle(){
	$(".load-single").click(function(e){
		e.preventDefault();
		$("#all").animate({
			"margin-left": -$(window).width() + 'px'
		}, 200)
	})
}


function linkEffects(){
	$('.post a:not(.imglink)').mouseenter(function(){
		$(this).css('background', linkColors[Math.floor(Math.random() * linkColors.length)]);
	})
	$('.post a:not(.imglink)').mouseleave(function(){
		$(this).css('background', 'none');
	})
}
function scrollTo(target){
	if($(target).length > 0){
		$('html,body').animate({
			scrollTop: $(target).position().top + 'px'
		}, 1000);
	}
}
function scrollLinks(){
	$('a.anchor').click(function(e){
		e.preventDefault();
		scrollTo($(this).attr('href'));
		
	})
}
function activateFitting(){
	$(window).resize(function(){
		fit();
	})
	fit();
}
function fit(){
	$("#footer").css("min-height", $(window).height() + "px");
	var minWidth = 350;
	if($("#content .post").length > 1){
		fitColumns($("#content"), minWidth, true);
		fitColumns($("#information"), minWidth, false, 2);
	}
}
function fitColumns(container, minWidth, indentOnStart, maxColumns){
	
	container.css("min-width", 480 + "px");
	
	firstPost = container.find('.post:first');
	stageWidth = container.width() - 70;
	columnsAmount = Math.floor(stageWidth / minWidth);
	columnWidth = Math.floor(stageWidth / columnsAmount);
	postsAmount = container.find(".post").length;
	
	if(columnsAmount < 1){
		columnsAmount = 1;
	} else if(columnsAmount > maxColumns){
		columnsAmount = maxColumns;
	}
	var i;
	
	if(container.find('.post').length >= columnsAmount && container.find('.column').length != columnsAmount){
		// der unsichtbare tmp-container für die Posts
		container.append("<div id='container-tmp'></div>");
		container.find('.post').each(function(){
			$('#container-tmp').append($(this));
		})
		// remove the old columns
		container.find('.column').remove();
		// create the columns
		for(i = 0; i<columnsAmount; i++){
			container.append('<div class="column column-'+i+'"></div>');
		}
		// add the posts to the columns
		for(i = 0; i<postsAmount; i++){
			var currentPost = $("#container-tmp #post-" + i);
			if(currentPost.length == 0){
				currentPost = $("#container-tmp .post:first");
			}
			appendToShortestColumn(container, currentPost);
		}
		// den unsichtbaren container wegwerfen
		$("#container-tmp").remove();
	}
	// adjust the column's top-margin
	for(i = 0; i<container.find('.column').length; i++){
		if(i * columnWidth > 450 && indentOnStart){
			container.find('.column-' + i).css('margin-top', '0px');
		} else {
			container.find('.column-' + i).css('margin-top', '200px');
		}
	}
	// die Breite der Columns festlegen
	if(exactFit){
		container.find('.column').css('width', columnWidth + 'px');
	}
	container.find('.column:last').addClass("last-column");
	
}
function appendToShortestColumn(container, post){
	var shortestColumn = container.find(".column:first");
	container.find(".column").each(function(){
		if($(this).height() < shortestColumn.height()){
			shortestColumn = $(this);
		}
	})
	post.appendTo(shortestColumn);
}







