var HonorRollRotate = {
    data: [],
    i: 0,
    padding: 5,

    start_fade: function () {
        $('honor_roll_wrap').hide();
        $('honor_roll_name').innerHTML = this.data[this.i][0];
        $('honor_roll_amount').innerHTML = this.data[this.i][1];
        // Position it to a random spot in the box
        var blockDim = $('honor_roll').getDimensions();
        var wrapDim = $('honor_roll_wrap').getDimensions();
        var x = Math.floor(Math.random() * (blockDim.width - wrapDim.width - this.padding));
        var y = Math.floor(Math.random() * (blockDim.height - wrapDim.height - this.padding));
        $('honor_roll_wrap').setStyle({ 'left': x + 'px' });
        $('honor_roll_wrap').setStyle({ 'top': y + 'px' });
        Effect.Appear('honor_roll_wrap', { duration: 1.5, afterFinish: this.end_fade.bind(this) });
        if (++this.i == this.data.length) {
            this.i = 0;
        }
    },

    end_fade: function () {
        Effect.Fade('honor_roll_wrap', { duration: 1.5, afterFinish: this.start_fade.bind(this) });
    }
}

var ThermometerGrow = {
    percent: 0,
    fullSrc: '',

    grow: function() {
        $('thermometer_bar').hide();
        var height = (this.percent / 100) * 142;
        $('thermometer_bar').setStyle({ height: height + 'px' });
        // Safari shows the bar at a random place in the page if we slide, so skip the effect
        if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) {
          $('thermometer_bar').show();
          return;
        }
        Effect.SlideDown('thermometer_bar', { duration: 2, afterFinish: this.checkFor100.bind(this) });
    },

    checkFor100: function() {
        if (this.percent == 100) {
            $('thermometer').setStyle({ backgroundImage: 'url(' + this.fullSrc + ')' });
        }
    }
}
