function zeroPad(num,count) {
    var numZeropad = num + '';
    while(numZeropad.length < count) {
        numZeropad = '0' + numZeropad;
    }
    return numZeropad;
}

$(document).ready(function() {
    
    //main content slider
    if ( $('#slider').length ) {
        $('#slider').anythingSlider({
            hashTags: false,
            buildArrows: true,
            buildNavigation: false,
            startText: '',
            stopText: '',
            autoPlay: true,
            delay: 7000,
            animationTime: 1000,
            easing: 'easeInOutExpo'
        });
        
        //irecycle animation
        $('#irecycle-frames').innerfademod();
    }
    
    //fade out last three images
    var images = $('#irecycle-frames img ');
    for (i=1; i<9; i++) {
        var opacity = (0.125 * i);
        images.eq(-i).css('opacity', opacity);
    }
    
    //sponsorbar animation
    $('#sponsor-container').innerfade({
        speed: 750,
        timeout: 3000
    });
    
    //add ribbon corners
    $('#sponsor-bar, #pledge-content').append('<div id="ribbon-fold-left"/><div id="ribbon-fold-right"/>');
    
    if ($('#done').length) {
        $('#total').hide();
    }
    
    /*Update homepage pledge count
    if ($('#pledge-count').length) {
        $.get('/pledge/count.php', function(data) {
            countStr = zeroPad(data, 4);
            countArr = countStr.split('');
            for (i=0; i<countArr.length; i++) {
                $('#pledge-count .digit').eq(i).text(countArr[i]);
            }
        });
    }
    */
});
