﻿
function Tune(startN, finishN, increment)
{
    for (var i = startN; i < finishN; i++)
    {
        var obj = document.getElementById("accord" + i);
        if (obj)
        {
            var t = obj.innerHTML.charAt(0), tnew = "?";
            var tIndex = 0;
            
            if (t == "A") tIndex = 0;
            if (t == "B") tIndex = 1;
            if (t == "H") tIndex = 2;
            if (t == "C") tIndex = 3;
            if (t == "D") tIndex = 5;
            if (t == "E") tIndex = 7;
            if (t == "F") tIndex = 8;
            if (t == "G") tIndex = 10;
            
            if (obj.innerHTML.charAt(1) == 'b') { tIndex--; t = t + "b"; };
            if (obj.innerHTML.charAt(1) == '#') { tIndex++; t = t + "#"; };           
            
            tIndex += increment;
            while (tIndex < 0)
                tIndex += 12;
            while (tIndex >= 12)
                tIndex -= 12;
                
            if (tIndex == 0) tnew = "A";
            if (tIndex == 1) tnew = "Hb";
            if (tIndex == 2) tnew = "H";
            if (tIndex == 3) tnew = "C";
            if (tIndex == 4) tnew = "C#";
            if (tIndex == 5) tnew = "D";
            if (tIndex == 6) tnew = "D#";
            if (tIndex == 7) tnew = "E";
            if (tIndex == 8) tnew = "F";
            if (tIndex == 9) tnew = "F#";
            if (tIndex == 10) tnew = "G";
            if (tIndex == 11) tnew = "G#";
            
            obj.innerHTML = tnew + obj.innerHTML.substring(t.length);
        }
    }
}

