cr1 = 0;
cg1 = 146;
cb1 = 62;
cr2 = 9;
cg2 = 44;
cb2 = 74;
function vote_process() {
	params = 'questionaryid='+$('questionaryid').value;
	data = $('vote_form').getInputs();
	votes_count = 0;
	for(var i=0; i<data.length; i++) {
		if (data[i].checked) {
			params = params + '&' + data[i].name + '=' + data[i].value;
			votes_count++;
			data[i].checked = false;
		}
	}
	if (votes_count) {
		url = $('vote_form').action+'?'+params;
		new Ajax.Request(url,
		{
			method:'get',
			onSuccess: function(transport){
				if (transport.responseText) {
					//alert(transport.responseText);
					if (!transport.responseText.isJSON()) {
						showRes();
						alert(alreadyVoted);
					}
					else {
						var data = transport.responseText.evalJSON();
						for(var i in data) {
							$('percentage_'+i).innerHTML = data[i]['percent'];
							$('counter_'+i).innerHTML = data[i]['count'];
							getGradientColor(data[i]['percent'], cr1,cg1,cb1,cr2,cg2,cb2, 'progressbar_'+i);
							$('progressbar_'+i).style.width = ''+data[i]['percent']+'%';
						}
						showRes();
						alert(th);
					}
				} else {alert(error);}
			},
			onFailure: function() {alert(error);}
		});
	} else alert(choise);
}
function showRes() {
	$('questionaryform').style.display='none';
	$('questionaryform').style.visibility='hidden';
	$('questionaryres').style.display='block';
	$('questionaryres').style.visibility='visible';

}

//author Ramm
function getGradientColor(percent, r1, g1, b1, r2, g2, b2, id) {
	kr = (r2-r1)/100;
	kg = (g2-g1)/100;
	kb = (b2-b1)/100;
	r = Math.round(r1+percent*kr);
	g = Math.round(g1+percent*kg);
	b = Math.round(b1+percent*kb);
	if ($(id)) {
		$(id).style.backgroundColor = 'rgb('+r+','+g+','+b+')';
	}
}
