var projectTxt = {
    container:null,

    init: function(container){
        projectTxt.container = container;

        $(projectTxt.container+" p").hide();
        $(projectTxt.container+" h1").append("<span>info</span>");

        $(projectTxt.container+" h1").click(function(){
            $(projectTxt.container+" p").slideToggle('medium');
            $(projectTxt.container+" h1 span").toggleClass('open');

            return false;
        }).toggle(
            function(){
                $(projectTxt.container+" h1 span").html('exit');
                $(projectTxt.container).fadeTo("slow", 1);
            },
            function(){
                $(projectTxt.container+" h1 span").html('info');
                $(projectTxt.container).fadeTo("slow", 0.6);
            }
        );
    }
}

$(document).ready(function(){
    $("body").addClass('javascript');

    if($("#project-txt").length > 0){
        projectTxt.init("#project-txt");
    }

    if($("#who-we-are").length > 0){
        $("#who-we-are td div").hide();

        $("#who-we-are td#john").mouseover(function(){
            $("#who-we-are td#carlijn div").fadeIn();
        })

        $("#who-we-are td#carlijn").mouseover(function(){
            $("#who-we-are td#john div").fadeIn();
        })

        $("#who-we-are td").mouseout(function(){
            $("#who-we-are td div").hide();
        })

    }

    if($("#slides li").length > 1){
        var counter = 0;
        $("#content").after("<ul id='image-paging'><li><a href='#' id='prev'>previous</a></li><li class='sep'>></li><li><a href='#' id='next'>next image</a></li></ul>");

        $("#slides li").hide();
        $("#slides li:first").fadeIn('slow');

        $("#slides li").click(function(){
            $(this).fadeOut('medium');
            $(this).next().fadeIn('medium');

            if($(this).next().length == 0){
                $("#slides li:first").fadeIn('medium');
                counter = 0;
            }else{
                counter++;
            }
        });

        $("#next").click(function(){
            $("#slides li").fadeOut('medium');
            if($("#slides li.slide_"+(counter+1)).length == 0){
                $("#slides li:first").fadeIn('medium');
                counter = 0;
            }else{
                $("#slides li.slide_"+counter).next().fadeIn('medium');
                counter++;
            }
            return false;
        });

        $("#prev").click(function(){
            $("#slides li").fadeOut('medium');
            if($("#slides li.slide_"+(counter-1)).length == 0){
                $("#slides li:last").fadeIn('medium');
                counter = ($("#slides li").length - 1);
            }else{
                $("#slides li.slide_"+counter).prev().fadeIn('medium');
                counter--;
            }
            return false;
        });
    }
});