$(document).ready(function(){
	$("#poll").submit(formProcess); // setup the submit handler
  
	if ($("#poll-results").length > 0 ) {
		animateResults();
	}
});

function animateResults() {
  $("#poll-results div").each(
  	function(){
    	var percentage = $(this).next().text();
      	$(this).css({width: "0%"}).animate({width: percentage}, 'slow');
  	}
	);
}


function formProcess(event){
  event.preventDefault();
  
  var id = $("input[@name='pollvote']:checked").attr("value");
  var pollquestion = $("#pollquestion").val();
  
  $("#poll-container").fadeOut("slow",function(){
    $(this).empty();
    
	jQuery.post('/app/modules/poll/pod.cfm', {'pollquestion': pollquestion, 'pollvote': id}, function(data) {
	  $("#poll-container").append(data).fadeIn("slow",function(){
	    animateResults();}
		);
	});
}); // POST to /some/script.php
	
}

