var species = {};
$('document').ready(function(){
    $.get( "/species", function( species_r ) {
        species_r.data.map(function(item) {
            species[item._id] = item
        });

        $( "#body" ).load( "/templates/home.html", function(){$("#load").fadeOut("slow");
            $.get("/info", function( data ) {
                var text = "<table class=\"info\">"
                $.each(data, function(i, obj) {
                    text += "<tr><td>"+i+"</td><td> "+obj+"</td></tr>";
                });
                text += "</table>"
                $( "#info" ).html( text );
                $("#load").fadeOut("slow");
            });
        });
        $("body").bgswitcher({
            images: ["/images/bg0.jpg", "/images/bg1.jpg", "/images/bg2.jpg", "/images/bg3.jpg", "/images/bg4.jpg"],
            loop: true,
            duration: 1500
        });
    });
});