$(function () {
	updateAnswer("/n700/enquete/xml/?limit=10&question_id=" + question_id);
	
	$(".table p").hover(
		function () {
			$(this).children().eq(3).show();
		},
		function () {
			$(this).children().eq(3).hide();
		}
	)
	
	$(".q li a").each( function() {
		var option_id = $(".q li a").index(this);
		$(this).click( function () {
			$(".q li").removeClass("selected");
			$(this).parent().addClass("selected");
			updateAnswer("/n700/enquete/xml/?limit=10&question_id=" + question_id + "&option_id=" + option_id);
			return false;
		});
	});
	show_graph($("#enq_a"), Math.floor(6.68 * option_count[0]) + "px");
	show_graph($("#enq_b"), Math.floor(6.68 * option_count[1]) + "px");
	show_graph($("#enq_c"), Math.floor(6.68 * option_count[2]) + "px");
	show_graph($("#enq_d"), Math.floor(6.68 * option_count[3]) + "px");
	show_graph($("#enq_e"), Math.floor(6.68 * option_count[4]) + "px");
});

function show_graph(g, w) {
	g.animate({ 
		width: w
	}, 2000 );
}
function updateAnswer (xml_url) {
	$.ajax({
		url: xml_url,
		type: 'GET',
		datatype: 'xml',
		timeout: 10000,
		success: function (xml) {
			answers = "";
			$("answer", xml).each(function () {
				answers += "<li>" + $('content', this).text() + "</li>";
			});
			$(".a").html(answers);
		}
	})
};
