$(function(){

	// isotope - masonryHorizontal
	$('#overview').isotope({
		itemSelector: '.box',
		layoutMode: 'masonryHorizontal',
		resizesContainer: true
	});
	
	// isotope - masonry
	$("#single-post #wrapPost").isotope({
		itemSelector: ".box",
		layoutMode: 'masonry',
		resizeContainer: true
	});

	// box-shadow mit individuelle bg-color
	$("#overview .box").hover(function(){
		$color = $(this).css("background-color");
		$(this).css("box-shadow", "0px 0px 10px "+$color);
		$(this).css("opacity", 0.9);
	}, function(){
		$(this).css("opacity", 1.0);
		$(this).css("box-shadow", "none");
	});
	
	$("#single-post .box").hover(function(){
		$color = $(this).css("background-color");
		$(this).css("box-shadow", "0px 0px 10px "+$color);
	}, function(){
		$(this).css("box-shadow", "none");
	});
	
	// vertikaler scroll wird zu horizontalem scroll
	$(window).mousewheel(function(e, d)
	{
		if(d < 0) { // scrolldown
			$s = $(document).scrollLeft();
			$(document).scrollLeft($s+100);
		}
		if(d > 0) { // scrollup
			$s = $(document).scrollLeft();
			$(document).scrollLeft($s-100);
		}
	});
	
	// Nav verstecken X__X
	$n = $("nav");
	$nm = 1;
	$nh = $n.height()+40;
	
	$("p.navToggle").click(function(){
		if($nm == 0){
			$(this).css("background-position", "0 0");
			$n.animate({"bottom": 0}, "slow");
			$nm = 1;
		}
		else
		{
			$(this).css("background-position", "0 -45px");
			$n.animate({"bottom": "-"+$nh+"px"}, "slow");
			$nm = 0;
		}
	});
	
	// Headlines Index
	$("h2 a").wrap("<span></span>");
	$("h2 span.only-text").wrapInner('<p class="chakalaka"></p>');
	
	// bg absoften?
	$("section#single-post").parent().append('<div id="whiteymcwhite"></div>');
	
	/* KLICK */
	$("#overview .box h2 span a").parents(".box").click(function(){
		$href = $(this).find("a").attr("href");
		location.href = $href;
	});
	
	// HEADER
	$("header").hover(function(){
		$(this).animate({boxShadow: "0px 0px 10px #000"});
	}, function(){
		$(this).animate({boxShadow: "none"});
	});
	
	// Galerie
	$('div[rel^="galerie"]').prettyPhoto();
	
});
