//SCROLL TO

$(function() {

    function scroll(direction) {

        var scroll, i,
                positions = [],
                here = $(window).scrollTop(),
                collection = $('.post');

        collection.each(function() {
            positions.push(parseInt($(this).offset()['top'],10));
        });

        for(i = 0; i < positions.length; i++) {
            if (direction == 'next' && positions[i] > here) { scroll = collection.get(i); break; }
            if (direction == 'prev' && i > 0 && positions[i] >= here) { scroll = collection.get(i-1); break; }
        }

        if (scroll) {
            $.scrollTo(scroll, {
                duration: 750       
            });
        }

        return false;
    }

    $("#next,#prev").click(function() {        
        return scroll($(this).attr('id'));        
    });

    $(".ScrollTo").click(function() {
        $.scrollTo($($(this).attr("href")), {
            duration: 750
        });
        return false;
    });

});

// FADE MENU

//<![CDATA[
$(document).ready(function () {
	//Append a div with hover class to all the LI
	$('#navMenu li').append('<div class="hover"><\/div>');
	$('#navMenu li').hover(
		//Mouseover, fadeIn the hidden hover class	
		function() {
			$(this).children('div').fadeIn('1000');	
		}, 
		//Mouseout, fadeOut the hover class
		function() {
			$(this).children('div').fadeOut('1000');	
	});
});
//]]>


// FANCYBOX

		$(document).ready(function() {
			$("a[rel=example_group]").fancybox({
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
		});
		

		
		
// CUFON

Cufon.replace('#navMenu li, #kontakt');
Cufon.replace('h1, h2, h3, h4, h5');
