Trying to add/subtract variable
<p>I am trying to have something where when it is enabled it adds to a variable and when it is disabled it subtracts from the variable but when I <code>alert</code> the value of the variable is just comes up saying <code>NaN</code> Here is my code:</p>

<p>This is for enabling/disabling the button</p>

<pre><code>var speedrating;
function onoffButton(i, g, r)
{
    $(i).click(function () {
        if ($(i).html() == '&lt;a class="onoffswitch" id="' + g + 'ON"&gt;&lt;/a&gt;') {
            $(i).html('&lt;a class="onoffswitch" id="' + g + 'OFF"&gt;&lt;/a&gt;');
            speedrating -= r;
        } else {
            speedrating += r;
            $(i).html('&lt;a class="onoffswitch" id="' + g + 'ON"&gt;&lt;/a&gt;');
        }
        updateSpeedRate();
    });
}
</code></pre>

<p>Here is where it checks the variable to see which thing to do:</p>

<pre><code>function updateSpeedRate()
{
    if (speedrating &lt; 34) {
        $('.speedmeter').css('background-position', '0px -30px');
    } else {
        if (speedrating &lt; 67) {
            $('.speedmeter').css('background-position', '0px -15px');
        } else {
            $('.speedmeter').css('background-position', '0px 0px');
        }
    }
    alert(speedrating);
}
</code></pre>

<p>Then using the enable/disable object (the third number is the number I'm trying to work with):</p>

<pre><code>onoffButton("#switchRating", "rating", 10);

onoffButton("#switchFavicon", "favicon", 30);

onoffButton("#switchClock", "clockswitch", 10);

onoffButton("#switchWeather", "weatherswitch", 30);

onoffButton("#switchNotepad", "notepadswitch", 15);

onoffButton("#switchLinks", "linksswitch", 5);
</code></pre>
