$(function() {
    
    /* Background picture picker for front page. */
    
    $(".pick").bind("click", function() { 
        clearInterval(sleeper);
        $(this).trigger("update_background");
    });
    
    $(".pick").bind("update_background", function() {
        var target = "#" + $(this).attr("id").replace(/pick/i, "slide");
        
        $(".pick").removeClass("on");
        $(this).addClass("on");
        
        $(".slide").fadeOut(2000);
        $(target).fadeIn(1000);

        return false;
    });
    
    /* Randomly change background picture in frontpage every 6 seconds. */
    var sleeper = setInterval(function() {
        $(".pick:not(.on)").sort(function() { 
          return Math.round(Math.random())-0.5;
        }).slice(0,1).trigger("update_background");
    }, 6000);

});

$(document).ready(function(){
	
	$(".toggle_container").hide();
 
	$("h3.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
	});
 
});

$(function() {

    $('#container').hide();
    $('#container').fadeIn(700);

});
