$(function(){
    var picnum = 10; //total number of pics
    var rndo = Math.ceil(Math.random() * picnum); //random first pic
    var rndo2; //used to calculate next pic
    $('.slideshow img').hide(); //hide all images
    $('.slideshow :nth-child(' + rndo + ')').fadeIn('slow'); //fade in first pic
    setInterval(function(){
        do {
            rndo2 = Math.ceil(Math.random() * picnum); //random next pic
        } while(rndo == rndo2) //make sure next pic != current pic
        $('.slideshow :nth-child(' + rndo + ')').fadeOut('slow'); //fade out current pic
        $('.slideshow :nth-child(' + rndo2 + ')').fadeIn('slow'); //fade in next pic
        rndo = rndo2; //refresh current pic
    }, 5000);
});

$(function(){
    var pic2 = Math.ceil(Math.random() * $('.spons > a').length); //total number of pics
    $('.spons a').hide(); //hide all images
    $('.spons :nth-child(' + pic2 + ')').show(); //show selected ad
});

function toggle () {
    var speed = 'normal';
    
    if ($('#fbcontent').is(":hidden")) {
        $('#fbcontent').slideDown(speed);
    }
    else {
        $('#fbcontent').slideUp(speed);
    }
}
