function do_vote(poll_id) {
	
	var showResponse = function (originalRequest) {
	//alert(originalRequest.responseText+' dadasdasdasdasd');
	$('poll_choices').update(originalRequest.responseText);
	if (choice != 0) 
	//$('clicktovote').update('<button id="vote" type="button" onclick="location.href=\'www.smartparenting.com.ph/polls\'">VIEW POLL ARCHIVE</button>');
	$('clicktovote').update('THANK YOU FOR VOTING');
								};
	var showProgress = function () { $('poll_choices').update('<li>Processing vote...</li>'); };
	
	var whichitem = 0;
	var choice = 0;
	
	while (whichitem < document.pollform.pchoice_id.length)
	{
		if (document.pollform.pchoice_id[whichitem].checked) 
			choice = document.pollform.pchoice_id[whichitem].value;
		whichitem++;
	}
	
	var url = "http://www.smartparenting.com.ph/templates/polls/vote.xml.php";
	var pollParams = "poll_id="+poll_id+"&choice_id="+choice+"&mode="+ $('vote').innerHTML;
	//alert(pollParams);
	if (choice == 0) $('clicktovote').update('<button id="vote" type="button" onclick="do_vote('+poll_id+'); set_poll_btn_caption('+poll_id+');">BACK</button>');
	
	var myAjax = new Ajax.Request( url,	{method: 'get', parameters: pollParams, onComplete: showResponse} );
	pageTracker._trackPageview(chnnl+"/poll");

//	urchinTracker("ajax"+chnnl+"/poll");
}

function set_poll_btn_caption(poll_id)
{
	if ($('vote').innerHTML == "BACK") 
	{
		$('clicktovote').update('<button id="vote" type="button" onclick="do_vote('+poll_id+')">VIEW RESULTS</button>');
	} else {
		$('clicktovote').update('<button id="vote" type="button" onclick="do_vote('+poll_id+')">VOTE!</button>');
	}
}

