var lsQuestion = {
	vote: function(idTopic) {
		var obj = $('topic_question_area_' + idTopic), idAnswer = [];
		if (obj) {
			obj.getElements('[name^=topic_answer]').each(function(chk) {
				if (chk.checked) idAnswer.push(chk.value);
			});
			JsHttpRequest.query(
    			'POST ' + DIR_WEB_ROOT + '/plugins/lsquestion/include/ajax/questionVote.php',
	        	{ idTopic: idTopic, idAnswer: idAnswer, security_ls_key: LIVESTREET_SECURITY_KEY },
	    	    function(result, errors) {
    	    		if (!result) {
        	    	    msgErrorBox.alert('Error','Please try again later');
	        		}
    	        	if (result.bStateError) {
        	    		msgErrorBox.alert(result.sMsgTitle,result.sMsg);
	            	} else {
    	        		msgNoticeBox.alert(result.sMsgTitle,result.sMsg);
        	    		obj.set('html',result.sText);
	        	    }
	    	    },
    	    	true
	    	);
		}
	},
	chart: function(idTopic, data) {
		google.load('visualization', '1', {'packages':['corechart']});
		google.setOnLoadCallback(function() {
			var tb = new google.visualization.DataTable();
			tb.addColumn('string', 'Answer');
			tb.addColumn('number', 'Count');
			tb.addRows(data);
			var chart = new google.visualization.PieChart(document.getElementById('ls_question_chart_' + idTopic));
			chart.draw(tb, {width: 400, height: 240, is3D: true, chartArea: {left: 0, top: 20, width: '100%', height: '100%'}});
		});
	}
};


