// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function getVote(){ 
  //alert(getCheckedValue(document.forms["voteform"].elements["votechoice"]));
  return getCheckedValue(document.forms["voteform"].elements["votechoice"]);
} 



function checkAnswer(liId ){
 //alert(getCheckedValue(document.testGem.elements[radioName]));
 if (liId == 1 || document.getElementById("li6").style.display =='' ){
     var  sum = getSum();
     document.getElementById("s2").style.display ='none';      document.getElementById("s1").style.display ='none';  document.getElementById("s0").style.display ='none';
     //alert(sum);
     if(sum >=4){
       document.getElementById("s2").style.display =''; 
     }else if (sum>=2){
       document.getElementById("s1").style.display =''; 
     }else{
       document.getElementById("s0").style.display =''; 
     }
 }else{
     document.getElementById(liId).style.display ='';
 } 
}

function getSum(){
     var sum = 0;
     for(i=0; i<7 ; i++){
       sum += parseInt(getCheckedValue(document.testGem.elements["q" + i]));
     }
     return sum;
}
