$(document).ready(function() {   

	$(".poll-ajax-loader").hide(); //hide the ajax loader
	$("#poll-message").hide(); //hide the ajax loader
	$(".poll-submit").click(function() {
		var ThisForm  = this.form.id; 
		
		if ($('input:radio[name=poll-answer-id]:checked').length) {
				
		var AnswerID = $('input:radio[name=poll-answer-id]:checked').val();
		
		var PollID = ThisForm.replace('PollForm','');
	
			$(ThisForm + '#poll-ajax-loader.' + PollID).show(); //show the ajax loader
			$.ajax({
				type: "POST",
				url: "/includes/poll.process.asp",
				data: { AnswerID: AnswerID, action: "vote", PollID: PollID },
				target: ('#output' + PollID),
				success: function(theResponse) {
						$('#poll-ajax-loader.' + PollID).hide(); //hide the ajax loader again
						$('#pollsubmit' + PollID).attr("disabled", "disabled"); //disable the submit button 
						$(ThisForm + '#input:radio').attr("disabled", "disabled");
						$('#output' + PollID).html(theResponse);
						$('#poll-ajax-loader.' + PollID).hide();
	
				}
			});
			return false; 

		} else {
			$('#poll-message.' + PollID).html("Please select an answer.").fadeTo("slow", 1, function(){
				setTimeout(function() {
					$('#poll-message.' + PollID).fadeOut("slow");
				}, 3000);
			});
			return false;
		}

	});

});

