<!--

var namePrefix = '';
var scores = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

function ResetForm()
{
    scores = new Array(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

    var rankForm = document.getElementById('ranking');
    if (rankForm != null)
    {
        rankForm.reset();
    }

    var total = TotalScore();

    ShowTotal(total);
        
    ShowRank(total);
}

function ScoreChange(rdoItem)
{
    
    if ((rdoItem.name) && (rdoItem.name.indexOf(namePrefix) == 0))
    {
        var score = 0;
        var questionNum = rdoItem.name.substr(namePrefix.length);

        switch (rdoItem.value)
        {
            case 'Poor':
                score = 1;
                break;
            case 'Good':
                score = 5;
                break;
            case 'Very Good':
                score = 7;
                break;
            case 'Strong':
                score = 10;
                break;
        }
        
        var questionIdx = parseInt(questionNum) - 1;
        scores[questionIdx] = score;

        var total = TotalScore();
        
        ShowTotal(total);
        
        ShowRank(total);
    }
}

function AllSelected()
{
    var all = true;
    for (var i = 0; all && i < scores.length; i++)
    {
        if (scores[i] == 0)
        {
            all = false;
        }
    }
    return all;
}

function TotalScore()
{
    var score = 0;
    for (var i = 0; i < scores.length; i++)
    {
        score += scores[i];
    }
    return score;
}

function ShowTotal(total)
{
    var scoreSpan = document.getElementById('spanScore');
    if (scoreSpan)
    {
        scoreSpan.innerHTML = total;
    }
}

function ShowRank(total)
{
    var rankSpan = document.getElementById('spanRank');
    if (rankSpan)
    {
        var rank = 'Not calculated';
        if (AllSelected())
        {
            if (total < 75)
            {
                rank = 'Poor';
            }
            if ((total >= 75) && (total < 90))
            {
                rank = 'Unsatisfactory';
            }
            if ((total >= 90) && (total < 102))
            {
                rank = 'Good';
            }
            if ((total >= 102) && (total < 141))
            {
                rank = 'Very Good';
            }
            if (total >= 141)
            {
                rank = 'Strong';
            }
        }
        rankSpan.innerHTML = rank;
    }
}

//-->

