function getCheckedValue(radioObj) {
        if(!radioObj)
                return "";
        var radioLength = radioObj.length;
        if(radioLength == null)
                if(radioObj.checked)
                     return radioObj.value;
				else 
                        return "";
        for(var i = 0; i < radioLength; i++) {
                if(radioObj[i].checked) {
                        return radioObj[i].value;
                }
        }
        return "";
}

function score(form){
var score = 0;
var formvalid = "yes";

var a1 = getCheckedValue(form.q1);
var a2 = getCheckedValue(form.q2);
var a3 = getCheckedValue(form.q3);
var a4 = getCheckedValue(form.q4);
var a5 = getCheckedValue(form.q5);
var a6 = getCheckedValue(form.q6);
var a7 = getCheckedValue(form.q7);
var a8 = getCheckedValue(form.q8);
var a9 = getCheckedValue(form.q9);
var a10 = getCheckedValue(form.q10);
var a11 = getCheckedValue(form.q11);

if (a1 == ""){
alert("Please answer question 1");
formvalid = "no";
} 

else if (a2 == ""){
alert("Please answer question 2");
formvalid = "no";
}

else if (a3 == ""){
alert("Please answer question 3");
formvalid = "no";
}

else if (a4 == ""){
alert("Please answer question 4");
formvalid = "no";
}

else if (a5 == ""){
alert("Please answer question 5");
formvalid = "no";
}

else if (a6 == ""){
alert("Please answer question 6");
formvalid = "no";
}

else if (a7 == ""){
alert("Please answer question 7");
formvalid = "no";
}

else if (a8 == ""){
alert("Please answer question 8");
formvalid = "no";
}

else if (a9 == ""){
alert("Please answer question 9");
formvalid = "no";
}

else if (a10 == ""){
alert("Please answer question 10");
formvalid = "no";
}

else if (a11 == ""){
alert("Please answer question 11");
formvalid = "no";
}

else { // tally score

score = (score * 1) + (a1 * 1);
score = (score * 1) + (a2 * 1);
score = (score * 1) + (a3 * 1);
score = (score * 1) + (a4 * 1);
score = (score * 1) + (a5 * 1);
score = (score * 1) + (a6 * 1);
score = (score * 1) + (a7 * 1);
score = (score * 1) + (a8 * 1);
score = (score * 1) + (a9 * 1);
score = (score * 1) + (a10 * 1);
score = (score * 1) + (a11 * 1);

}

if (formvalid == "yes"){
var start = '<hr size="1" noshade color="#7F7B6D" class="hrpad" /><p class="heading"><br />How to Score Yourself</p><p>The above are some commonly held, but incorrect beliefs of mental illness, so the more "false" you scored, the higher your mental health IQ.</p><p class="redheading">Your Score: '+ score +'</p>';
var finish = '<table border="0" cellspacing="2" cellpadding="2"><tr><td><img src="images/arrow.gif" width="13" height="9" /></td><td><a href="facts.htm">Mental Health Facts</a></td></tr></table>';

if (score <= 7) {
document.getElementById("my_score").innerHTML = start +'<p>A score of 0-7 indicates that, like many people, you hold many negative and erroneous beliefs about mental illness. Knowing the facts about mental illness may be helpful in reducing your misunderstanding and even anxiety. Who knows, this knowledge may enable you to get support or at least point sufferers in the right direction.</p>' + finish;
}

else if (score >= 8 && score <= 10) {
document.getElementById("my_score").innerHTML = start +'<p>While you are generally free of the more common myths of mental illness, there are still a few blind spots which have been found to inhibit sufferers and their loved ones from seeking attention. You may want to find out the facts about mental illness.</p>' + finish;
}

else if (score >= 11) {
document.getElementById("my_score").innerHTML = start +'<p>Congratulations, you are free of the common prejudices people often have of the mentally ill. It is people like you who can be very helpful in providing an environment which supports the mentally ill on their road to recovery.</p>' + finish;
}

} else {

// form is invalid

}

}
