﻿/* 120 pixels max height 0 = 0, 140 = 2000 */
var initMeter = function(initVal, newVal, dateVal){
    $('#meter-label h2').text(initVal);
    $('#meter-label span').text(dateVal);
    $('#meter-add').text(newVal)
    initVal = initVal.replace(",","");
    if (initVal > 2000) {initVal = 2000};
    updateMeter(initVal, newVal);
}   

var initMeterModule = function(initVal, dateVal){
    $('#meter-module-label h2').text(initVal);
    $('#meter-module-label span').text(dateVal);
    initVal = initVal.replace(",","");
    if (initVal > 2000) {initVal = 2000};
    if (initVal < 1000) {
       var newHeight = Math.round(initVal * .015);
    } else {
       var newHeight = Math.round((initVal - 1000) * .08) + 15; 
    }
    
    $('#meter-module-star').blink({
        blinkCount: 5
    });
    
    $('#meter-module-top').animate({
        height: newHeight
    }, 5000, function() {
        // Animation complete.
    });
}   

var updateMeter = function(initVal, newVal){
    
    if (initVal < 1000) {
       var newHeight = Math.round(initVal * .024);
       $('#meter-top').css("height",Math.round((initVal - newVal) * .024));
    } else {
       var newHeight = Math.round((initVal - 1000) * .12) + 24; 
       $('#meter-top').css("height",Math.round((initVal - newVal - 1000) * .12) + 24);
    }
       
    $('#meter').show(); 
    
    $('#meter-star').blink({
        blinkCount: 5
    });
    
    $('#meter-top').animate({
        height: newHeight
    }, 5000, function() {
        // Animation complete.
    });
}  
 

