function tabson(idon, idoff){
	var i1 = document.getElementById(idon).style.display;
	if (i1 == 'none'){
		document.getElementById(idon).style.display = 'block';
		document.getElementById(idoff).style.display = 'none';
	}else{
		document.getElementById(idon).style.display = 'none';
		document.getElementById(idoff).style.display = 'block';
	}
}
function getRadioGroupValue(radioGroupObj){
	for (var i=0; i < radioGroupObj.length; i++){
		if (radioGroupObj[i].checked) {
			return radioGroupObj[i].value;
		}
	}
	return null;
}
function sendVote(action){
    //читаем данные из формы
	var extis = document.getElementById('vote2');
	var question = getRadioGroupValue(document.formVote.question);
	var comment = document.formVote.comment.value;
	if (extis) {
		var ext = getRadioGroupValue(document.formVote.ext);
	}else{
		var ext = 1;
	}
	if ((question==null || question==0) && comment=='') {
		$("#divVote").html('<br /><b>Потрібно зробити вибір!</b>').show();
		return false;
	}
	if (question!=null && ext==null) {
		$("#divVote").html('<br /><b>Потрібно зробити вибір!</b>').show();
		tabson('vote1','vote2');
		return false;
	}else{ 
		document.getElementById('vote1').style.display = 'none';
		document.getElementById('vote-submit').style.display = 'none';
		if (extis) {document.getElementById('vote2').style.display = 'none';}
		$("#divVote").html('<br /><img src="http://doc.osvita.ua/doc/i/spin16.gif"><br />').show();
		$.post(action,
		{
			"question": question, 
			"ext": ext, 
			"comment": comment
		},
			updateVoteForm
		);
	}
}
function updateVoteForm(data) { 
    var result = eval( '(' + data + ')' );
	if (result){
		$("#divVote").html('<font color="red">' + result.thank + '</font><br />' + result.results + ' ').show();
	}
}
