;(function($){

    $(document).ready(function(){

        // fancy fonts
        Cufon.replace('.navigation a,h1,h2,h3,#call-me .sendbutton', {
            hover: true
        });

        // add additional classes to avoid css3 :last-child and :first-child
        $('ul').find('li:first').addClass('first');
        $('ul').find('li:last').addClass('last');

        // add .hover to list items containing a link (to fix ie li:hover)
        $('ul').find('li:has(a)').hover(function(){
            $(this).addClass('hover');
        }, function(){
            $(this).removeClass('hover');
        });


        $('.column').find('p:first').addClass('intro');

        /* equal column height
        var maxColumnHeight = 0;
        $('.column').each(function(){
            maxColumnHeight = $(this).height() > maxColumnHeight ? $(this).height() : maxColumnHeight;
        });
        $('.column').css({ height: maxColumnHeight });
        */

	    // vertically center page
	    $(window).resize(function(){
            $('#container').css({
                paddingTop: Math.max(20, (($(window).height()-$('#container').height())/2))
            });
	    }).trigger('resize');

	    // gallery
		$('body').prepend('<ul class="navigation" id="gallery-navigation"><li><a id="prev" href="#">Vorige</a></li><li><a href="#" id="close">Sluiten</a><li><a id="next" href="#">Volgende</a></li></ul>');
        $('#prev').click($.fn.colorbox.prev);
        $('#next').click($.fn.colorbox.next);
        $('#close').click($.fn.colorbox.close);

	    $('a.panel').colorbox({
            onOpen: function(){
                $('#gallery-navigation')
                    .css({ opacity: 0 })
                    .show()
                    .animate({ opacity: 1 }, 300);
            },
            onClosed: function(){
                $('#gallery-navigation')
                    .hide();
            }
        });

    });

})(jQuery);
